发送一个字节的程序如下:
void IIC_WriteByte(uint8_t dat,uint16_t Waddr,uint8_t EAddr)
{
while(I2C_GetFlagStatus(I2C_FLAG_BUSBUSY));
I2C_GenerateSTART(ENABLE);
while (!I2C_CheckEvent(I2C_EVENT_MASTER_MODE_SELECT));
I2C_Send7bitAddress(EAddr, I2C_DIREC
tiON_TX);
while (!I2C_CheckEvent(I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED));
I2C_SendData(Waddr>>8);
while (!I2C_CheckEvent(I2C_EVENT_MASTER_BYTE_TRANSMITTING));
I2C_SendData(Waddr&0x00ff);
while (!I2C_CheckEvent(I2C_EVENT_MASTER_BYTE_TRANSMITTING));
I2C_SendData(dat);
while (!I2C_CheckEvent(I2C_EVENT_MASTER_BYTE_TRANSMITTED));
I2C_GenerateSTOP(ENABLE);
}
其它的while 语句试过,除了while(I2C_GetFlagStatus(I2C_FLAG_BUSBUSY));以外,其它while都在执行死循环,求各位大神指点,谢谢~