Showing results for 
Search instead for 
Did you mean: 

HAL_I2C_Mem_Read() fail after ST-Link download complete.


Chipmodel : STM32L431RBTx

I use M24C04-WDW6TP EEPROM on I2C line and read it using HAL_I2C_Mem_Read() function.

In normal condition, HAL_I2C_Mem_Read() works well. But After download binary to MCU using ST-Link,  1 case in 1000 times try, HAL_I2C_Mem_Read() return error and fail, or retrun success but readout value is invalid.

In in comparison with J-link instead of ST-Link, no read error occurred.  And with simple On/Off test, no error occurred too.

Have you have any similar case like as my?  

Michal Dudka
Senior III

If you stops (to download new binary) MCU somewhere in I2C communication, your slave device can be stucked and wait to complete previous I2C sequence ... and blocks you.

Is MX_I2C1_Init() which called STM32 FW inittal stage has no effect to reset I2C block? or insufficient?

How to secure I2C init when ST-Link download?


The usual slaves don't reset when the mcu does, and Have you checked bith sda and scl are high before even asking to generate a start bit? If not, do you resync the bus with 9 or 18 stop bits bit bang generated ? Rugged I2C is a brainer.

Pavel A.
Evangelist III

> with J-link instead of ST-Link, no read error occurred

That's why J-links are so expensive ; )