cancel
Showing results for 
Search instead for 
Did you mean: 

PWM in Interrupt

venkateswarlu
Associate II

how to use PWM timer1 in Interrupt mode

1 REPLY 1
Imen.D
ST Employee

Hello @venkateswarlu and welcome to the Community 🙂

You can start from STM32CubeMX to configure the peripherals and generate the code.

So, you need to configure the timer, the Clocks, the PWM channel, and the interrupt.

ImenD_0-1712043867278.png

 

You can start the PWM output in interrupt mode using HAL_TIM_PWM_Start_IT(&htim1, TIM_CHANNEL_1);
Then, implement the Interrupt Handler using HAL_TIM_IRQHandler(&htim1);

Make sure to enable GPIOx and TIMx clock in RCC and set correctly the interrupt priority.

Please refer to these resources for more info on the STM32 Timers:

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen