Skip to content

Commit b8f4af6

Browse files
kb-kb-
kb-
authored and
kb-
committed
fix hang
Added 3 timeouts. Necessary? removed "Wait idle or owner bus mode", already handled by the ship (p459 "Transmitting Address Packets" in SMAD21 datasheet). caused hang on loss of arbitration
1 parent 8b79ff5 commit b8f4af6

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

cores/arduino/SERCOM.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,9 @@ void SERCOM::enableWIRE()
376376
{
377377
// Set inactive time-out (prevent bus hang in multi-master set-up)
378378
sercom->I2CM.CTRLA.bit.INACTOUT = 3 ;
379+
sercom->I2CM.CTRLA.bit.LOWTOUTEN = 1 ;
380+
sercom->I2CM.CTRLA.bit.SEXTTOEN = 1 ;
381+
sercom->I2CM.CTRLA.bit.MEXTTOEN = 1 ;
379382
// I2C Master and Slave modes share the ENABLE bit function.
380383

381384
// Enable the I2C master mode
@@ -496,13 +499,7 @@ bool SERCOM::startTransmissionWIRE(uint8_t address, SercomWireReadWriteFlag flag
496499
address = (address << 0x1ul) | flag;
497500

498501
// Wait idle or owner bus mode
499-
while ( !isBusIdleWIRE() && !isBusOwnerWIRE() )
500-
{
501-
// Check the bus error bit and the arbitration loss bit, restart if set.
502-
if (sercom->I2CM.STATUS.bit.ARBLOST) {
503-
return false;
504-
}
505-
}
502+
// while ( !isBusIdleWIRE() && !isBusOwnerWIRE() );//causes hang on loss of arbitration; not necessary, handled by the chip (p459 "Transmitting Address Packets" in SMAD21 datasheet)
506503

507504
// Send start and address
508505
sercom->I2CM.ADDR.bit.ADDR = address;

0 commit comments

Comments
 (0)