We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f6148c3 commit 63366ddCopy full SHA for 63366dd
cores/arduino/SERCOM.cpp
@@ -458,7 +458,12 @@ void SERCOM::initMasterWIRE( uint32_t baudrate )
458
// sercom->I2CM.INTENSET.reg = SERCOM_I2CM_INTENSET_MB | SERCOM_I2CM_INTENSET_SB | SERCOM_I2CM_INTENSET_ERROR ;
459
460
// Synchronous arithmetic baudrate
461
- sercom->I2CM.BAUD.bit.BAUD = SystemCoreClock / ( 2 * baudrate) - 5 - (((SystemCoreClock / 1000000) * WIRE_RISE_TIME_NANOSECONDS) / (2 * 1000));
+ baudrate = SystemCoreClock / ( 2 * baudrate) - 5 - (((SystemCoreClock / 1000000) * WIRE_RISE_TIME_NANOSECONDS) / (2 * 1000));
462
+ if(baudrate > 255) // I2C baud rate is 8bit
463
+ {
464
+ baudrate = 255;
465
+ }
466
+ sercom->I2CM.BAUD.bit.BAUD = baudrate;
467
}
468
469
void SERCOM::prepareNackBitWIRE( void )
0 commit comments