I2C serial bus decoding

I2C (Inter Integrated Circuit) is a low-speed serial data protocol, commonly used to transfer data between multiple components and modules within a single device.

Developed in the early 1980s by Philips Semiconductors (now NXP), I2C employs 2 signal wires to transfer “packets” of information between one or more “master” devices such as microcontrollers, and multiple “slave” devices such as sensors, memory chips, ADC and DACs.

Example of I2C wiring diagram

Wiring

Multiple “master” and “slave” I2C devices are connected to the bus using two lines:

  • SCL – Serial Clock
  • SDA – Serial Data

Signaling voltages are typically 0 V for logic low and +3.3 V or +5 V for logic high.

Pull-up resistors keep both lines at logic high level when the bus is idle.

Signaling

I2C bus speeds range from 100 kbit/s in Standard mode, 400 kbit/s in Fast mode, 1 Mbit/s Fast mode plus, and 3.4 Mbit/s in High Speed mode.

Each device on the bus is recognised by a unique 7-bit or 10-bit address.

Data is transferred in “packets”, which include the address of the device, a read/write command, acknowledgements and the data being transferred.

The diagram shows the structure of a single packet of I2C data.

Timing format of an I2C data packet

At the start of packet a master device takes control of the bus by driving SDA low while SCL remains high. This indicates that a message will follow.

Next a 7 (or 10) bit address is transmitted followed by a R/W bit to indicate whether it is a read (1) or write (0) instruction.

The addressed slave device then transmits an acknowledge (ACK) bit by pulling the SDA line low. If the line remains high, the master can infer that the slave did not recognise the address and corrective action needs to be taken.

After the address is acknowledged by the slave, the master continues to generate the clock and depending on the R/W bit either the master or the slave will send data over the bus. After each byte of data sent, an ACK is generated by the receiving device.

The end of packet is recognised by the SDA line going from low to high when the SCL is already high.

PicoScope serial protocol decoder menu, with I2C selected

I2C decoding in PicoScope

I2C serial decoding is included in PicoScope as standard. Select I2C from the list of protocols in the Tools > Serial Decoding > Create drop-down menu.

Settings

In the Settings box select the correct channels and thresholds for Data and Clock and choose the Bus speed to match the device under test.

The bus can be given a name, such as "Temperature sensors", to make it easily readable.

Decoded data can be displayed in the format of your choice: Graph, Table, or both at once.

PicoScope I2C decoder settings menu

Graph

Shows decoded data in a bus format, aligned with the analog waveform, on a common time axis. Frames can be zoomed and correlated with acquired analog channels to investigate timing errors or other signal integrity issues that are the cause of data errors.

Table

Shows a list of the decoded frames, including the data and all flags and identifiers. You can set up filtering conditions to display only the frames or data you are interested in, search for frames with specified properties, or use a Link File to translate frame ID and hexadecimal data into human-readable form.

For more information on PicoScope's serial decoding capabilities, see Serial bus decoding and protocol analysis - overview.