Closed benpicco closed 4 years ago
Indeed, this is true for SAMD51. The baud calculation should be slightly rework. We should also use the SERCOM GCLK input clock instead of CLOCK_CORECLOCK (which is a legacy from old SAMD21 inplementation). I can have a deeper look after the summit if you want.
I think it helpful to look at how Zephyr is handling it. But it looks like we need to use a slower GCLK.
One quick workaround could be to use GCLK5 (already used by xtimer) and replace the hardcoded CLOCK_CORECLOCK. Since the issue only affects SAME54 (for now) this could be the way to go for now. In a second time, I think we could put some work into a new way to handle clock init / clock management (like a struct array parse during boot ?) in order to replace all hardcoded stuff among SAM0 drivers.
Description
The I2C baudrate is always derived from
CLOCK_CORECLOCK
, even if a different.gclk_src
is selected. IfCLOCK_CORECLOCK
is too high, the resulting baudrate will is too big and a check ini2c_init()
silently fails, leaving the I2C uninitialized.Any resulting access to the i2c bus will fail.
Steps to reproduce the issue
in
examples/default
:USEMODULE += i2c_scan
make BOARD=same54-xpro flash
i2c_scan 0
Expected results
Actual results
the program hangs indefinitely in an
-EAGAIN
loop.Versions
RIOT master