I2C: how to figure out what is holding SCL or SDA low? - Page 1
Forum section: electronics / projects

author: mwb1100
author_rank: Frequent Contributor
timestamp: November 07, 2022, 07:55:34 pm
content: Let me know if there's a better part of the forum to post this question.I'm trying to troubleshoot a problem with I2C communication. An STM32 is the I2C controller (aka master), anNXP PCF8551 LCD controlleris the I2C target (aka slave). The PCF8551 has 24 registers that can be written or read. I can successfully read registers from the PCF8551 - but only up to 12 in a single I2C transaction. From my reading of the data sheet, I should be able read all 24 in a single transaction.However, when I try to read more than 12 registers, both the SCL and SDA channels get held low (as if there's a very long "clock stretch") - the SCL line is held low for almost half a second (470ms or so) and the SDA line gets held low forever, so no further I2C communication can occur. It takes a power off/on reset to get it back into a usable state.I'm curious if there's a way I can use an oscilloscope to determine whether it's the STM32 or the PCF8551 that is driving these signals low?What I can currently see is the lines are being driven low, but it's possible for either (or both) of the devices on the I2C bus to do that (there are no other devices on that I2C bus).Some pictures to show what's going on:- 12 byte read that works correctly (note that the SDA and SCL lines are released, letting the pull-up bring them high)- 13 byte read that doesn't work (note that the SDA and SCL lines remain held low at the end of the read)- zoom out that shows the SCL eventially being released after 470ms, while the SDA line remains low forever

author: DavidAlfa
author_rank: Super Contributor
timestamp: November 07, 2022, 08:13:36 pm
content: Put a 10K pullup at both sides and 470R resistor in series.The side having higher voltage is not the one pulling it down.

author: mwb1100
author_rank: Frequent Contributor
timestamp: November 07, 2022, 08:26:44 pm
content: That was quick! Thanks!A couple questions: I'd probe at the locations where the blue arrows are? And the switches at the bottom: I have to have only one closed at a time and I'd close the one that corresponds to the side I'm probing?(I probably should have mentioned that you're talking to a software guy, so when you're talking resistors and capacitors you might want to talk to me like I'm a 5th grader. Maybe even a 2nd grader)

author: DavidAlfa
author_rank: Super Contributor
timestamp: November 07, 2022, 08:31:54 pm
content: You can probe anywhere between the resistor and the SDA pin, it's the same network, there's nothing to affect the readings.

author: mwb1100
author_rank: Frequent Contributor
timestamp: November 07, 2022, 08:57:23 pm
content: So I set the probe then flip the switch to measure the effect of either the STM32 or the PCF8551?

author: ataradov
author_rank: Super Contributor
timestamp: November 07, 2022, 09:02:11 pm
content: I don't see why you would need the switches. I use this method all the time. Just measure voltage levels on both sides of the 470 Ohm resistor. Whichever is lower, is the side driving the bus.

author: DavidAlfa
author_rank: Super Contributor
timestamp: November 07, 2022, 09:04:51 pm
content: When your SDA locks up, measure the voltage at both sides.You don't need any fancy equipment, a simple multimeter in the 200-600 mVDC range will work!The side to blame will read 0V, the other should measure 0.15V. Simple as that.

author: mwb1100
author_rank: Frequent Contributor
timestamp: November 07, 2022, 09:36:06 pm
content: Thanks everyone - for the amazingly quick responses and especially for your patience with me.

author: pcprogrammer
author_rank: Super Contributor
timestamp: November 08, 2022, 06:33:26 am
content: Quote from: mwb1100 on November 07, 2022, 08:26:44 pmThe switches are only in the schematic for the simulation to calculate the voltages. So in real life no switches need to be used.

author: DavidAlfa
author_rank: Super Contributor
timestamp: November 08, 2022, 10:37:16 am
content: Yeah! I didn't realize he was actually meaning those switches