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

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

4,359 Views
JonHart
Contributor I
FYI:
 
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.
Labels (1)
0 Kudos
Reply
3 Replies

1,097 Views
Selea
Senior Contributor I

to me it doesn't work anyway with 1 byte read... I have a 10th clk after the ack one, so it doesn't make the stop condition...

0 Kudos
Reply

1,097 Views
JonHart
Contributor I
...oh and my solution!
 
Check the number of bytes.  If it is only one, set TXAK when you send the IIC START signal.
 
 
0 Kudos
Reply

1,097 Views
DrSeuss
Contributor I

I think you are correct. I will try to get the AN updated.

Thank you.

0 Kudos
Reply