Author Topic: STM32L452 - Same timer for varying frequency PWM and fixed frequency interrupt  (Read 355 times)

0 Members and 2 Guests are viewing this topic.

Offline ricko_ukTopic starter

  • Super Contributor
  • ***
  • Posts: 1070
  • Country: gb
Hi,

I am using a STM32L452 (without any RTOS) and I would like to use the same timer for both of the following:

- drive a sounder on a fixed 4KHz PWM frequency but ideally also other frequencies (which I dynamically set at runtime) above and below 1ms time period so it can make more elaborate sounds which

- also generate a 1ms interrupt to control flashing of LEDs and do other quick and simple tasks

Obviously I can set the timer interrupt to twice the highest sound frequency I want to generate and drive the sounder through a PWM I generate by toggling the buzzer pin in the int routine.

But I was wondering if there are more elegant ways especially to drive the buzzer with the PWM...? Perhaps the STM32L4 family has some nice features that I did not come across when reading the manual?

Thank you as always :slightly_smiling_face:
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf