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

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

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

4,363 次查看
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.
标签 (1)
0 项奖励
回复
3 回复数

1,101 次查看
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 项奖励
回复

1,101 次查看
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 项奖励
回复

1,101 次查看
DrSeuss
Contributor I

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

Thank you.

0 项奖励
回复