
Timers
MC68360 USER’S MANUAL
REF—Output Reference Event
The counter has reached the TRR value. The ORI bit in the TMR is used to enable the
interrupt request caused by this event.
CAP—Capture Event
The counter value has been latched into the TCR. The CE bits in the TMR are used to
enable generation of this event.
7.5.3 Timer Examples
The following example lists the required initialization sequence of timer 2 to generate an in-
terrupt every 10
s, assuming a general system clock of 25 MHz. This means that an inter-
rupt should be generated every 250 system clocks.
1. TGCR = $0000. Put timer 2 into the reset state. Do not use cascaded mode.
2. TMR2 = $001A. Enable the prescaler of the timer to divide-by-1 and the clock source
to general system clock. Enable an interrupt when the reference value is reached, and
restart the timer to repeatedly generate 10-
s interrupts.
3. TCN2 = $0000. Initialize the timer 2 count to zero. This is the default state of this reg-
ister.
4. TRR2 = $00FA. Initialize the timer 2 reference value to 250 (decimal).
5. TER2 = $FFFF. Clear TER2 of any bits that might have been set.
6. CIMR = $00040000. Enable the timer 2 interrupt in the CPM interrupt controller. Initial-
ize the CPM interrupt configuration register.
7. TGCR = $0010. Enable timer 2 to begin counting.
To implement the same function with a 32-bit timer using timer 1 and timer 2, the following
sequence may be used:
1. TGCR = $0080. Cascade timer 1 and timer 2. Put timer 1 and timer 2 in the reset state.
2. TMR2 = $001A. Enable the prescaler of timer 2 to divide-by-1 and the clock source to
general system clock. Enable an interrupt when the reference value is reached, and
restart the timer to repeatedly generate 10
s interrupts.
3. TMR1 = $0000. Enable timer 1 to use the output of timer 2 as its input, which is the
default state of this register.
4. TCN1 = $0000, TCN2 = $0000. Initialize the combined timer 1 and timer 2 count to
zero which is the default state of this register. (This can be accomplished with one 32-
bit data move to TCN1.)
5. TRR1 = $0000, TRR2 = $00FA. Initialize the combined timer 1 and timer 2 reference
value to 250 (decimal). (This can be accomplished with one 32-bit data move to
TRR1.)
6. TER2 = $FFFF. Clear TER2 of any bits that might have been set.
7. CIMR = $00040000. Enable the timer 2 interrupt in the CPM interrupt controller. Initial-
ize the CPM interrupt configuration register.
8. TGCR = $0091. Enable timer 1 and timer 2 to begin counting. Leave the timers in cas-
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
..
.