I2C & LPC1347 - Too many bytes are read when more than 1 byte is requested

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

I2C & LPC1347 - Too many bytes are read when more than 1 byte is requested

867 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by mathseng on Wed Oct 09 19:31:43 MST 2013
Problem:
The sample code for LPC13xx (used for LPC1347) for the I2C example reads back too many bytes when bytes requested is 2 or greater.
The error occurs in the handling of state value 0x50.

Suggested solution:
My suggested correction is to compare the current updated read index plus 1 against the number of bytes being requested.
This is because the action to occur happens AFTER the NEXT byte read, thus showing the need to compare with the modified pointer.

Implementation:
Modify the comparison test code in i2c.c::void I2C_IRQHandler(void) as follows - this then causes the state machine to execute state 0x58 after the NEXT byte - state 0x58 handles the LAST byte being received.
<code>
case 0x50:/* Data byte has been received, regardless following ACK or NACK */
I2CSlaveBuffer[RdIndex++] = LPC_I2C->DAT;
if ( (RdIndex +1) < I2CReadLength )
</code>

Regards,
Bill
标签 (1)
0 项奖励
回复
0 回复数