2021-12-02 11:10 AM
I've created a single pulse that executes for about 150ms. When it's complete I was expecting HAL_TIM_PWM_PulseFinishedCallback() to be called, however, it never is.
Doing this:
if (HAL_TIM_OnePulse_Start(&htim1, TIM_CHANNEL_1) != HAL_OK) {
/* Starting Error */
Error_Handler();
}
Then in the main while() loop when a certain condition is met:
__HAL_TIM_ENABLE(&htim1);
My oscilloscope shows the pulse occurs at the correct time for the correct duration.
Why wouldn't the callback execute?
Thanks,
Solved! Go to Solution.
2021-12-02 01:59 PM
HAL_TIM_OnePulse_Start() is a blocking function and doesn't use interrupts.
If you want a callback, you can use HAL_TIM_OnePulse_Start_IT() instead which will call HAL_TIM_PWM_PulseFinishedCallback in the HAL IRQ handler. The interrupt needs to be enabled prior to this call. CubeMX can generate the code and interrupt function handler for you.
2021-12-02 01:59 PM
HAL_TIM_OnePulse_Start() is a blocking function and doesn't use interrupts.
If you want a callback, you can use HAL_TIM_OnePulse_Start_IT() instead which will call HAL_TIM_PWM_PulseFinishedCallback in the HAL IRQ handler. The interrupt needs to be enabled prior to this call. CubeMX can generate the code and interrupt function handler for you.
2021-12-03 06:23 AM
Well, that makes perfect sense. Thanks for pointing that out.