AnsweredAssumed Answered

I2C Stop after Address

Question asked by Franck80 on Apr 27, 2016
Latest reply on Apr 28, 2016 by Franck80

I am trying to handle I2C bus errors on the master side => get the I2C bus working again after detecting an error. (MCU: STM32F407)

In the following test, the master send an Address + Read command to a none existing slave address.
The firmware detect the none responding slave with a 20us time-out and try to reset the bus.
But after trying several methods to reset the bus, I always get the same problem:
Next time I try an Address + Read, the master send a stop condition mediately after the Slave NACK (or ACK if the slave is connected)

Any idea on what could get the master to send a stop condition after sending an address?
I tried to disable the stop condition just before sending the address, no change.


01./* Start condition */
02.I2C_GenerateSTART(I2Cx, ENABLE);
03.while(!I2C_CheckEvent(I2Cx, I2C_EVENT_MASTER_MODE_SELECT));
05./* Address + Read */
06.I2C_Send7bitAddress(I2Cx, Addr, I2C_Direction_Receiver);
08./* Wait for Slave ack or time-out */
10.while(!I2C_GetFlagStatus(I2Cx, I2C_FLAG_ADDR))
12.    if(Tempo_IsTimeOut())
13.    {
14.        (void)(I2Cx->SR1);      // Clear ADDR flag
15.        (void)(I2Cx->SR2);
16.        ResetBus();
17.        return false;
18.    }