Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix I2C timing. #69

Merged
merged 1 commit into from
Sep 5, 2021
Merged

Fix I2C timing. #69

merged 1 commit into from
Sep 5, 2021

Conversation

mgottschlag
Copy link
Contributor

While stealing this code for stm32g4xx-hal, I noticed that the I2C timing was WAY off.

The std::max() meant that scll was always set to 255, resulting in bit
rates that were far too slow. Also, the documentation states that the
clock is divided by PRESC+1, not by 2^(PRESC+1).

This code is untested, I do not have any STM32G0xx MCU. I only tested the effects of this patch on a system with an STM32G4xx MCU, where it results in the correct bit rate. AFAICS, the peripherals are identical.

The std::max() meant that scll was always set to 255, resulting in bit
rates that were far too slow. Also, the documentation states that the
clock is divided by PRESC+1, not by 2^(PRESC+1).
@andresv
Copy link
Member

andresv commented Aug 30, 2021

Thanks for the PR. I try to verify it with some G0 board.

@dotcypress
Copy link
Member

Verified!
Thank you @mgottschlag

@dotcypress dotcypress merged commit fb9c629 into stm32-rs:main Sep 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants