Other Parts Discussed in Thread: AM4379
Hi,
I'm using Starterware v02.01.00.01 on AM4379, and communicating over i2c using the i2c_utils from the examples.
I have found that NACKs are not handled correctly. In fact I can send bytes to any (non-existant) i2c device address and the I2CUtilsWrite() function will return S_PASS (rather than the expected E_I2C_NAK_ERR).
Looking inside I2cUtilsTransceive() I see the following:
/*transmit byte of data*/
I2CPutTxData(instObj->baseAddr, dataByte);
/*Check for status*/
devStatus = I2CIntrRawStatus(instObj->baseAddr);
/*check nack status*/
if (devStatus & I2C_INTR_NO_ACK)
{
status = E_I2C_NAK_ERR;
break;
}
My feeling is that this can't work, as it takes some time for a NACK to be realised, and the code checks for the NACK status right after writing the data register. However an attempt to fix this by inserting the following after the transmit doesn't help:
do
{
devStatus = I2CIntrRawStatus(instObj->baseAddr);
} while (!((I2C_INTR_REG_ACESS_RDY & devStatus) || (I2C_INTR_NO_ACK & devStatus) || (I2C_INTR_TX_READY & devStatus)));
In fact, even if the loop is changed to wait ONLY for a NACK (and when a NACK is clearly seen on the logic analyser) the NACK bit in the status register is not set.
Has anyone else experienced this and found a solution?
Thanks, Kieran.