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

stm32/usart: Changing baud rate #1289

Open
ra1u opened this issue Mar 20, 2023 · 2 comments
Open

stm32/usart: Changing baud rate #1289

ra1u opened this issue Mar 20, 2023 · 2 comments
Labels
e-stm32 help wanted Extra attention is needed kind-feature New feature or request

Comments

@ra1u
Copy link

ra1u commented Mar 20, 2023

I would like to change uart baud at runtime.

Code seems to be in usart::configure and one needs to write appropriate value into brr reg

However I can not figure out how to access relevant initialisation values T::MULTIPLIER and T::frequency() because they are behind sealed (aka private) interface. Values are needed to calculate appropriate value for brr divisor .

Question is, how do I change brr register, accordingly.
Only idea I have so far is to set value relative to current value. So if baud needs to go from 57600 to 115200 one can divide current brr reg by 2,

Is there anything better?

@Dirbaio
Copy link
Member

Dirbaio commented Mar 20, 2023

it's not implemented yet. The inner guts are intentionally not public, you're not supposed to touch registers directly if using the HAL. The fix would be to add a public .set_baudrate() method.

@Dirbaio Dirbaio added kind-feature New feature or request help wanted Extra attention is needed e-stm32 labels Mar 20, 2023
@Dirbaio Dirbaio changed the title Changing baud on uart stm32 stm32/usart: Changing baud rate May 12, 2023
@EnmanuelParache
Copy link

Just opened #3512 adding .set_baudrate() method as mentioned above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
e-stm32 help wanted Extra attention is needed kind-feature New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants