stm32-rs / stm32l4xx-hal

A Hardware abstraction layer for the stm32l432xx series chips written in rust.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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:

  1. When we configured I2C1 with a frequency of 400.khz(), the resulting I2C clock frequency (as measured with oscilloscope) was 500 khz.

  2. 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.