Skip to content

Set a PWM periodwith sub Hz granularity #477

@punkto

Description

@punkto

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions