825482C54
825482C54
825482C54
Page 1 of 4
6/1/2013
Page 2 of 4
3. After power-up, the count value and output of all Counters are undefined. 4. Each counter must be programmed before it can be used. 5. Unused counters need not be programmed. 6. Counters are programmed by writing a Control Word and then an initial count. 7. GATE=1 enables counting, GATE=0 disables counting.
COUNTER DESCRIPTION:
COUNTING ELEMENT, OLm, OLl, OL: 1. The actual Counter is "CE" in figure 5. 2. OLm and OLl are two 8-bit latches. OL is "Output Latch" The subscripts m and l stand for "Most significant byte" and "Least significant byte". Both are normally referred to as one unit and called just OL. These latches "follow" the CE as it counts. 3. If a suitable Counter Latch Command is sent to the 8254, the latches capture the present count until read by the CPU. Once read, the latches return to "following" the CE. 4. One latch at a time is enabled by the counter's control logic to drive the internal bus. This is how the 16bit counter communicates over the 8-bit bus. 5. The CE itself cannot be read. If the user wants to read the count, it is the OL that is being read. CE, CRm, CRl, CR: 1. There are two 8-bit registers called CRm and CRl. These are the Count Register (Most significant byte and Least significant byte.) Both are normally just called the CR. 2. When a new count is written to the counter, the count is stored in the CR and later transferred to the CE. 3. The Control Logic allows one register at a time to be loaded from the internal bus. 4. Both bytes are transferred to the CE simultaneously. 5. CRm and CRl cleared when the Counter is programmed so that if the Counter has been programmed for one byte counts (either lsb or msb only) the other byte will be zero. 6. Note that the CE cannot be written into; whenever a count is written, it is written into the CR.
WRITE OPERATIONS:
There are two conventions for writing to the 8254: 1. For each Counter, the Control Word must be written before the initial count is written. 2. The initial count must follow the count format specified in the Control Word (lsb only, msb only, or lsb then msb). A new initial count may be written to a Counter at any time without affecting the Counter's programmed Mode in any way. However, the actual counting in the Counter will be affected as described in the various Mode definitions.
READ OPERATIONS:
The value of a Counter can be read by any one of the following three methods: 1. A simple READ operation: a. Select the Counter with the A1,A0 inputs. b. Inhibit the CLK of the selected counter by using either the GATE input or external logic. (The CLK must be inhibited or the count may be in the process of changing when it is read, giving an undefined result.)
6/1/2013
Page 3 of 4
c. Note that stopping the CLK stops the count. 2. Counter Latch Command (does not disturb the count in progress): a. It is written to the Control Word Register like a Control Word, but two bits (D5,D4) distinguish this command from a Control Word. b. The selected Counter's OL latches the count at the time the Counter Latch Command is received. c. The count is held in the latch until it is read by the CPU. d. The count is then unlatched automatically and the OL returns to "following" the CE. 3. Read-Back Command: a. This command allows the user to check the count value, programmed Mode, and current states of the OUT pin and Null Count flag of the selected counter(s). b. This command is similar to several Counter Latch Commands, one for each counter latched.
MODE DEFINITIONS:
CLK PULSE: a rising edge, then a falling edge, in that order, of a Counter's CLK input. Trigger: a rising edge of a Counters GATE input. Counter loading: the transfer of a count from the CR to the CE. MODE 0: INTERRUPT ON TERMINAL COUNT 1. Event counting. 2. After the Control Word is written, OUT is initially low and remains low. 3. When the counter reaches zero. OUT then goes high and remains high until a new count or a new Mode 0 Control Word is written into the Counter. MODE 1: HARDWARE RETRIGGERABLE ONE-SHOT 1. OUT will be initially high. OUT will go low on the CLK pulse following a trigger to begin the one-shot pulse, and remain low until the Counter reaches zero. 2. OUT will then go high and remain high until the CLK pulse after the next trigger. MODE 2: RATE GENERATOR 1. Functions like a divide-by-N counter and used to generate a Real Time Clock interrupt. 2. OUT will initially be high. 3. When the initial count has decremented to one, OUT goes low for one CLK pulse. 4. Out then goes high again, the Counter reloads the initial count and the process is repeated. 5. MODE 2 is periodic. The same sequence is repeated indefinitely. MODE 3: SQUARE WAVE MODE 1. Typically used for baud rate generation. 2. Out will initially be high. 3. When half the initial count is expired, OUT goes low for the remainder of the count. 4. MODE 3 is periodic. The same sequence is repeated indefinitely. MODE 4: SOFTWARE TRIGGERED STROBE 1. OUT will initially be high. 2. When the initial count expires, OUT will go low for one CLK pulse and then go high again. 3. The counting sequence is "triggered" by writing the initial count. 4. The Counter is loaded on the next CLK pulse following writing a Control Word and initial count. MODE 5: HARDWARE TRIGGERED STROBE (RETRIGGERABLE) 1. OUT will initially be high. 2. Counting is triggered by a rising edge of GATE. 3. When the initial count expires, OUT will go low for one CLK pulse and then go high again. 4. The difference between MODE 4 and MODE 5 is that in MODE 5 the count will not be loaded until the CLK pulse after a trigger.
6/1/2013
Page 4 of 4
6/1/2013