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

nucleo-l432kc, nucleo-l031k6, nucleo-f722ze seemingly lack the ability to change I2C frequency #2311

Closed
rayozzie opened this issue Nov 24, 2021 · 5 comments
Labels
enhancement New feature or request stm32

Comments

@rayozzie
Copy link

For both of these boards there are consts for TWI_FREQ, however the I2CConfig type has no Frequency field and thus it is not apparent how to configure bus speed for I2C.

https://tinygo.org/docs/reference/microcontrollers/machine/nucleo-l432kc/
https://tinygo.org/docs/reference/microcontrollers/machine/nucleo-l031k6/
https://tinygo.org/docs/reference/microcontrollers/machine/nucleo-f722ze

Thank you for your consideration of this fix/enhancement.

@deadprogram deadprogram added enhancement New feature or request stm32 labels Nov 24, 2021
@deadprogram
Copy link
Member

@kenbell I was looking at this briefly, and saw that we are using some constant values based on clock speed generated by STM32CubeMX. We could keep doing this as an interim solution if we can also generate those 4 values for the typical standard and fast mode speeds for each of the boards this is currently being used for.

I was looking at STM32CubeMX but it was not immediately obvious how to regenerate those values. Could you show me how you did that and/or help out to generate values for the various getFreqRange() functions?

@kenbell
Copy link
Member

kenbell commented May 6, 2024

@deadprogram you first have to set the peripheral clock to the correct MHz in the 'Clock Configuration' tab. For L432, it's this (80MHz on PCLK1):
image

Resolve the clock configuration.

Then enable I2C1 peripheral, you'll now see in gray the magic value in the 'timing' setting (0x10909CEC in this case for 100kHz standard mode):
image

@deadprogram
Copy link
Member

Thanks @kenbell that is exactly what I was looking for. PR coming later.

@deadprogram
Copy link
Member

Merged into dev, tagged to close on next release. Thanks @rayozzie for report and to @kenbell for helping me out.

@deadprogram
Copy link
Member

This was released with v0.32.0 so now closing. Thank you everyone!

@deadprogram deadprogram removed the next-release Will be part of next release label Jun 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request stm32
Projects
None yet
Development

No branches or pull requests

3 participants