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-27 12:08 PM
Read out and check/post content of TIM and relevant GPIO registers.
Make sure PB10 is connected to the header where you observe it, that there are no disconnected jumpers or solder bridges, and that there is no onboard resource connected to this pin - check this in the Nucleo's manual.
Try to set PB10 to GPIO and toggle it in a loop, with a delay. Even better, try to toggle it "manually" from debugger.
JW
2021-06-27 12:08 PM
Read out and check/post content of TIM and relevant GPIO registers.
Make sure PB10 is connected to the header where you observe it, that there are no disconnected jumpers or solder bridges, and that there is no onboard resource connected to this pin - check this in the Nucleo's manual.
Try to set PB10 to GPIO and toggle it in a loop, with a delay. Even better, try to toggle it "manually" from debugger.
JW
2021-06-27 08:24 PM
I checked it with toggling PB10 ,It was working fine. But for some reason PWM blink code is note working. I also tried debugging it and the the PWM timer was kept in if condition to check it with HAL_OK, and it was without any error.
if(HAL_TIM_PWM_Start(&htim2,HAL_TIM_ACTIVE_CHANNEL_3 )!=HAL_OK){
Error_Handler();
}
2021-06-28 03:37 AM
Read out and check/post content of TIM and relevant GPIO registers.
JW
2021-06-28 04:05 AM
ST videos sometimes feel more like a powerpoint sales pitch than hands-on engineering learning material.
Try this video https://www.youtube.com/watch?v=rM7QonHkh2w&feature=emb_title
2021-06-28 06:58 AM
2021-06-28 07:19 AM
The timer registers seemed to be configured fine ,but the GPIOB10 ODR register is not toggling.
2021-06-28 07:35 AM
This is the GPIOB register status.
2021-06-28 08:15 AM
TIM2_CR1.CEN=0, i.e. timer is not enabled, it is not running. You should also see TIM2_CNT changing, when you read in the TIM2 values repeatedly.
Also, TIM2_CCER=0, i.e. no output is enabled. But maybe because you stopped execution before calling the Cube/HAL function which would set it.
GPIO_ODR is irrelevant here; you want to have a look at GPIO_MODER and GPIO_AFR.
[EDIT] After reloading the thread I see that you've posted all GPIOB registers - MODER and AFR for PB10 look OK there.
JW
2021-06-29 03:12 AM
I checked it and the timer is enabled and its also counting, but there is some problem with the GPIOB configuration I guess.