How can I use i2c to communicate two STM32F103
I want to i2c to communicate two STM32F103. one of them will be a slave and other will be master. But program is stop on this :
void SendI2CByteData (I2C_TypeDef* I2Cx, uint8_t SlaveAddr, uint8_t Data)
{
__IO uint8_t temp = 0;
I2C_GenerateSTART(I2Cx, ENABLE); /* NOTE: Generate Start Condition*/
while ((I2Cx->SR1&0x0001) != 0x0001);
I2C_Send7bitAddress(I2Cx, SlaveAddr<<1, I2C_Direction_Transmitter); /* NOTE: Send Slave Addres. Slave addr'yi 1 sola kaydiriyorum ki write biti yazilsin*/
while ((I2Cx->SR1 &0x0002) != 0x0002); /* NOTE: Wait Data to transgfer*/
temp = I2Cx->SR2;
while(!I2C_GetFlagStatus(I2C2,I2C_FLAG_TXE))
I2C_SendData(I2Cx, Data); /* NOTE: Sending Data */
while ((I2Cx->SR1 & 0x00004) != 0x000004); /* NOTE: Wait data sending */
I2C_GenerateSTOP(I2Cx, ENABLE); /* NOTE: Is All Data transfering, then generate stop otherwise i2c bus is hang*/
while ((I2Cx->CR1&0x200) == 0x200);
}
program stop this line :
while ((I2Cx->SR1 & 0x00004) != 0x000004); /* NOTE: Wait data sending
Please can you help me ?
