cancel
Showing results for 
Search instead for 
Did you mean: 

Is this a HAL IIC bug?

Junde
Senior III

Hi there,

I drove 4 SHT4x by STM32G473VE and used the HAL_I2C_Master_Transmit() and HAL_I2C_Master_Receive() to write and read the sensors.

Normally, everything is well.

However, if I

  1. unplug the sensor;
  2. replug the sensor again;(Not the sensor maybe can NOT work normally)
  3. reset the MCU;

the program will probably run into  the following dead loop:

Junde_0-1736739151853.png

I don't know why this happened, and how I can recover from this error state.

Thank you!

 

2 REPLIES 2
Saket_Om
ST Employee

Hello @Junde 

 

Have you tried checking the device with the HAL_I2C_IsDeviceReady() API after unplugging and replugging it?

Could you provide the data transmission trace using the logic analyzer?

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Saket_Om

Previous discussion on recovering from problems on the I2C bus:

https://community.st.com/t5/stm32-mcus-embedded-software/hal-i2c-geterror-reporting-error-codes/m-p/677103/highlight/true#M47943

 

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.