Hardware manual

Common Features Description
Atmel 8051 Microcontrollers Hardware Manual 2-63
4316A–8051–01/04
2.16.1 How Interrupts Are
Handled
The interrupt flags are sampled at SsP2 of every machine cycle. The samples are
polled during the following machine cycle. If one of the flags was in a set condition at
S5P2 of the preceding cycle, the polling cycle will find it and the interrupt system will
generate an LCALL to the appropriate service routine, provided this hardware-
generated LCALL is not clocked by any of the following conditions:
1. An interrupt of equal or higher priority level is already in progress.
2. The current (polling) cycle is not the final cycle in the execution of the instruction
in progress.
3. The instruction in progress is RETI or any access to the IE or IP registers.
The polling cycle is repeated with each machine cycle, and the values polled are the
values that were present at S5P2 of the previous machine cycle. Note then that if an
interrupt flag is active but not being responded to for one of the above conditions, if the
flag is not still active when the blocking condition is removed, the denied interrupt will
not be serviced. In other words, the facts that the interrupt flag was once active but not
serviced is not remembered. Every polling cycle is new.
The polling cycle/LCALL sequence is illustrated in Figure 2-28.
Note that if an interrupt of higher priority level goes active prior to S5P2 of the machine
cycle labeled C3 in Figure 2-28, then in accordance with the above rules it will be
vectored to during CS and C6, without any instruction of the lower priority routine
having been executed.
Figure 2-28. Interrupt Response Timing Diagram
Thus the processor acknowledges an interrupt request by executing a hardware
generated LCALL to the appropriate servicing routine.
In some cases it also clears the flag that generated the interrupt, and in other cases it
doesn’t. It never clears the Serial Port or Timers 2 flags. This has to be done in the
user’s software. It clears an external interrupt flag (IEO or IE1) only if it was transition-
activated.