Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

STM32f10c-Eval , I2C Arbitration lost problem.

Status
Not open for further replies.

lignin

Junior Member level 2
Junior Member level 2
Joined
Apr 27, 2013
Messages
22
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,436
hello forum.
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 .
 

Hi,

Arbitration lost is a state where two masters are transmitting data on the bus at the same time.

The one who sends the lower address / data byte, would win the arbitration.

In your case, there's just one master, so no arbitration happens.

Could it be that you have two devices that putting data on the bus?
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top