I’m using an STM32L452RET (no RTOS) and would like to use the same timer (timer 2) for two purposes:
What would be the best way to do that?
I tried setting the PWM to 1ms for the interrupt to check other tasks and drive the buzzer pin directly (instead of the PWM peripheral) but then it would not create frequencies higher than 500Hz for the buzzer.
Thank you. 😊
The ARM Cortex-M4 CPU inside your STM32 MCU has a Systick timer which is specifically designed for generating periodic interrupts at a fixed frequency, or for other timing-related purposes. This would be perfect for your 1ms tick.
Then you could use the other timer for your PWM signal, and vary its frequency, duty cycle, or whatever, as you see fit, without disturbing the 1ms tick.