2019-09-03 12:48 AM
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 ?
2019-09-03 08:25 AM
Actually Slave device recived a data, but did not receive second data. master device was stop at second data. I don't know couse
2019-09-03 08:39 AM
Again, have you got your Master thoroughly tested and debugged working with a standard slave?
If you haven't, then you need to do that first!
If you have, then you should be familiar with what happens when it is working properly - and, from that, be able to see where it's going wrong with your slave...
2019-09-03 08:55 AM
Yes ı did. İt is working properly. İt has no problem. But now it has a problem that ı dont know
2019-09-12 07:02 AM
Then you need to get debugging ...