Jon Hart

Bug in Freescale IIC (I2C) example code (AN2318)

Discussion created by Jon Hart on Jun 26, 2006
Latest reply on Aug 8, 2013 by Omar Pighi
For anybody trying to get the freescale example AN2318 IIC code to work.
The code works fine if you tx or rx 2 bytes or more. 
If you rx a single byte, however, the code fails to switch off master transmission acknowledgements ( by setting TXAK = 1).  This is because it relies on the transmission of the "last but one" byte to switch TXAK off.  Of course if you are only rx'ing one byte their is no "last but one" byte.
This problem occurred for me because the AD5242 digital pot I am using requires the reception of a single byte (after the slave address).  The read worked for the majority of the time, but occasionally resulted in the failure of the device to deassert the SDA line.  The failure occured on the next read/write when the bus was still busy.