AnsweredAssumed Answered

Disabling IRQ causes irq routine to be called

Question asked by JulienD on Oct 4, 2016
Latest reply on Oct 5, 2016 by JulienD

I found something curious (for me...) while playing around usart interrupts on STM32L1

// USART1 is initialized and IRQ is enabled
// TC is 1
// TCIE is 0
__HAL_UART_ENABLE_IT(&huart1, UART_IT_TC);    -- > none interrupt routine is called
HAL_NVIC_DisableIRQ(USART1_IRQn);             --->  USART1_IRQHandler is called

After standard initialization of usart1 with cubeMx (containing a call to
HAL_NVIC_EnableIRQ(USART1_IRQn);                      ).

TC flag is 1 and TCIE flag is 0. So none interrupt is called. Now here's the point:
When I call


none interrupt routine is called while I think it should because TC is 1.

Then, when I call

HAL_NVIC_DisableIRQ(USART1_IRQn);                      --->  USART1_IRQHandler is called

USART1_IRQHandler is called while I think it should not.

Is it a regular behaviour? If yes, is there a reason?