cancel
Showing results for 
Search instead for 
Did you mean: 

Can an interrupt be triggered when the flag bit is set and then the interrupt enable bit is set?

14545714
Associate II
Posted on May 29, 2015 at 11:45

STM32L051xx: 

I am using the interrupt mode for UART2 Rx. Normally the interrupt is enabled at the beginning, so that Rx interrupt could be triggered once a new byte is received.

However sometimes in the program I need to disable the interrupt, do something and enable it again, like the following:

  HAL_NVIC_DisableIRQ(USART2_IRQn);

  

  //do something where UART interrupt should be avoided, for example when you modify some global variables that are also used in the interrupt IRQ handler.

  //the execution time is very short.

  

  HAL_NVIC_EnableIRQ(USART2_IRQn);

  

  So it is possible a new byte arrives and RXNE bit is set when the interrupt is disabled, and the interrupt will not be triggered. Will it be triggered immediately again just after the interrupt is enabled again? If not, the new byte will be lost and even an overrun error will happen.

  

  Thanks
2 REPLIES 2
Posted on May 29, 2015 at 14:35

Would expect so.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
14545714
Associate II
Posted on May 29, 2015 at 17:13

Hi, clive1,

What do you mean by ''Would expect so''? Thanks