8- 8
MC68341 USER’S MANUAL
MOTOROLA
COUNTER
CLOCK
0
3
2
1
0
3
2
1
0
3
2
1
0
COUNTER
TOUT
N: N + 1
N + 1
ENABLE
TIMEOUT
MODEx Bits in Control Register = 001
Preload 1 Register = N = 3
OCx Bits in Control Register = 01
3
Figure 8-5. Square-Wave Generator Mode
If TGATE is negated when it is enabled to control the timer (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 SR ON bit is set again.
If TGATE is disabled (TGE = 0), TGATE has no effect on the operation of the timer. In this
case, the counter begins counting on the falling edge of the counter clock immediately
after the SWR and CPE bits in the CR are set. The TG bit of the SR cannot be set. At all
times, TGL in the SR reflects the level of TGATE.
If the counter counts down to the value stored in the COM register, then the COM and TC
bits in the SR are set. The counter continues counting down to time-out. At this time, the
SR TO bit is set, and the SR COM bit is cleared. The next falling edge of the counter clock
after time-out causes the value in PREL1 to be loaded back into the counter, and the
counter begins counting down from this value.
The period of the square-wave generator can be changed dynamically by writing a new
value into the PREL1. Caution must be used because, if PREL1 is accessed
simultaneously by the counting logic and a CPU32 write, the old PREL1 value may
actually get loaded into the counter at time-out.
Periodic interrupt generation can be accomplished by enabling the TO, TG, and/or TC bits
in the SR to generate interrupts by programming the CR IE bits. When enabled, the
programmed IRQ≈ signal is asserted whenever the specified bits are set.
8.3.3 Variable Duty-Cycle Square-Wave Generator
In this mode, both the PREL1 and PREL2 registers are used to generate a square wave
with virtually any duty cycle. The square wave is generated by counting down from the
value in the PREL1 to time-out (count value $0000), then loading that value from PREL2
and again counting down to time-out. When this second time-out occurs, the value from
PREL1 is loaded into the counter, and the cycle repeats. TOUT can be programmed to
change state with every time-out, thus generating a variable duty-cycle square wave. This
mode can be selected by programming the MODE bits in the CR to 010.
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
..
.