I2C speed at 320 kHz instead of 400 kHz on the STM32F411 #14267
-
Hi,
When testing this with the SoftI2C it shows 500 kHz (!?) but I prefer the hardware I2C.
PS: Is there any difference between the I2C of the pyb module and the one from the machine module? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
If you look into the data sheet and the way, the I2C hardware is set up, it's clear that 400k cannot be achieved. The I2C device clock is 24MHz. According to the data sheet, getting to 400KHz requires a multiple of 10 MHz for the I2C clock. You could get that by changing the clock configuration of the device, e.g. by setting the clock to 80Mhz or trying 100Mhz. You have to change the value of: |
Beta Was this translation helpful? Give feedback.
If you look into the data sheet and the way, the I2C hardware is set up, it's clear that 400k cannot be achieved. The I2C device clock is 24MHz. According to the data sheet, getting to 400KHz requires a multiple of 10 MHz for the I2C clock. You could get that by changing the clock configuration of the device, e.g. by setting the clock to 80Mhz or trying 100Mhz. You have to change the value of:
#define MICROPY_HW_CLK_PLLN (192)
in mpconfigboard.h to either 160 for 80Mhz clock or 200 for a 100MHz clock. The latter is out of the spec, but could work.
Note that the actual clock at the bus depends as well from the rise time of the clock signal, determined by the time constant of all R's and C'…