I2C程序调了好几天了,还没有调通,存在的问题是:一直收不到应答信号。如下,由IntSource==I2C_ARDY_ISRC引起中断,然后就进入:
if(I2caRegs.I2CSTR.bit.NACK == 1)
{
I2caRegs.I2CMDR.bit.STP = 1;
I2caRegs.I2CSTR.all = I2C_CLR_NACK_BIT;
Count3++;
}
Count3一直在自加,而没执行CurrentMsgPtr->MsgStatus = I2C_MSGSTAT_RESTART;
包括写数据时也受不应答信号。什么原因引起的呢了,外设器件有问题吗??
// Interrupt source = Register Access Ready
// This interrupt is used to determine when the RTC address setup portion of the
// read data communication is complete. Since no stop bit is commanded, this flag
// tells us when the message has been sent instead of the SCD flag. If a NACK is
// received, clear the NACK bit and command a stop. Otherwise, move on to the read
// data portion of the communication.
else if(IntSource == I2C_ARDY_ISRC)
{
if(I2caRegs.I2CSTR.bit.NACK == 1)
{
I2caRegs.I2CMDR.bit.STP = 1;
I2caRegs.I2CSTR.all = I2C_CLR_NACK_BIT;
Count3++;
}
else if(CurrentMsgPtr->MsgStatus == I2C_MSGSTAT_SEND_NOSTOP_BUSY)
{
CurrentMsgPtr->MsgStatus = I2C_MSGSTAT_RESTART;
Count4++;
}
} // end of register access ready
|