2013-12-23 02:44 PM
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; }2013-12-24 12:54 AM
Hi
Do you have an oscilloscope? Look at what is happening with the oscilloscope. Despite what you might think - the I2C bus master is not in full control of the bus. Any device can pull either SDA or SCL low at any time - hence the arbitration lost. Chances are it is not your code but a real arbitration lost. The tricky bit is understanding why.