2021-06-27 11:55 AM
I have followed the ST tutorial on how to genterate a 1Hz PWM using timer, but for some reason its not blinking.
I configured:
1)Clock configuration to 8Mhz
2)Set PWM genration channel 3
3)Set prescaler to 127
4)Set ARR to 62499
5)Selected PWM mode 1 and made the pulse value to 31250
6)Finally I set the PINB10 to tim2_ch3 and connected it to an LED in a breadboard
In the main.c I have this HAL function to start the PWM
HAL_TIM_PWM_Start(&htim2,HAL_TIM_ACTIVE_CHANNEL_3 );
Please help ,I have been with this for some time now. But still I am not getting the output.
Solved! Go to Solution.
2021-06-29 03:15 AM
In CCMR2, you have set CH3 for output compare, but in CCER you have set the enable bit for CH2.
JW
2021-06-29 09:10 AM
Thanks for your help.The issue was a bug in HAL function :
HAL_TIM_PWM_Start(&htim2,HAL_TIM_ACTIVE_CHANNEL_4 )
When I gave HAL_TIM_ACTIVE_CHANNEL_4 its taken as channel 3 and giving the correct output.
2021-06-29 09:15 AM
I don't use Cube/CubeMX, but it appears that you are supposed to use TIM_CHANNEL_3 as a parameter there https://github.com/STMicroelectronics/STM32CubeL4/blob/5e1553e07706491bd11f4edd304e093b6e4b83a4/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim.c#L1420
JW
2021-06-29 10:39 AM
I used TIM_CHANNEL_3 , then Channel 2 was enabling. Then I changed to TIM_CHANNEL_4.
2021-06-29 11:25 AM
> I used TIM_CHANNEL_3 , then Channel 2 was enabling. Then I changed to TIM_CHANNEL_4.
No. You were using HAL_TIM_ACTIVE_CHANNEL_3 and then you've change it to HAL_TIM_ACTIVE_CHANNEL_4 . Those are different constants than TIM_CHANNEL_3 and TIM_CHANNEL_4.
JW
2021-06-29 08:01 PM
You are right. When I use TIM_CHANNEL_3 its working.
Thanks for your help.