In some very rare situations one can have to violate the interruptibility rule.
In this case, interruptions must be masked. In order to keep the code consistant with interruptions usage
you must use the following macro to manage interrupts (ie: never change the INTCON
enabling bits (GIE/GIEH/GIEL
) directly).
MASK_HI_PRI_IT
: disable high priority interrupts.
MASK_LO_PRI_IT
: disable low priority interrupts.
UNMASK_HI_PRI_IT
: enable high priority interrupts.
UNMASK_LO_PRI_IT
: enable low priority interrupts.
Before entering a critical (ie: non-interruptible) section, just uses the DISABLE_IT
macro : it will atomically
disable all interrupts.
When you leave the critical section, use the ENABLE_IT
macro : interrupts will be restored to the previous state, no matter they was enabled or not.
Of course, never change the interrupt status in a critical section, and never enter a critical section inside a critical section.
All these macros are defined in <interrupt.h> header.