
MOTOROLA
MC68341 USER’S MANUAL
8- 9
The timer is enabled by setting both the SWR and CPE bits in the CR and, if TGATE is
enabled (CR TGE bit is set), then asserting TGATE . When the timer is enabled, the ON bit
in the SR is set. On the next falling edge of the counter clock, the counter is loaded with
the value stored in the PREL1 register (N1). With each successive falling edge of the
counter clock, the counter decrements. The time between enabling the timer and the first
time-out can range from N1 to N1+1 periods. When TGATE is used to enable the timer,
the enabling of the timer is asynchronous; however, if timing is carefully considered, the
time to the first time-out can be known. For additional details on timing, see the Section
12 Electrical Characteristics.
If the counter counts down to the value stored in the COM register, the COM and timer
compare interrupt (TC) bits in the SR are set. The counter continues counting down to
time-out. At this time, the TO bit in the SR is set, and the COM bit is cleared. The next
falling edge of the counter clock after time-out causes the value in PREL2 (N2) to be
loaded into the counter, and the counter begins counting down from this value. Each
successive time-out causes the counter to be loaded alternately with the values from
PREL1 and PREL2.
TOUT behaves as a variable duty-cycle square wave when the CR OC bits are
programmed for toggle mode. The second time-out occurs after N2 + 1 periods (allowing
for the zero cycle), resulting in a change of state on TOUT. The third time-out occurs after
N1 + 1 periods, resulting in a change of state on TOUT, and so on (see Figure 8-6). The
OUT bit in the SR reflects the level of TOUT.
COUNTER
CLOCK
0
4
3
2
1
0
2
1
0
4
3
2
1
COUNTER
TOUT
N1: N1 + 1
N2 + 1
N1 + 1
ENABLE
TIMEOUT
MODEx Bits in Control Register = 010
Preload 1 Register = N1 = 4
Preload 2 Register = N2 = 2
OCx Bits in Control Register = 01
0
2
1
0
TIMEOUT
N2 + 1
Figure 8-6. Variable Duty-Cycle Square-Wave Generator Mode
If TGATE is negated when it is enabled (TGE = 1), the prescaler and counter are disabled.
Additionally, the TG bit of the SR is set, indicating that TGATE was negated. The ON bit of
the SR is cleared, indicating that the timer is disabled. If TGATE is reasserted, the timer is
re-enabled and begins counting from the value attained when TGATE was negated. The
ON bit is set again.
If TGATE is not enabled (TGE = 0), TGATE has no effect on the operation of the timer. In
this case, the counter would begin counting on the falling edge of the counter clock
immediately after the SWR and CPE bits in the CR are set. The SR TG bit cannot be set.
At all times, the TGL bit in the SR reflects the level of TGATE.
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
..
.