求一个从机通信程序...
功能是 主接收 从发送模式...
现在问题是主能接收一次 第二次就接收不到了...会卡在RECIVED_BYTE那里
不知什么原因...很可能是程序写错了...望指教...
void TRANSFER_Slave(void)
{
while(!I2C_CheckEvent(I2C1, I2C_EVENT_SLAVE_TRANSMITTER_ADDRESS_MATCHED));
I2C_SendData(I2C1, 0x01);
while(!I2C_CheckEvent(I2C1, I2C_EVENT_SLAVE_BYTE_TRANSMITTED));
I2C_SendData(I2C1, 0x02);
while(!I2C_CheckEvent(I2C1, I2C_EVENT_SLAVE_BYTE_TRANSMITTED));
I2C_SendData(I2C1, 0x03);
while(!I2C_CheckEvent(I2C1, I2C_EVENT_SLAVE_BYTE_TRANSMITTED));
I2C_SendData(I2C1, 0x04);
while(!I2C_CheckEvent(I2C1, I2C_EVENT_SLAVE_BYTE_TRANSMITTED));
// while(!I2C_CheckEvent(I2C1, I2C_EVENT_SLAVE_STOP_DETECTED)); //有这句卡这句
//Clear I2C2 STOPF flag: read operation to I2C_SR1 followed by a write operation to I2C_CR1
(void)(I2C_GetFlagStatus(I2C1, I2C_FLAG_STOPF));
I2C_Cmd(I2C1, ENABLE);
} |