cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_TIM_PWM_PulseFinishedCallback() not getting called

jgauthier
Senior

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,

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

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.

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

2 REPLIES 2
TDK
Guru

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.

If you feel a post has answered your question, please click "Accept as Solution".
jgauthier
Senior

Well, that makes perfect sense. Thanks for pointing that out.