Skip to main content
14545714
Associate II
May 29, 2015
Question

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

  • May 29, 2015
  • 2 replies
  • 753 views
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
    This topic has been closed for replies.

    2 replies

    Tesla DeLorean
    Guru
    May 29, 2015
    Posted on May 29, 2015 at 14:35

    Would expect so.

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

    Hi, clive1,

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