![](http://datasheet.mmic.net.cn/360000/Z80B-CTC_datasheet_16678678/Z80B-CTC_102.png)
Z8 Microcontrollers
Interrupts
ZiLOG
7-12
UM001600-Z8X0599
7.6.2 Nesting of Vectored Interrupts
Nesting of vectored interrupts allows higher priority re-
quests to interrupt a lower priority request. To initiate vec-
tored interrupt nesting, do the following during the interrupt
service routine:
Push the old IMR on the stack.
Load IMR with a new mask to disable lower priority
interrupts.
Execute EI instruction.
Proceed with interrupt processing.
After processing is complete, execute DI instruction.
Restore the IMR to its original value by returning the
previous mask from the stack.
Execute IRET.
Depending on the application, some simplification of the
above procedure may be possible.
7.7 POLLED PROCESSING
Polled interrupt processing is supported by masking off the
IRQ to be polled. This is accomplished by clearing the cor-
responding bits in the IMR.
To enable any interrupt, first the interrupt mechanism must
be engaged with an EI instruction. If only polled interrupts
are to be serviced, execute:
EI ;Enable interrupt mechanism
DI ;Disable vectored interrupts.
To initiate polled processing, check the bits of interest in
the IRQ using the Test Under Mask (TM) instruction. If the
bit is set, call or branch to the service routine. The service
routine services the request, resets its Request Bit in the
IRQ, and branches or returns back to the main program.
An example of a polling routine is as follows:
In this example, if IRQ2 is being polled, MASKA will be
00000100B and MASKB will be 11111011B.
7.8 RESET CONDITIONS
Upon reset, all bits in IPR are undefined.
In IMR, bit 7 is 0 and bits 0-6 are undefined. The IRQ reg-
ister is reset and held in that state until an enable interrupt
(EI) instruction is executed.
TM IRQ, #MASKA
JR Z, NEXT
;Test for request
;If no request go to
NEXT
;If request is there, then
;service it
CALL SERVICE
NEXT:
.
.
.
SERVICE:
;Process Request
.
.
.
AND IRQ, #MASKB
RET
;Clear Request Bit
;Return to next