-
Notifications
You must be signed in to change notification settings - Fork 2.1k
cpu/sam0_common: i2c baudrate calculation fails if CLOCK_CORECLOCK > 51 MHz #12037
Copy link
Copy link
Closed
Closed
Copy link
Labels
Area: driversArea: Device driversArea: Device driversType: bugThe issue reports a bug / The PR fixes a bug (including spelling errors)The issue reports a bug / The PR fixes a bug (including spelling errors)
Milestone
Description
Description
The I2C baudrate is always derived from CLOCK_CORECLOCK, even if a different .gclk_src is selected. If CLOCK_CORECLOCK is too high, the resulting baudrate will is too big and a check in i2c_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_scanmake BOARD=same54-xpro flash- run
i2c_scan 0
Expected results
2019-08-20 14:01:01,264 - INFO # > i2c_scan 0
2019-08-20 14:01:01,270 - INFO # Scanning I2C device 0...
2019-08-20 14:01:01,279 - INFO # addr not ack'ed = "-", addr ack'ed = "X", addr reserved = "R", error = "E"
2019-08-20 14:01:01,283 - INFO # 0 1 2 3 4 5 6 7 8 9 a b c d e f
2019-08-20 14:01:01,286 - INFO # 0x00 R R R R R R R R R R R R R R - -
2019-08-20 14:01:01,287 - INFO # 0x10 - - - - - - - - - - - - - - - -
2019-08-20 14:01:01,288 - INFO # 0x20 - - - - - - - - X - - - - - - -
2019-08-20 14:01:01,296 - INFO # 0x30 X - - - - - X - - - - - - - - -
2019-08-20 14:01:01,298 - INFO # 0x40 - - - - - - - - - - - - - - - -
2019-08-20 14:01:01,304 - INFO # 0x50 X - - - - - X - X - - - - - X -
2019-08-20 14:01:01,309 - INFO # 0x60 X - - - - - - - - - - - - - - -
2019-08-20 14:01:01,313 - INFO # 0x70 - - - - - - - - R R R R R R R R
Actual results
2019-08-20 13:56:22,893 - INFO # > i2c_scan 0
2019-08-20 13:56:22,895 - INFO # Scanning I2C device 0...
2019-08-20 13:56:22,901 - INFO # addr not ack'ed = "-", addr ack'ed = "X", addr reserved = "R", error = "E"
2019-08-20 13:56:22,906 - INFO # 0 1 2 3 4 5 6 7 8 9 a b c d e f
the program hangs indefinitely in an -EAGAIN loop.
Versions
RIOT master
Reactions are currently unavailable
Metadata
Metadata
Labels
Area: driversArea: Device driversArea: Device driversType: bugThe issue reports a bug / The PR fixes a bug (including spelling errors)The issue reports a bug / The PR fixes a bug (including spelling errors)