I²C (Inter-Integrated Circuit) is a serial bus, that is used to exchange data with low-speed peripherals. I²C uses two bi-directional lines, serial data (SDA) and serial clock (SCL). Typical voltages used are +5 V or +3.3 V. The most common I²C bus modes are the 400 kbit/sec fast mode, the 100 kbit/s standard mode and the 10 kbit/s low-speed mode. A high speed mode of 3.4 Mbit/sec is also available.
I²C uses a 10 bit address space with 16 reserved addresses, which means that a maximum of 1008 nodes can communicate on the same bus. Two types of nodes are possible: master and slave. I²C devices use a dedicated protocol to communicate with each other.
When devices on a I²C bus are not communicating properly, something must be wrong and the error has to be found. Measuring the electrical parameters of the two signals in the I²C bus can be done easily with an oscilloscope. But, when the electrical parameters are all OK, the signals have to be analyzed, to check if the communication protocol is implemented properly.
To measure I²C signals, a measuring instrument with at least two channels is required. The maximum frequency on the I²C bus depends on the bus type, the instrument must sample at at least twice the maximum speed on the bus, but preferable five to ten times higher, on both channels. For a 100 kbit/sec bus that would mean a minimum sampling frequency of at least 1 MHz on both channels. I²C uses either 3.3 Volt or 5 Volt, so the instrument should be able to measure voltages between 0 and 5 Volt. Since data transfers can be long, a long record length is preferred to capture the communication.
The Handyscope HS3, Handyscope HS4, Handyscope HS4 DIFF and the TiePieSCOPE HS805 are suitable instruments to measure I²C signals.
To examine the communication protocol in the measured signals, the various pulses on both signals have to be examined and their sequences have to be converted in I²C commands.
The TiePie engineering Multi Channel software is capable of analyzing the I²C communication protocol, using the I²C analyzer.
In this example, a Handyscope HS4 is used to measure I²C signals on an I²C EEPROM that is being accessed.
First the Handyscope HS4 is connected to the computer and the Multi Channel software is started.
Now connect Ch1 to the Serial Clock signal of the I²C bus and Ch2 to the Serial Data signal of the I²C bus. The ground terminals of the two input channels must be connected to the same ground as the I²C bus uses.
Since only two channels are used to measure the I²C signals, Ch3 and Ch4 of the Handyscope HS4 are removed from the screen.
We are using Ch1 to measure the Serial Clock signal (SCL) and Ch2 to measure the Serial Data signal (SDA). To simplify recognition of the signals, they can be given a descriptive name (alias). To change the alias of a channel, right-click the channel in the object tree and select Set alias... and enter the required alias. Give Ch1 the alias "SCL" and Ch2 the alias "SDA".
I²C signals lie between 0 Volt and either +3.3 Volt or +5 Volt. Therefore, set the channel input coupling of both channels to "DC" and set the input sensitivity of both channels to "8 Volt" full scale. That way both signal levels can be measured properly.
The I²C signals in our example are measured on a 100 kbit/sec bus, and can therefore be up to 100 kHz in frequency, which means that the minimum required sampling frequency must be 200 kHz. However, this results in only 2 samples per period, barely enough to recognize the signal but not enough to analyze it properly. Therefore, set the sampling frequency to at least 1 MHz.
Since I²C communication can take several milliseconds, a long record length is preferred, to capture as much as possible of the communication. In this example, a relative short communication is measured, therefore the record length is set to 20000 samples. When a longer communication is expected, set the record length to a longer value, e.g. 100000 samples.
Both SCL and SDA are high in idle state. When a communication starts, first the SDA line is made low. Therefore, select Ch2 as trigger source, set the trigger mode to "falling slope" and set the trigger level to a value half way the signal, e.g. 1.5 Volt. Set the trigger hysteresis to e.g. 0.5 Volt. A trigger will now occur when Ch2 measures a falling slope, where the signal is initially above +2 Volt and drops below 1.5 Volt.
To analyze the I²C signals, the I²C analyzer sink is used. Create one by right-clicking Sinks in the object tree. This also opens an additional window, which will display the analyzed I²C communication.
The I²C analyzer requires two sources to be connected, the first source that is connected is treated as SCL, the second signal is treated as SDA. First drag Ch1 on the I²C analyzer and then drag Ch2 on the I²C analyzer.
The I²C analyzer output window will now display which source is connected to the SCL input and which source is connected to the SDA input of the analyzer.
When the inputs are connected to the wrong sources, a click on the Swap inputs button
will swap the inputs.
The I²C analyzer can analyze both 3.3 Volt I²C buses and 5 Volt I²C buses. To set the bus voltage, right-click the I²C analyzer sink in the object tree, select Voltage and then select either 3.3 Volt or 5 Volt. In our example we measure on a 3.3 Volt bus.
Now both input channels and I²C analyzer are configured, a measurement can be performed and analyzed.
The I²C signals shown in the screen shot above are from communication with an EEPROM. They are converted by the I²C analyzer into the following commands:
To clear the I²C output window for a new measurement, press the Clear text button
.
When a block of communication is longer than the I²C output window, it is not possible to see
all text that is appended.
The window has an auto scroll function, which always makes sure the bottom lines are visible.
To toggle this function, click the Auto scroll button
.
To save the contents of the output window to a file, press the Save button
.
The I²C protocol uses addresses to access the various devices on the bus. To simplify reading the decoded I²C communication, the addresses in the output window can be replaced by descriptive names (aliases). Click on the Aliases tab in the I²C analyzer output window to set the aliases for the addresses that occur in the decoded communication.
Aliases for addresses can be added by clicking the Add Alias button
and edited with the Edit alias button
.
Often used aliases can be saved to disk (
) and restored from disk (
).
Once address aliases are set, all next measurements will display the entered aliases.