AnsweredAssumed Answered

STM32 I2C arbitration lost problem

Question asked by arslan.bahadir on Dec 23, 2013
Latest reply on Dec 24, 2013 by sung.chen_chung
hello forum.
I am trying to communicate with mpu6050 with I2C. I am trying to receive data from sensor.
But when I send second address of sensor , arbitration lost is occur. ARLO(arbitration lost bit) is set. There is one master and one slave in communication so how can ARLO bit is set ? I cant understand this situation . Can you help me pls ?
thank you.
here is my code :
uint8_t I2C_SingleByteRead(uint8_t register_address)
{
     uint8_t mask=0;
     
     while(I2C_GetFlagStatus(I2C1,I2C_FLAG_BUSY)==SET);          
               
     I2C_GenerateSTART(I2C1,ENABLE);
     
     while(I2C_CheckEvent(I2C1,I2C_EVENT_MASTER_MODE_SELECT)==ERROR);                                                                           
     
     I2C_Send7bitAddress(I2C1,MPU6050_Default_Address,I2C_Direction_Transmitter);
     
     while(I2C_CheckEvent(I2C1,I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED)==ERROR);                                                                                                                                                      
     I2C_Cmd(I2C1,ENABLE);
     
     I2C_SendData(I2C1,register_address);                                                                                                                             
     
     while(I2C_CheckEvent(I2C1,I2C_EVENT_MASTER_BYTE_TRANSMITTED)==ERROR);                                                                                                                                                                                                                                           
     
     I2C_GenerateSTART(I2C1,ENABLE);                                             
     
     while(I2C_CheckEvent(I2C1,I2C_EVENT_MASTER_MODE_SELECT)==ERROR);                                                                                                                                                                     
     I2C_Send7bitAddress(I2C1,MPU6050_Default_Address,I2C_Direction_Receiver);
     ********************* arbitration lost bit is set*******************
     while(I2C_CheckEvent(I2C1,I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED)==ERROR);                                                                                                                                                           
     
     I2C_AcknowledgeConfig(I2C1,DISABLE);                                                                                                                                                                                                                  
     I2C_GenerateSTOP(I2C1,ENABLE);
     
     while(I2C_CheckEvent(I2C1,I2C_EVENT_MASTER_BYTE_RECEIVED)==ERROR);
     
     mask=I2C_ReceiveData(I2C1);
     
     I2C_AcknowledgeConfig(I2C1,ENABLE);                                        
     
     return mask;     
}

Outcomes