82C54
COUNTER LATCH COMMAND
The second method uses the ‘‘Counter Latch Command’’. Like a Control Word, this command is written
to the Control Word Register, which is selected
when A
1,A0
e
11. Also like a Control Word, the
SC0, SC1 bits select one of the three Counters, but
two other bits, D5 and D4, distinguish this command
from a Control Word.
A1,A
0
e
11; CSe0; RDe1; WRe0
D
7
D
6
D5D4D3D2D1D
0
SC1 SC0 0 0 X X X X
SC1, SC0 - specify counter to be latched
SC1 SC0 Counter
00 0
01 1
10 2
1 1 Read-Back Command
D5,D4 - 00 designates Counter Latch Command
X - don’t care
NOTE:
Don’t care bits (X) should be 0 to insure compatibility
with future Intel products.
Figure 9. Counter Latching Command Format
The selected Counter’s output latch (OL) latches the
count at the time the Counter Latch Command is
received. This count is held in the latch until it is read
by the CPU (or until the Counter is reprogrammed).
The count is then unlatched automatically and the
OL returns to ‘‘following’’ the counting element (CE).
This allows reading the contents of the Counters
‘‘on the fly’’ without affecting counting in progress.
Multiple Counter Latch Commands may be used to
latch more than one Counter. Each latched Counter’s OL holds its count until it is read. Counter Latch
Commands do not affect the programmed Mode of
the Counter in any way.
If a Counter is latched and then, some time later,
latched again before the count is read, the second
Counter Latch Command is ignored. The count read
will be the count at the time the first Counter Latch
Command was issued.
With either method, the count must be read according to the programmed format; specifically, if the
Counter is programmed for two byte counts, two
bytes must be read. The two bytes do not have to be
read one right after the other; read or write or pro-
gramming operations of other Counters may be inserted between them.
Another feature of the 82C54 is that reads and
writes of the same Counter may be interleaved; for
example, if the Counter is programmed for two byte
counts, the following sequence is valid.
1. Read least significant byte.
2. Write new least significant byte.
3. Read most significant byte.
4. Write new most significant byte.
If a Counter is programmed to read/write two-byte
counts, the following precaution applies; A program
must not transfer control between reading the first
and second byte to another routine which also reads
from that same Counter. Otherwise, an incorrect
count will be read.
READ-BACK COMMAND
The third method uses the Read-Back command.
This command allows the user to check the count
value, programmed Mode, and current state of the
OUT pin and Null Count flag of the selected counter(s).
The command is written into the Control Word Register and has the format shown in Figure 10. The
command applies to the counters selected by setting their corresponding bits D3,D2,D1
e
1.
A0, A1e11 CSe0RDe1WRe0
D
7D6D5
D4D3D2D1D
0
1 1 COUNT STATUS CNT 2 CNT 1 CNT 0 0
D5:0eLatch count of selected counter(s)
D4:0eLatch status of selected counter(s)
D
3
:1eSelect counter 2
D
2
:1eSelect counter 1
D
1
:1eSelect counter 0
D
0
: Reserved for future expansion; must be 0
Figure 10. Read-Back Command Format
The read-back command may be used to latch multiple counter output latches (OL) by setting the
COUNT
bit D5e0 and selecting the desired counter(s). This single command is functionally equivalent to several counter latch commands, one for
each counter latched. Each counter’s latched count
is held until it is read (or the counter is reprogrammed). That counter is automatically unlatched
when read, but other counters remain latched until
they are read. If multiple count read-back commands
are issued to the same counter without reading the
7