cancel
Showing results for 
Search instead for 
Did you mean: 

Enable PWM Output Channel with HAL like formally done with LL_TIM_CC_EnableChannel

SThie.1
Associate II

I have an older code where I use TIM1 in PWM2 mode to generate a frequency for a buzzer connected to the OC Channel4. Code is coming from F051 project.

Now I started a new project and wanted to reuse the same principal, but i do not see the function to turn on an off the Output pin to get either low, or a the PWM signal on the output.

I was using LL_TIM_CC_EnableChannel (TIM3,LL_TIM_CHANNEL_CH4);

I found TIM_CCxNChannelCmd(&htim1, Channel, TIM_CCxN_ENABLE) in the HAL but this is static, so not intended to be used by my code.

What is the equivalent function for LL_TIM_CC_EnableChannel in the HAL ?

1 REPLY 1
Sarra.S
ST Employee

Hello @SThie.1

You are right, the equivalent function is achieved through a combination of HAL functions

To configure the timer and the channel in PWM mode: HAL_TIM_PWM_ConfigChannel

To start the PWM output: HAL_TIM_PWM_Start or HAL_TIM_PWM_Start_IT for interrupt-driven operation

To stop the PWM output: HAL_TIM_PWM_Stop or HAL_TIM_PWM_Stop_IT

Hope that helps! 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.