cancel
Showing results for 
Search instead for 
Did you mean: 

Output Compare not set in HAL_TIM_PWM_PulseFinishedCallback

JGu
Associate

void HAL_TIM_PWM_PulseFinishedCallback(TIM_HandleTypeDef *htim)

{

if(htim->Instance == htim2.Instance && htim->Channel == HAL_TIM_ACTIVE_CHANNEL_1) {

HAL_TIM_PWM_Stop_DMA(&htim2, TIM_CHANNEL_1);

__HAL_TIM_SET_COUNTER(&htim2, 0);

__HAL_TIM_SET_COMPARE(&htim2, TIM_CHANNEL_2, 100);

HAL_TIM_OC_Start_IT(&htim2, TIM_CHANNEL_2);

}

}

The OC settings are all normal elsewhere. However, it is not set by the change of time set here. Very quickly it comes to HAL_TIM_OC_DelayElapsedCallback.

Even if the words are awkward, please understand. Google Translate.

1 ACCEPTED SOLUTION

Accepted Solutions

> Very quickly it comes to HAL_TIM_OC_DelayElapsedCallback.

Maybe the related flag (CC2IF) is already set in TIMx_SR. You might want to clear the TIMx_SR.CC2IF before you call HAL_TIM_OC_Start_IT().

JW

View solution in original post

2 REPLIES 2

> Very quickly it comes to HAL_TIM_OC_DelayElapsedCallback.

Maybe the related flag (CC2IF) is already set in TIMx_SR. You might want to clear the TIMx_SR.CC2IF before you call HAL_TIM_OC_Start_IT().

JW

__HAL_TIM_CLEAR_FLAG (& htim2, TIM_SR_CC2IF);

By inserting the above.

Thank you.