Skip to main content
Junde
Senior III
January 13, 2025
Question

Is this a HAL IIC bug?

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!

 

This topic has been closed for replies.

2 replies

ST Technical Moderator
January 13, 2025

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?

 

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Saket_Om
Andrew Neil
Super User
January 13, 2025
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.