AnsweredAssumed Answered

Masking unwanted callbacks

Question asked by Matthew Force on May 24, 2018

The following is CubeMX generated code (STM32L051) for TIM interrupts.  I am interested in the capture callback from a different TIM channel configured for IC but I am also getting OC_Delay and PWM_PulseFinished callbacks firing.  Without modifying the auto-generated code, how do I disable the TIM interrupts I do not want while still enabling the one I do?

 

void HAL_TIM_IRQHandler(TIM_HandleTypeDef *htim)
{
...
if(__HAL_TIM_GET_FLAG(htim, TIM_FLAG_CC2) != RESET)
{
if(__HAL_TIM_GET_IT_SOURCE(htim, TIM_IT_CC2) !=RESET)
{
__HAL_TIM_CLEAR_IT(htim, TIM_IT_CC2);
htim->Channel = HAL_TIM_ACTIVE_CHANNEL_2;
/* Input capture event */
if((htim->Instance->CCMR1 & TIM_CCMR1_CC2S) != 0x00U)
{
HAL_TIM_IC_CaptureCallback(htim);
}
/* Output compare event */
else
{
HAL_TIM_OC_DelayElapsedCallback(htim);
HAL_TIM_PWM_PulseFinishedCallback(htim);
}
htim->Channel = HAL_TIM_ACTIVE_CHANNEL_CLEARED;
}
}
...
}

Outcomes