I was able to get this working, but not by using I2C_CheckEvent(...). (I am using version 1.1 of the STR91x library.) Through lots of experimentation I discovered that although the ACK failure bit (AF) is alongside the other 'events' in the status registers, ACK failure is not an event but rather just a momentary condition. When you read the status register that contains the AF bit, the bit is automatically cleared.
The way to test for ACK failure that I use is to call I2C_GetLastEvent(..) and check for the specific AF bit (it may be 0x1000, I can't recall for sure). Don't use the masks provided by the firmware library, they don't work in this case. Specifically, looking for EVF | AF won't work, as this condition never occurs. One caution though, I have only used this technique when testing for ACK failure after the first byte (the address byte) in order to see if the slave I'm addressing is actually there. I haven't used it for testing for ACK failure during the data bytes themselves, so this may not work. This reply is long after the OP was made, but hopefully it will help somebody else out. Rich
Am I the only one using the I2C bus??? Someone must know how to detect if a slave is acking or not. I think it is very strange that the example code provided by st does not include this check.
I have exactly the same story going on! However, I can see the ACK on my DSO, The AF Flag is never set. Wheter on right I2C address or wrong. I would like to know WHEN to check for the AF Flag after addressing, as the adressing-finished (ENDAD) flag, needs also to be checked. If the AF flag is cleared on reading the status register, this ends in a dilemma, as it is uncertain which flasg comes up first....... Hope anybody has an idea..
problem solved, the AF flag is SET BEFORE ENDAD flag! do { lastevent = I2C_GetLastEvent(I2C0); if (lastevent & I2C_FLAG_AF) { I2C_GenerateSTOP (I2C0, ENABLE); I2C_Cmd (I2C0, DISABLE); return -1; } else if (lastevent == I2C_EVENT_MASTER_MODE_SELECTED) { break; } }while(1 == 1);