ENTER_CRITICAL_SECTION() : behavior of __disable_irq()
Hello, I'm new to STM world, so I'll post what may seem a trivial question to many, but which is not totally clear to me:
I'd like to understand better the behavior of the micro controller in a situation like:
/* Configure ISR on UART RX */
/* Enter Critial Section */
uint32_t primask_bit = __get_PRIMASK( );
__disable_irq( );
/* Do stuff */
/* !!! ISR occurring on UART RX !!! */
/* Do other stuff */
/* Exit Critial Section */
__set_PRIMASK( primask_bit )Is the ISR totally ignored by the micro controller or the IRQ associated to the ISR is executed right after line 12?
I understand that __disable_irq() works on the I-bit of the CPSR register, which disables IRQ interrupts globally, so my guess is that the NVIC may take trace of the ISR occurrence until the core has re-enabled the I-bit of CPSR register (line 12).
Is this a correct interpretation or is it misleading?
Also in case the IRQ of UART ISR is responsible of re-configuring the interrupt enable bit in UART registers, is it possible that in the previous scenario:
1. The ISR occurs during the CRITICAL SECTION
2. IRQ is not executed, so the IE flag has been cleared by HW due to the ISR occurrance, but it has not been set by the IRQ.
3. ISR cannot occur anymore.
Thank you for the support.
