Boo0ns / arduino

Automatically exported from code.google.com/p/arduino
0 stars 0 forks source link

bug in twi.c which effectively disconnects TWI/I²C after an error in Slave Receiver mode #486

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
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."

Original issue reported on code.google.com by dmel...@gmail.com on 26 Feb 2011 at 8:06

GoogleCodeExporter commented 9 years ago

Original comment by dmel...@gmail.com on 24 Aug 2011 at 6:51

GoogleCodeExporter commented 9 years ago

Original comment by dmel...@gmail.com on 16 Dec 2011 at 10:08