2025-01-16 01:12 PM
Hello everyone, I am writing some code to control an IS31FL3736 LED Matrix Driver which communicates over I2C. I am using a Nucleo H563 as the devboard. I have 4.7k pullup resistors on the SDA and SCL lines. I am using I2C4 with PG6 & PG7 as the SDA & SCL pins respectively.
The problem I am running into is that occasionally when I try to call HAL_I2C_Master_Transmit(), both the data and clock lines get pulled low by the microcontroller. The original call to HAL_I2C_Master_Transmit() fails because of a timeout, and all successive calls to HAL_I2C_Master_Transmit() timeout. The only status bits I see set in the peripheral's I2C_ISR are TXE and BUSY. I didn't see any behavior like this listed in the errata, as well as I couldn't find any references to this behavior elsewhere online.
The exact configuration of I2C4 is as follows (all code was generated by CubeMX):
The code snippet:
static void led_unlockCMD() {
uint8_t txbuf[2] = { 0xFE, 0xC5 };
HAL_I2C_Master_Transmit( &hi2c4, 0xA6, txbuf, 2, 20 );
}
I've tried different baud rates, disabling clock stretching, and soldering directly to the dev board instead of using jumpers and a breadboard. I've also tried some different clock configurations and found that lower clock rates tend to cause this error less, but they still do occur.
I verified this behavior using a digital logic analyzer, and I made sure it was the microcontroller by disconnecting the clock and data jumper wires, which caused the lines to return high, so I'm pretty sure it's something with the microcontroller, whether it's software or hardware I don't know. Additionally, I do have a second Nucleo H563 which exhibited the same behavior when flashed with the same software.
Any feedback is appreciated!
2025-01-16 01:26 PM
Here's some screenshots of the digital logic analyzer showing normal (but still unusual) behavior, and a lockup.
Regular Behavior:
Note that there is about 130us between the clock falling the first time and the actual clock pulses, then there's an unusually long pulse pulling SCL low ~600us after the transmission and holding low for ~7ms. That all seems strange.
Lockup Behavior:
As you can see, both the clock and data lines are pulled low.
2025-01-16 07:43 PM
Scope analog signals. Is there noise? Try to tweak the analog and digital filters of the I2C (see the RM).