Hi,
I'm having issues with waiting for ACK/NACK flag in I2CSTR register and by that i mean how do i know the flag status is up-to date(It corresponds to latest operation)? What i'm currently doing is that i'm pushing data into I2CDXR register and i would like to wait and see if the slave did respond with ACK or not - how do i know when to read the register - I cannot read it immediately because it won't be set yet.
Pseudo not working code:
HWREG_WRITE_32(pI2C->DXR, byte);
// Note that this will never evaluate to True....
if (0U != (HWREG_READ_32(pI2C->STR) & (1U << I2C_STR_NACK_POS)))
{
// Nack received
}
Psuedo working code:
HWREG_WRITE_32(pI2C->DXR, byte);
Delay(100);
if (0U != (HWREG_READ_32(pI2C->STR) & (1U << I2C_STR_NACK_POS)))
{
//Nack received
}
The delay method does work but it's far from ideal - any ideas how it can be improved?
Any ideas?