Skip to main content
Graduate II
February 19, 2024
Question

I2C transmit error by I2C_FLAG_AF flag

  • February 19, 2024
  • 1 reply
  • 1703 views

Hi all,

I want to drive Humidity and Temperature Sensor SHT4x(address is 0x44).

I finished the driver code in STM32F103C8 with HAL lib, but when I used the same driver code in STM32F429IG with HAL lib, the HAL_I2C_Master_Transmit() always returned HAL_ERROR. After debugging, the error comes from the following code:

Junde_0-1708322372777.png

This topic said the reason is the I2C master did NOT receive the ACK by slave.

But I catch the signal by an oscilloscope, and it seems the sensor already ACK:

Junde_1-1708322646196.png

I try to send the command 0xFD(measure T & RH with high precision), MCU should write the device addr, following by the command, but here just the device address.

What happened, please help me! Thanks a lot.

    This topic has been closed for replies.

    1 reply

    Super User
    February 19, 2024

    Sometimes the slave will NACK the last byte of the transfer which can lead to this issue. A logic analyzer capture of the full transaction would clear things up.