MOTOROLA
7-4
GENERAL-PURPOSE TIMER
MC68331
USER’S MANUAL
7
7.3.4 Test Mode
Test mode is used during Motorola factory testing. The GPT has no dedicated test-
mode control register; all GPT testing is done under control of the system integration
module.
7.4 Polled and Interrupt-Driven Operation
Normal GPT function can be polled or interrupt-driven. All GPT functions have an as-
sociated status flag and an associated interrupt. The timer interrupt flag registers
(TFLG1 and TFLG2) contain status flags used for polled and interrupt-driven opera-
tion. The timer mask registers (TMSK1 and TMSK2) contain interrupt control bits. Con-
trol routines can monitor GPT operation by polling the status registers. When an event
occurs, the control routine transfers control to a service routine that handles that event.
If interrupts are enabled for an event, the GPT requests interrupt service when the
event occurs. Using interrupts does not require continuously polling the status flags to
see if an event has taken place. However, status flags must be cleared after an inter-
rupt is serviced, in order to disable the interrupt request.
7.4.1 Polled Operation
When an event occurs in the GPT, that event sets a status flag in TFLG1 or TFLG2.
The GPT sets the flags; they cannot be set by the CPU. TFLG1 and TFLG2 are 8-bit
registers that can be accessed individually or as one 16-bit register. The registers are
initialized to zero at reset.
Table 7-1
shows status flag assignment.
For each bit in TFLG1 and TFLG2 there is a corresponding bit in TMSK1 and TMSK2
in the same bit position. If a mask bit is set and an associated event occurs, a hardware
interrupt request is generated.
To re-enable a status flag after an event occurs, the status flags must be cleared. Sta-
tus registers are cleared in a particular sequence. The register must first be read for
set flags, then zeros must be written to the flags that are to be cleared. If a new event
occurs between the time that the register is read and the time that it is written, the as-
sociated flag is not cleared.
Table 7-1 GPT Status Flags
Flag
Mnemonic
IC1F
IC2F
IC3F
OC1F
OC2F
OC3F
OC4F
I4/O5F
TOF
PAOVF
PAIF
Register
Assignment
TFLG1
TFLG1
TFLG1
TFLG1
TFLG1
TFLG1
TFLG1
TFLG1
TFLG2
TFLG2
TFLG2
Source
Input Capture 1
Input Capture 2
Input Capture 3
Output Compare 1
Output Compare 2
Output Compare 3
Output Compare 4
Input Capture 4/Output Compare 5
Timer Overflow
Pulse Accumulator Overflow
Pulse Accumulator Input