I2C frequency calculation appears to be incorrect
datdenkikniet opened this issue · comments
When setting the I2C frequency using the I2c::i2cX
function, it appears that the resulting configuration actually gives a different frequency than the one that was provided as input.
These tests were performed with the following clock configuration:
rcc.cfgr.msi(MsiFreq::RANGE32M)
Two examples:
-
When we configured I2C1 with a frequency of
400.khz()
, the resulting I2C clock frequency (as measured with oscilloscope) was 500 khz. -
When we configured I2C1 with a frequency of
200.khz()
, the resulting I2C clock frequency (as measured with an oscilloscope) was 300 khz.
It would be good if the frequency calculation that is currently performed can be given a look, to ensure that it actually does what it's supposed to.
Hmm, upon second measurement it doesn't actually seem that this is the case. Unclear why we got those measurements to begin with.