cancel
Showing results for 
Search instead for 
Did you mean: 

I2C transmit error by I2C_FLAG_AF flag

Junde
Senior

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.

1 REPLY 1
TDK
Guru

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.

If you feel a post has answered your question, please click "Accept as Solution".