void uEnable_Interrupt(
void);
This function is called in order to enable all processor interrupts. Typically it is used in conjunction with the function
uEnable_Interrupt(), which protects a region of code so
that it will not be interrupted by interrupts which could otherwise be dangerous for integrity of its operation; for example when a flag or variable is changed that could also be accessed
by an interrupt routine or a sub-routine from it.
The routine also maintains a counter of the amount of times that it is called in a nested manner. This is then used to ensure that the interrupt is not enabled again
before the area defined by the outer nest has completed. This counter is also incremented by hardware interrupts on entry and decremented on exit so that any sub-routines
that calls
uDisable_Interrupt() don't cause interrupt to be re-enabled before the hardware interrupt has completed.
Generally the region of code protected by calling
uDisable_Interrupt() before calling
uEnable_Interrupt() should be as short as possible to avoid interrupt handling
to be delayed for unnecessary amounts of time, which could otherwise lead to overruns at peripheral receivers and other undesirable effects
Note that the µTasker simulator monitors the calls of
uDisable_Interrupt() and its counterpart
uEnable_Interrupt() and will cause an exception if it is found
that
uEnable_Interrupt() is used without a corresponding
uDisable_Interrupt() call.
Example
This example shows
uDisable_Interrupt() being used to protect a count value while it is being incremented.
The same count value could otherwise be decremented by a call from an interrupt routine, causing potential data corruption.
At the end of the critical region a call of
uEnable_Interrupt() allows interrupts to occur again.
uDisable_Interrupt();
ptQUEQue->chars += nr_of_bytes; // the number of bytes valid in the buffer after the copy
uEnable_Interrupt();
Related functions
uDisable_Interrupt();
Please use the
µTasker forum to ask specific questions.