HAL - Why is the PWM pulse callback not triggering?
Hi there,
I would like to execute some code in an interrupt handler when the pulse value for TIM16 is reached. But for some reason, none of the interrupts provided by HAL seem to trigger for this event.
I have setup the timer using the configuration tool with the following:
(TIM 16 running off an 8MHz clock)
CH 1 - PWM Generation CH1
Prescaler - 799
ARR - 9999
Mode - PWM mode 1
Pulse - 2499
I assigned pin PB8 to produce the PWM signal.
To start the timer I have made the call:
/* USER CODE BEGIN 2 */
HAL_TIM_PWM_Start_IT(&htim16, TIM_CHANNEL_1);
/* USER CODE END 2 */I am using a scope to check that indeed there is a PWM signal on PB8 with a duty cycle of 25% and a period of 1s. As expected.
I have placed LED toggling code inside the following interrupts:
HAL_TIM_PeriodElapsedCallback
HAL_TIM_PeriodElapsedHalfCpltCallback
HAL_TIM_OC_DelayElapsedCallback
HAL_TIM_PWM_PulseFinishedCallback
HAL_TIM_PWM_PulseFinishedHalfCpltCallback
HAL_TIM_TriggerCallback
HAL_TIM_TriggerHalfCpltCallback
HAL_TIM_ErrorCallback
As I expected, the LED being toggled by HAL_TIM_PWM_PulseFinishedCallback is changing state every second.
The only other LED that is toggling is the one belonging to HAL_TIM_OC_DelayElapsedCallback. Evidently, all the other interrupts are not being called.
I would expect that "HAL_TIM_PWM_PulseFinishedHalfCpltCallback" would be called when the pulse value is reached in the CNT register of tim16, but this does not seem to be happening.
What is the "HAL_TIM_PWM_PulseFinishedHalfCpltCallback" used for? And if it is not to indicate when the pulse value is reached, then what callback can I use for this purpose?
Thanks in advance!
P.S. Here is a TIM16 register dump

