
Interrupts
7-17
Program Flow Control
7.4.2
CPU Interrupt Control Bits
Three CPU registers contain bits used to control CPU interrupt operation:
The CPU status register (ST).
The CPU global interrupt enable bit (GIE),
located in the ST, controls all maskable CPU interrupts. When this bit is
set to 1, CPU interrupts are globally enabled. When this bit is cleared to
0, all CPU interrupts are disabled (except NMI, the nonmaskable inter-
rupt). Refer to subsection 3.1.7, Status Register (ST) on page 3-5.
Internal interrupt enable register (IIE).
The IIE is used to enable CPU
internally-generated interrupts (from timers, communication ports, and
DMA channels). See subsection 3.1.9, CPU Internal Interrupt Enable
Register (IIE) on page 3-11, for more information.
IIOF flag register (IIF).
The IIF contains interrupt flag bits and bits to deter-
mine the function of the external-interrupt pins (IIOF0 – IIOF3).
The IIF Register
When an external interrupt or most of the internal interrupts are received, a
corresponding bit in the IIF register is set to 1. The only internally generated
interrupts that do not have a flag bit in the IIF register are the communication
port interrupts.
When the CPU services an interrupt that has an interrupt flag bit in the IIF regis-
ter, or when the DMA controller latches this type of interrupt into a DMA internal
signal, this flag bit is cleared by the internal interrupt acknowledge signal. How-
ever, for level-triggered interrupts, if IIOFn is still low when the interrupt ac-
knowledge signal occurs, the interrupt flag bit is cleared for only one cycle and
then set to 1 again. For this reason, it is theoretically possible that, depending
on when the IIF register is read, the interrupt flag bit may be zero, even though
IIOFn is low. After reset, zero is written to the interrupt flag register, thereby
clearing all pending interrupts.
The IIF register bits can be read or written under software control. This pro-
vides access to the IIOFx pins, which can be treated as general-purpose I/O
or as interrupt pins. For example, if at the IIF register, FUNCx = 0 (I/O pin) and
TYPEx = 1 (output pin), then by writing into the FLAGx bit, you can also write
to the external pin IIOFx. If FUNCx = 1 (interrupt pin), writing a 1 to the IIF regis-
ter FLAGx bit has the same effect as an incoming interrupt received on the cor-
responding pin. In this way, all interrupts can be triggered and/or cleared
through software. Since the interrupt bits also can be read, the interrupt pins
can be polled in software when an interrupt-driven interface is not required.