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

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

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

4,365件の閲覧回数
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,103件の閲覧回数
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,103件の閲覧回数
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,103件の閲覧回数
DrSeuss
Contributor I

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

Thank you.

0 件の賞賛
返信