I am setting the I2C frequency on the Compute Module 4 (running Ubuntu 22.04.2 LTS) with dtparam=i2c_arm=on,i2c_arm_baudrate=400000. The I2C bus has two parallel 10kOhm pullup (to 3.3V) resistors per line.
I've noticed that regardless of the speed I set it at, the actual measured clock frequency is significantly slower, roughly 33% slower. I've attached some screenshots from the oscilloscope used, and will list some of the measurements I found below:
Setting (kHz) | Measured (kHz)
10 | 4.66
50 | 26.7
100 | 66.8
200 | 134
300 | 200
400 | 292
I'm not sure why there is this large discrepancy, any ideas on what might be causing (or fix) this would be great! Not sure whether this is an issue in software, hardware, or something else.
I've heard of clock stretching being used by peripheral devices at high I2C speeds, but as I see this still happening at slower speeds (10kHz to 100kHz), I don't believe that's the cause of the discrepancy.
Screenshots below are in the same order as listed above. Measurements were taken by reading the difference in time (delta x) between the two cursors shown as vertical purple dotted lines. The measured delta x and equivalent frequency is shown in the grey box on the middle right (the oscilloscope traces are there but very faint, trace period is shown top left next to the M).
Below is a screenshot of multiple bytes being sent at 400kHz frequency setting. The cursors measure the period of 8 bits, which roughly corresponds with 33% slower (33.56kHz * 8 = 268kHz).
config.txt
?