2024-05-10 2:25 AM
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 ?
2024-05-13 1:52 AM
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.
We’re moving the ST Community to a new platform to give you a better and more reliable community experience.