STM32H563 I2C Stuck Busy
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):
- 250MHz peripheral clock
- I2C_CR1 = 0x00000001 (only PE is set)
- I2C_CR2 = 0x020220A6 (SADD=0xA6, START=1, NBYTES=2, AUTOEND=1)
- I2C_OAR1 = 0x00008000 (OA1EN=1)
- I2C_OAR2 = 0x00000000
- I2C_TIMINGR = 0x3090216C (SCLL=0x6C, SCLH=0x21, SDADEL=0x00, SCLDEL=0x09, PRESC=0x03)
- I2C_TIMEOUTR = 0x00000000
- I2C_PECR = 0x00000000
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!
