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

Set a PWM periodwith sub Hz granularity #477

Open
punkto opened this issue Jan 21, 2024 · 1 comment
Open

Set a PWM periodwith sub Hz granularity #477

punkto opened this issue Jan 21, 2024 · 1 comment

Comments

@punkto
Copy link

punkto commented Jan 21, 2024

I'm trying to leverage a PWM from a Blue Pill to play some notes on a buzzer. I have done this before in C+libopencm3 by adjusting the prescaler and the autoreload registers directly to reach a frequency near the musical note (if you are curious, here is an example: https://github.com/themightyteam/bluepill-examples/tree/master/examples/buzzer_music ).

Now I would like to do the same using this HAL, but so far I can only play full Hertz and I don't see a way to update directly the registers (example here: https://github.com/aindustriosa/RustyBugA/blob/7-add-buzzer-to-the-bsc/mightybuga_bsc/examples/no_bsc_buzzer.rs ).

So my questions are:

  • Is this possible in a way I'm not aware of?
  • If not, Is this an update you will welcome to the HAL or consider it too low level?
  • If not, What would be the best way to implement it for my project? Use the PAC directly? Implement a new PWM trait?

Thanks in advance.

@TheZoq2
Copy link
Member

TheZoq2 commented Jan 22, 2024

This is probably closely related to #225 which has been open for a while.

Using the PAC directly would work for sure but is a bit annoying.

I'm not really involved in this repo much anymore so I can't directly comment on if we would want this in the HAL, but presumably we'd want it on the embedded-hal layer, not here for it to be done "properly".

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

No branches or pull requests

2 participants