![Infineon Technologies XC2200 User Manual Download Page 222](http://html1.mh-extra.com/html/infineon-technologies/xc2200/xc2200_user-manual_2055439222.webp)
XC2200 Derivatives
System Units (Vol. 1 of 2)
Interrupt and Trap Functions
User’s Manual
5-10
V2.1, 2008-08
ICU_X2K, V2.2
Please note that the sequence above blindly controls the global enable flag. If the global
setting must not be changed, the code sequence can be enhanced, as shown below:
JNB IEN, GlobalIntOff
BCLR IEN ;Globally disable interrupts
BCLR T2IE ;Disable Timer 2 interrupt node
JNB T2IE, Next ;Any instruction reading T2IC can be used
Next: ;(assures that T2IC is written by BCLR
;before being read by JNB or other instr.)
BSET IEN ;Globally enable interrupts again
JMPR cc_uc, Continue
GlobalIntOff: ;Interrupts are globally disabled anyway
BCLR T2IE ;Disable Timer 2 interrupt node
JNB T2IE, Continue ;Reading T2IC can be omitted if the next
Continue: ;few instructions do not set IEN
...
The same function can easily be implemented as a C macro:
#define Disable_One_Interrupt(IE_bit) \\
{if(IEN) {IEN=0; IE_bit=0; while (IE_bit); IEN=1;} else
{IE_bit=0; while IE_bit);}}
Usage Example:
Disable_One_Interrupt(T2IE) ; // T2 interrupt enable flag
ATOMIC or EXTend sequences preserve the status of the interrupt arbitration when they
begin. An accepted request is processed after the ATOMIC/EXTend sequence.
Therefore, the following code sequence may not produce the desired result:
AvoidThis:
ATOMIC #3
BCLR T2IE ;Disable Timer 2 interrupt node
NOP
NOP ;Timer 2 request may be processed
;after this instruction!!!