Question
Generate a single interrupt on TIM3_IRQHandler() when CCR is reached instead of every rising pulse
Hi all.
I have a motor encoder connected to TIM3 and I'm trying to generate a single interrupt once
1848 ticks have been reached. However, TIM3_IRQHandler() keeps being triggered for every rising edge of the pulse. I just want a single interrupt triggered. once 1848 ticks have been reached. I could check for the CCR flag within the TIM3_IRQHandler(), however, the constant interrupting of TIM3_IRQHandler() will hinder my performance.
This is my initialising routine
uwPrescalerValue = 62640;
/* USER CODE END TIM3_Init 1 */
htim3.Instance = TIM3;
htim3.Init.Prescaler = uwPrescalerValue;
htim3.Init.CounterMode = TIM_COUNTERMODE_UP;
htim3.Init.Period = 1848 - 1;
htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim3.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
sConfig.ICPolarity = TIM_INPUTCHANNELPOLARITY_RISING;
sConfig.ICSelection = TIM_ICSELECTION_DIRECTTI;
sConfig.ICPrescaler = TIM_ICPSC_DIV8;
sConfig.ICFilter = 0;
HAL_TIM_IC_Init(&htim3);
if (HAL_TIM_IC_ConfigChannel(&htim3, &sConfig, TIM_CHANNEL_1) != HAL_OK)
{
Error_Handler();
}
HAL_TIM_IC_Start_IT(&htim3, TIM_CHANNEL_1);Any help would be great and some code examples please. Thanks
