lignin
Junior Member level 2
hello forum.
I am trying to communicate with mpu6050 with i2c.
I write code like this for receive data from sensör :
I create a repeated start condition and I send 7 bit address to device. But when I send 7 bit address to the sensor , arlo bit is set. So arbitration lost occur.
I cant' understand this situation ?
why arlo bit is set ? and How can I solve this problem ?
thank you .
I am trying to communicate with mpu6050 with i2c.
I write code like this for receive data from sensör :
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_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);
while(I2C_CheckEvent(I2C1,I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED)==ERROR);
I2C_AcknowledgeConfig(I2C1,DISABLE);
I2C_ReceiveData(I2C1);
while(I2C_CheckEvent(I2C1,I2C_EVENT_MASTER_BYTE_RECEIVED)==ERROR);
mask= I2C_ReadRegister(I2C1,I2C_Register_DR);
I2C_GenerateSTOP(I2C1,ENABLE);
I2C_AcknowledgeConfig(I2C1,ENABLE);
return mask;
}
I create a repeated start condition and I send 7 bit address to device. But when I send 7 bit address to the sensor , arlo bit is set. So arbitration lost occur.
I cant' understand this situation ?
why arlo bit is set ? and How can I solve this problem ?
thank you .