F4_HAL/i2c: Fix I2C frequency is faster than specified one. #22
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes following issue.
The actual I2C frequency is faster than specified one and it may exceededs I2C's specification for Fast mode.
Also, pyb.I2C initialize with baudrate=400000 (I2C Fast mode) by default but actual frequency of SCL is faster than 400KHz.
The frequency of SCL should be less than or equal to 400KHz in Fast mode.
How to reproduce
Execute this code
MicroPython Version
v1.19.1
Environment
NUCLEO-F446RE
Detail of changes
I2C is initialized by
https://github.com/micropython/micropython/blob/0e8c2204da377e95b5000a3c708891d98cdeb69c/ports/stm32/pyb_i2c.c#L254-L257
but I think current stm32lib has a bug that the frequency is faster than specified one.
This bug is fixed at least v1.24.1 but I couldn't find a release note about this fix.
I backport it from v1.27.1.
After applying this PR, the frequency of SCL is less than 400KHz.