Question
Why on STM32L053, TIMER22 generates an update, CC1 and CC2 event when counter is enabled?
I want generate an event when the timer counter is at CCR1 register or ARR register.
But when the counter is enabled, the timer generates all events.
Can you help me?
This is the init routine
void init_timeout_timer22()
{
RCC->APB2ENR = RCC->APB2ENR | 0x20; //TIM22 Clock enable
LL_TIM_SetCounterMode(TIMER_TIMEOUT, LL_TIM_COUNTERMODE_UP);
LL_TIM_SetClockDivision(TIMER_TIMEOUT, LL_TIM_CLOCKDIVISION_DIV1); //Clock 32MHz
LL_TIM_SetPrescaler(TIMER_TIMEOUT, 32000);
LL_TIM_SetAutoReload(TIMER_TIMEOUT, 8000);
LL_TIM_SetCounter(TIMER_TIMEOUT, 0x0000);
LL_TIM_DisableIT_UPDATE(TIMER_TIMEOUT);
LL_TIM_DisableIT_CC1(TIMER_TIMEOUT);
LL_TIM_DisableIT_CC2(TIMER_TIMEOUT);
}This is the routine that i call to set the limit and start counter
void enableToutI2cProtocolInt(int tout)
{
LL_TIM_DisableCounter(TIMER_TIMEOUT);
// Clear counter to make sure it starts from zero
LL_TIM_SetCounter(TIMER_TIMEOUT, 0);
LL_TIM_SetAutoReload(TIMER_TIMEOUT, tout);
//reset flag I2c timeout
startAlarmTimoutI2cIntProtocol();
// Configure ISR
LL_TIM_ClearFlag_CC1(TIMER_TIMEOUT);
LL_TIM_ClearFlag_UPDATE(TIMER_TIMEOUT);
LL_TIM_EnableIT_UPDATE(TIMER_TIMEOUT);
LL_TIM_EnableIT_CC1(TIMER_TIMEOUT);
LL_TIM_EnableCounter(TIMER_TIMEOUT);
NVIC_EnableIRQ(TIM22_IRQn);
}