Open rawlines opened 1 month ago
Ok, i've found htat the existing forumula is the result of clearing the BAUD variable in the following equation:
The result after clearing is:
sercom->I2CM.BAUD.bit.BAUD = SystemCoreClock / (2 * baudrate) - 5 - ((SystemCoreClock * WIRE_RISE_TIME_NANOSECONDS) / 2);
I'll assume that you are dividing by 1000000 SysctemCoreClock and then multiplying by 1000 for unit conversion purposes, But another thing. This formula will work only if BAUD.BAUDLOW is 0, is it worth it to add the following line before the formula?
sercom->I2CM.BAUD.bit.BAUDLOW = 0;
I've read in SAMD21 datasheet that the frequency generated for the I2C SCL line depends on the BAUD register.
Accoring to the documentation, this field should be generated using the following ecuations:
I've seen in the code inside this method that clock frequency is generated using the following line:
I was willing to know where this ecuation comes from as in the documentation says that for Synchronous baudrate the following ecuation should be used:
From that point of view, should that line be something like this?:
The datasheet: https://ww1.microchip.com/downloads/en/DeviceDoc/SAM_D21_DA1_Family_DataSheet_DS40001882F.pdf, page 412-413