Complete Guide to I2C Bus Debugging
I2C Fundamentals Recap
I2C (Inter-Integrated Circuit) is a two-wire serial bus using a clock line (SCL) and a data line (SDA). Both lines are open-drain, pulled high by external resistors, and driven low by devices on the bus. Communication follows a master-slave model: the master generates the clock and initiates transactions. Each transaction begins with a START condition (SDA falling while SCL is high) and ends with a STOP condition (SDA rising while SCL is high).
A standard I2C frame consists of a 7-bit address (or 10-bit in extended mode), a read/write bit, and one or more data bytes. After each byte, the receiver must pull SDA low during the 9th clock cycle to send an ACK. If SDA remains high, it is a NACK, indicating an error or end of transfer.
Standard mode runs at 100 kHz, fast mode at 400 kHz, fast mode plus at 1 MHz, and high-speed mode at 3.4 MHz. SMBus is a subset of I2C with stricter timing and voltage specifications, commonly used for power management and system monitoring.
Setting Up I2C Decode on Acute Instruments
Physical Connections
Connect two logic analyzer channels (or two analog channels on an MSO) to SDA and SCL. Always connect the analyzer’s ground lead to the target board’s ground at a point close to the I2C bus.
For logic analyzer connections:
- Set the threshold voltage to match the bus voltage. For 3.3V I2C, a threshold of 1.5V works well. For 1.8V I2C, use 0.8V.
- If using an MSO2000 or MSO3000 in analog mode, you can observe the actual voltage waveforms and identify signal integrity issues that a logic analyzer alone would miss.
Pull-Up Resistor Considerations
Before connecting probes, verify that the I2C bus has appropriate pull-up resistors. The probe’s input capacitance (typically 8-12 pF per channel) adds to the bus capacitance and can slow rise times. On fast-mode buses (400 kHz+) with marginal pull-ups, adding probe capacitance may cause the bus to fail.
If your bus is running near its capacitance budget, use active probes or ensure pull-up values are on the low end of the acceptable range (e.g., 2.2k ohm for 3.3V fast-mode).
Decode Configuration
In the Acute software:
- Open Protocol > I2C Decode (or SMBus Decode for SMBus traffic).
- Assign the SDA and SCL channels.
- Set the address mode (7-bit or 10-bit).
- Configure the display format: hexadecimal is standard; you can also import a device address table to display human-readable device names instead of raw addresses.
- Enable decode and run a capture.
The software overlays decoded transactions directly on the waveform: START, address, R/W bit, data bytes, ACK/NACK, and STOP are all annotated inline.
Trigger Configurations for I2C Debugging
Basic edge triggering on SCL captures everything, but on a busy bus with many devices, you may capture thousands of irrelevant transactions before the one you care about. Acute’s protocol-aware triggers solve this.
Trigger on Specific Address
Configure the trigger to fire when a specific 7-bit address appears on the bus. This is essential when debugging communication with one device on a multi-device bus. The analyzer waits until it sees a START condition followed by the matching address byte before starting capture.
Trigger on NACK
This is the most valuable trigger for debugging I2C problems. Configure the trigger to fire when any byte receives a NACK instead of an ACK. Since NACKs are relatively rare in normal operation, this trigger efficiently catches error conditions without filling memory with healthy transactions.
Trigger on Data Pattern
Trigger when a specific data value appears at a specific byte position in a transaction. This is useful for catching a particular register write (e.g., trigger when address 0x50 is written with register 0x0A set to value 0xFF).
Sequential Trigger
Use Acute’s multi-stage sequential trigger to capture complex scenarios: for example, trigger when device 0x68 is addressed, then a NACK occurs within the next 10 clock cycles. This combination catches intermittent communication failures with a specific device.
Common I2C Issues and How to Identify Them
Missing ACK (Unexpected NACK)
The most common I2C failure. Causes include: incorrect slave address, slave device not powered, slave in reset or sleep mode, or bus capacitance exceeding the slave’s drive capability. Capture with a NACK trigger and examine the preceding address byte to identify which device is not responding.
Bus Contention (Multi-Master Collision)
When two masters attempt to drive the bus simultaneously, SDA shows unexpected intermediate voltages or glitches. On an MSO, analog channels reveal this clearly as voltage levels that are neither fully high nor fully low. On a logic analyzer, you see data corruption: the decoded bytes do not match what either master intended to send.
Clock Stretching Issues
Some I2C slaves hold SCL low to pause the master while they process data. If clock stretching lasts too long, the master may time out (SMBus defines a 35 ms timeout). Capture SCL on an analog channel and measure the duration of low periods. Stretching appears as unusually long SCL low times between byte transfers.
Stuck Bus
A common failure where SDA or SCL is held permanently low, locking the entire bus. This usually occurs when a slave device freezes mid-transaction. To diagnose, capture both lines at a low sample rate over several seconds. If SCL remains low, a slave is stuck in clock stretching. If SDA remains low, a slave is holding data low, and you need to clock SCL manually (9 pulses followed by a STOP) to release it.
Rise Time Violations
On fast-mode and fast-mode-plus buses, excessive capacitance causes SDA and SCL rise times to exceed specification (300 ns for fast mode, 120 ns for FM+). This leads to intermittent bit errors. Use MSO analog channels to measure rise and fall times. If rise times are marginal, reduce pull-up resistance or reduce bus capacitance by shortening traces.
Electrical Validation Checklist
Beyond protocol-level debugging, validate the following electrical parameters using an MSO’s analog channels:
- VOL (output low voltage): Must be below 0.4V at rated sink current
- Rise and fall times: Within specification for the selected bus speed
- Ringing and overshoot: Should be less than 0.5V above VDD or below ground
- Capacitive loading: Total bus capacitance should be below 400 pF (standard mode) or 550 pF (fast mode with tuned pull-ups)
Summary
I2C debugging requires both protocol-level decode and electrical-level observation. Acute instruments provide protocol-aware triggering that lets you capture specific addresses, NACK conditions, and data patterns without wading through thousands of healthy transactions. For buses running at 400 kHz or faster, combine logic analyzer decode with MSO analog channels to catch signal integrity issues that cause intermittent failures.
Produits associes
Besoin d'aide pour choisir le bon instrument ?
Notre équipe d'ingénieurs peut vous aider à trouver la meilleure solution pour votre application. Contactez-nous pour une recommandation personnalisée ou pour planifier une démo.