I2c NACK protocol ambiguity

I have a question about the I2C protocol. I found this on the wikipedia page.

"If the transmitter sees 1 bit (NACK), it knows that:

1) The slave cannot receive data. 2) There is no such subordinate 3) The command is not understood 4) No more data can be received.

The first and fourth points seem to contradict each other. Scenario: I am trying to communicate between microcontrollers, therefore, one will act as a master and the other as a slave. I am transmitting 10 bytes from the master and the slave can only receive 5 bytes in my implementation.

So my question is i2c protocol when slave sends NACK? 1) After receiving the 5th byte. 2) After receiving the 6th byte.

+3


source to share


1 answer


This is a very good question. I looked at the actual I2C spec ( http://www.nxp.com/documents/user_manual/UM10204.pdf ) and one of the conditions it lists for NACK is "During transmission, the receiver cannot receive more data bytes." However, every piece of code I have seen for transmission from the master considers the received NACK as an error.

My experience is that slaves do not have redundant NACK bytes: they either wrap themselves internally, or silently extra data.

I feel that if you want to redirect the extra NACK data you should NACK the 6th byte (where you expect 5).



Note that this is a different case from receiving main data, where a NACK of the last byte is required, just before STOP. This is described on a separate line in the specification: "The master-receiver shall signal the completion of the transmission to the slave transmitter."

All this information is contained in section 3.1.6 in the specification.

+2


source







All Articles