DMA Interrupts
7-43
Program Flow Control
One solution is to use an instruction that is uninterruptible such as RPTS as
follows to set the GIE:
RPTS
0
AND
2000h, ST
; Set GIE=1
Use the following to reset the GIE:
RPTS
0
AND
0DFFFh, ST
; Set GIE=0
Another alternative incorporates the following code fragment, which protects
against modifying or saving the status register by disabling interrupts through
the interrupt-enable register:
PUSH IE
; Save IE register
•
Added instructions to
LDI
0, IE
; Clear IE register
avoid pipeline problems
NOP
;
•
2 NOPs or useful instructions
NOP
;
AND 0DFFFh,
ST ; Set GIE = 0
•
Instruction that reads or
POP IE
;
writes to ST register.
;
Added instruction
;
to avoid pipeline
;
problems.
In summary, the next three instructions immediately following an instruction
that clears the GIE bit might be interrupted. Also, the next three instructions
immediately following an instruction that sets the GIE bit might not be interrupted
even if there is a pending interrupt (see Example 7–15). Similarly, the next three
instructions immediately following an instruction that clears an interrupt-enable
mask might be interrupted. Furthermore, the next three instructions immediately
following an instruction that sets an interrupt flag might be executed before the
interrupt occurs.
Example 7–15. Pending Interrupt
LDI
0h, ST
; set GIE = 0
LDI
1h, R1
LDI
2h, R2
MPYI
*AR1, R0
; interrupts still enabled
ADDI *AR1,R1
; interrupts disabled here