MOTOROLA
MC68341 USER’S MANUAL
8- 11
COUNTER
CLOCK
COUNTER
TOUT
0
2
1
0
5
4
3
2
1
0
N1: N1 + 1
N2 + 1
ENABLE
TIMEOUT
MODEx Bits in Control Register = 011
Preload 1 Register = N1 = 2
Preload 2 Register = N2 = 5
OCx bits in Control Register = 01
Figure 8-7. Variable-Width Single-Shot Pulse Generator Mode
If TGATE is negated when it is enabled (TGE = 1), the prescaler and counter are disabled.
Additionally, the SR TG bit is set, indicating that TGATE was negated. The SR ON bit 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.
The width of the pulse generated on TOUT (the value in PREL2) can be changed while
the counter is counting down from the value in PREL1. Caution must be used because, if
PREL2 is accessed simultaneously by the counting logic and a CPU32 write, the old
PREL2 value may actually get loaded into the counter at time-out.
8.3.5 Pulse-Width Measurement
This mode is used to count the clock cycles during a particular event (see Figure 8-8). The
event is defined by the assertion and negation of TGATE . When TGATE is asserted, the
counter begins counting down from $FFFF. When TGATE is negated, the counter stops
counting and holds the value at which it stopped. Further assertions and negations of
TGATE have no effect on the counter. This mode can be selected by programming the CR
MODEx bits to 100.
The timer is enabled by setting the SWR, CPE, and TGE bits in the CR. Asserting TGATE
starts the counter. When the timer is enabled, the SR ON bit is set. On the next falling
edge of the counter clock, the counter is loaded with the value $FFFF. With each
successive falling edge of the counter clock, the counter decrements. The PREL1 and
PREL2 registers are not used in this mode.
When TGATE is negated, the SR TG bit is set, the ON bit is negated, and the prescaler
and counter are disabled. Subsequent transitions on TGATE do not re-enable the counter.
The TGL bit in the SR reflects the level of TGATE at all times.
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
..
.