
Counters/Timers
LH77790B User
’
s Guide
11-14
Mode 3: Square Wave Generator
This mode is similar to Mode 2 except for the duty cycle. In this mode, OUT is initially HIGH.
In this mode, the least significant bit of the count value (even or odd) will always be reset to ‘0’
.
For an initial even count values, when the count value is written to CR, the counting ele-
ment (CE) is loaded in the next clock cycle. CE is decremented by two on succeeding clock
cycles. One clock cycle after CE reaches a count of two, OUT goes low and CE is
reloaded. CE is then decremented by two on succeeding clock cycles. One clock cycle
after CE reaches a count of two, OUT goes high and CE is reloaded and so on. OUT will
be HIGH for N/2 cycles and LOW for N/2 cycles.
For an initial odd count values, when the count value is written to CR, the counting element
(CE) is loaded in the next clock cycle (CE contains the initial odd count -1). CE is decre-
mented by two on succeeding clock cycles. One clock cycle after CE reaches a count of
zero, OUT goes LOW and CE is reloaded. CE is then decremented by two on succeeding
clock cycles. One clock cycle after CE reaches a count of two, OUT goes HIGH and CE is
reloaded with CR minus one and so on. OUT will be high for (N + 1)/2 cycles and low for
(N
–
1)/2 cycles.
If CR is written while CE is counting, it will not affect the current counting sequence. CE
will be loaded with the new count when OUT changes level (N/2 for even count or
(N + 1)/2 for odd count).
If GATE goes LOW, OUT goes high immediately and CE stops decrementing. Once GATE
goes HIGH again, CE is reloaded on the next clock cycle (regardless of the current count
value in CE) and the sequence starts again. The GATE input can be used to synchronize
the counter.
For a count value of N, a square wave is generated with a period of N clocks.
Writing a new Mode 3 word into CT_CWR will cause CE to stop counting.
NOTE:
A count value of
‘
1
’
is illegal in Mode 3.
Mode 4: Software Triggered Strobe
In this mode, OUT is initially HIGH. When the count value is written to CR, the counting ele-
ment (CE) is loaded in the next clock cycle. The CE starts decrementing on succeeding clock
cycles. The OUT pin will remain HIGH until a count of zero is reached. The OUT pin then
goes LOW for one clock cycle then goes HIGH again. The counter keeps decrementing.
If CR is written while CE is counting, CE will be loaded with the new count on the next clock
cycle and the sequence continues form the new count. When operating as a 16-bit counter
(RW1 = RW0 = 1), writing the first byte has no effect, but the second causes the counter
to be loaded.
When GATE is HIGH, counting is enabled. When GATE is LOW, counting is disabled.
GATE does not affect OUT.
For a count value of N, OUT will go LOW N clock cycles after the count is loaded into CE
from CR.