Description
This is Issue 486 moved from a Google Code project.
Added by 2011-02-26T20:06:51.000Z by dmel...@gmail.com.
Please review that bug for more context and additional comments, but update this bug.
Original labels: Type-Defect, Priority-Medium, Component-Core
Original description
From http://arduino.cc/forum/index.php/topic,53131.0.html:
"Hello..
there is a bug in twi.c which effectively disconnects TWI/I²C after an error in Slave Receiver mode.
The bug is in SIGNAL(TWI_vect) at case label TW_SR_DATA_NACK/TW_SR_GCALL_DATA_NACK
the wrong code is:
// nack back at master
twi_reply(0);
This should be:
twi_reply(1);
Explanation: See ATmegaxxx Documentation (doc8161.pdf) from Atmel. In Fig. 21-16 on page 236 the states $88 (TW_SR_DATA_NACK) and $98 (TW_SR_GCALL_DATA_NACK) are final states. There is nothing to "nack back at master". This has already been done! Unlike the $80 (TW_SR_DATA_ACK) and $90 (TW_SR_GCALL_DATA_ACK) states, there will be no $A0 state (TW_SR_STOP) to terminate. Table 21-4. on page 235 shows that if we now leave TWEA off, we will never be able again to be selected as receiver. Calling twi_reply(1) will set TWEA and thus allow further selection as slave."