2
\$\begingroup\$

We are having issues with the I2C communication on our I2C bus and it seems like one of the INA233s on the bus is causing the issue. We are using the INA233s as current and power monitors. We use command 89h to read the 2 data bytes that give us a current measurement.

This seems to work fine. We also use 97h to give us the input power measurement reading. We also expect a 2-byte read from this. Most of the time these two commands work as intended. Once we engage a brake motor it seems like the INA233 that is reading that power measurement tends to hold the clock line high and the data line is held low. The bus is held in this state after this point. The only way to fix the issue is to power cycle the board.

I am using a Beagle to read the I2C communication on the bus and seems like the read I get back from the 97h command reads: FF 3B 00. We are receiving what the Beagle says is 3 bytes back. This may be a different issue that is causing this problem, but thought I would post on here to see if anyone had an idea of what might be going on. Any thoughts would help.

enter image description here

enter image description here

\$\endgroup\$
6
  • \$\begingroup\$ Updated the post with captured data and clock lines along with the 24V and 5V supply lines. \$\endgroup\$
    – slinkogel
    Commented Aug 24, 2023 at 20:48
  • 1
    \$\begingroup\$ Can you ask a specific question? \$\endgroup\$
    – Voltage Spike
    Commented Aug 24, 2023 at 21:14
  • 1
    \$\begingroup\$ The SDA and SCL snap both high and low and not with the usual sawtooth look of a line being crisply low and then the slower exponental journey to high. What is your pullup resistance and are your devices driving the lines low and high? \$\endgroup\$
    – D Duck
    Commented Aug 25, 2023 at 13:08
  • \$\begingroup\$ @VoltageSpike I am relatively new to I2C and just wanted to see if anyone had any ideas as to what could be causing the issue/how to debug this problem. \$\endgroup\$
    – slinkogel
    Commented Aug 25, 2023 at 16:31
  • \$\begingroup\$ That last 00 seems an input by Beagle that shouldn't occur...(there are no clock pulses that justify its presence). It is possible that the ACK at the end of the 3B transaction was not terminated properly. Be aware that after ACK, bus control should return to Beagle. Beagle seems to be reading its I2C data register when it should not - I'd be looking at the Beagle-end for the fault, not at INA233-end \$\endgroup\$
    – glen_geek
    Commented Sep 1, 2023 at 13:53

1 Answer 1

4
\$\begingroup\$

A quick note: An I2C device cannot hold a line high -- that's the default state. Since I2C is an open-drain bus, devices can either actively pull the line low or release it to the default state of high. According to the scope shots, it looks like a device is holding the SDA line low at the end of the transaction and the clock line at it's default state of high.

The Problem

You can see in the scope shot that the last byte sent is 0x3B, as expected. After that, there is one more clock pulse to allow the master to ACK, which it does by pulling the data line low for that clock pulse (the master can either ACK or NACK on the last byte, it doesn't matter). Then, a stop condition should be sent, which is when a rising edge on SDA occurs while SCL is high. This is all described in the INA233 datasheet:

INA233 Timing Diagram

Your scope shot looks correct until the very end, where the master ACKs (allowable according to footnote 3) but then does not send the stop bit seeing as the data line stays low.

Because some device is holding SDA low after the last byte, and no STOP condition was sent, this might be why the Beagle thinks that there was a third byte sent. It does detect the timeout (the "T" in the error column) but thinks that there's a partial byte as well, probably from the clock going high and then no stop condition so it looks like another byte coming.

That's a detailed look at what the problem is: something is preventing the data line from being released at the end of a transaction. So what could be causing this?

Speculation on the Cause

The fact that the bus remains locked up permanently until a reset hints to me that it's not the INA233 that's the problem -- it has a 28ms timeout specifically to prevent this type of issue. If the INA233 was the culprit, you'd expect to see this issue cause affect a single transaction, but not for the bus to permanently lock up. SDA should be released after 28ms if it was the fault of the INA233 and everything should go back to normal.

That means that I'd start looking at the master device, and particularly taking a careful look at how you turn on the brake motor (since that seems to be the instigator). Your supply voltages aren't noisy and same goes for the data lines, so EMI probably isn't causing the failure. And if the motor itself was the issue, I'd expect to see the bus fail exactly when the motor turns on, not at the last bit of a packet, when everything had been working perfectly fine while the motor was running before.

So how about looking at how you turn on the motor from a firmware perspective? I'd take a look at any state changes when the motor turns on that might somehow affect how the I2C code does it's thing. Or perhaps it's an accidental forever loop on the master after receiving the last byte, therefore never sending the STOP condition. The motor itself feels like a red herring, which could be verified by disconnecting the motor from power and trying again.

I wish I could give a more solid answer, but I hope that this is able to point you towards something more specific to debug. I know that this is a bit of a typical hardware answer, calling it a software problem because the hardware is never the problem, but based on what's given here, I do feel that examining the master code is likely a good move. Best of luck!

\$\endgroup\$
4
  • \$\begingroup\$ Thank you for the thoughtful insight! This answer has helped me better understand the possibilities of what could be going wrong for this problem. We will continue to investigate the issue. \$\endgroup\$
    – slinkogel
    Commented Aug 25, 2023 at 16:38
  • \$\begingroup\$ This is a good answer, it is very detailed. \$\endgroup\$
    – Voltage Spike
    Commented Aug 25, 2023 at 17:12
  • \$\begingroup\$ After many months I seem to have found the problem. On the same i2c bus, there is an accelerometer "ADXL355BEZ". According to its datasheet in the new revision, it states, "When sharing an SDA bus, the ADXL355 may prevent communication with other devices on that bus. If at any point, even when the ADXL355 is not being addressed, the 0x3A and 0x3B bytes (when the ADXL355 device address is set to 0x1D), or the 0xA6 and 0xA7 bytes (when the ADXL355 device address is set to 0x53) are transmitted on the SDA bus, the ADXL355 responds with an acknowledge bit and pulls the SDA line down." \$\endgroup\$
    – slinkogel
    Commented Apr 16 at 14:42
  • \$\begingroup\$ Wow, that's a pretty critical bug. I'd love to know the flaw in the design that led to this, since there's no way that that's intended behavior. Thanks for the follow up! \$\endgroup\$
    – Reid
    Commented Apr 17 at 23:39

Not the answer you're looking for? Browse other questions tagged or ask your own question.