Interrupt and Exception Handling
5-6
MC68322 USER’S MANUAL
MOTOROLA
5.3 TIMER MODULE
For the operating software to monitor time, the MC68322 provides a timer that continuously
posts an interrupt event to the core at regular intervals. Like the other modules of the
MC68322, the timer runs independent of the core (even though its interval can be changed
by the core at any time).
A timer operation is initiated by a write to the interval field in the timer register. At 16MHz,
the width of the timer register provides an interrupt frequency range from 125ns to more than
one second. Typically, this register is only set once during software initialization to produce
interrupts every 50ms. Figure 5-3 illustrates the timer register.
Figure 5-3. Timer Register
The timer interval field specifies the number of 1
× clocks between timer interrupts. The timer
count field provides the current 1
× clock count value in case more precise timing is required.
The interval field must be initialized before a timer interrupt event is enabled in the timer
interrupt event register (TIER), which is illustrated in Figure 5-4.
Figure 5-4. Timer Interrupt Event Register
The timer interval and count fields in the timer register consist of a high byte and low word.
First the high byte should be loaded, followed by the low word, which is the natural order of
an core long-word write access. Loading the low word causes the new interval to be loaded
into the timer counter. The count field counts down to zero, generates an interrupt, and then
reloads from the interval field. The value read from the count field reflects the current state
of the timer counter. The count field should be read twice to determine the actual timer
count. The timer count will decrement between the read of the high byte and the low word
portions of the count field, which can cause the high byte to decrement. For example, if the
timer counts down from 300
16 to 2FF16 between reads, then the software may incorrectly
read the upper byte as 3 and the lower word as FF
16 for a total of 3FF16.
= RESERVED
15
14
13
12
11
10
9
8
7
65432
1
0
15
14
13
12
11
10
9
8
7
65432
1
0
TIMER INTERVAL (HIGH BYTE)
00FFF600
00FFF602
00FFF604
00FFF606
TIMER INTERVAL (LOW WORD)
TIMER COUNT (HIGH BYTE)
TIMER COUNT (LOW WORD)
= RESERVED
15
14
13
12
11
10
9
8
7
65432
1
0
15
14
13
12
11
10
9
8
7
65432
1
0
ENB
00FFF730
00FFF732
00FFF734
INT
LEVEL
F
re
e
sc
a
le
S
e
m
ic
o
n
d
u
c
to
r,
I
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
n
c
..
.