Skip to main content
Explorer II
May 10, 2024
Question

Enable PWM Output Channel with HAL like formally done with LL_TIM_CC_EnableChannel

  • May 10, 2024
  • 1 reply
  • 1669 views

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 ?

    This topic has been closed for replies.

    1 reply

    ST Employee
    May 13, 2024

    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!