2020-07-24 01:55 AM
Hello everyone,
I would like to know how to configure Timer1 to run at a certain frequency, but the interrupt will only generate a certain number of pulses (determined by the repetition counter).
I am using STM32CubeIDE and nucleo-l476rg. I tried to do this, but the HAL_TIM_PWM_PulseFinishedCallback interrupt is still generated every pulse.
I will be grateful if someone tells me how to configure it in CubeMX and which interrupts to use in my code.
Best regards,
Grzegorz
Solved! Go to Solution.
2020-07-24 05:05 AM
Got it :) I used wrong HAL functions. Instead of using the HAL_TIM_Base_Start_IT and HAL_TIM_PeriodElapsedCallback functions, I used HAL_TIMEx_PWMN_Start_IT and HAL_TIM_PWM_PulseFinishedCallback. Now everything works correct.
Thanks for your reply JW :)
2020-07-24 02:10 AM
I don't know about CubeMX, but you simply set the repetition count to TIMx_RCR register and then the Update interrupt will happen only every N overflows of the timer.
JW
2020-07-24 02:42 AM
I set the RCR register to the desired value, but the interrupt keeps getting generated every pulse. The only difference I can see is that PWM generation will stop after a certain number of periods (equal to the number of RCs) when I set the timer in One Pulse Mode.
GS
2020-07-24 05:05 AM
Got it :) I used wrong HAL functions. Instead of using the HAL_TIM_Base_Start_IT and HAL_TIM_PeriodElapsedCallback functions, I used HAL_TIMEx_PWMN_Start_IT and HAL_TIM_PWM_PulseFinishedCallback. Now everything works correct.
Thanks for your reply JW :)