TIMER/COUNTER
8254 PROGRAMMABLE INTERVAL TIMER
The 8254 is a programmable interval timer/counter specially designed for
use in real time applications for timing and counting function such as
binary counting , generation of accurate time delay
FEATURES
Compatible with all Intel Microprocessor
Handles input from DC to 10 MHz
Clock frequency is 10MHz
Status Read Back command
Three Independent 16-Bit
counter
The 8254 is a programmable interval timer / counter designed for use with
Intel microcomputer system
In general multi-timing element that can be treated as an array of I/O ports in
the system software
It consist of three identical counting circuits each of which has CLK and
GATE inputs and OUT outputs
It solves the most common problem in any microcomputer system the
generation of accurate time delay under software control
8254 to match the requirement and program one of the counter for the desired
Delay
After the desired delay 8254 will interrupt the CPU
Some of other counter/timer function common to microcomputer which can
be implemented with the 8254 are
Real time clock
Event-counter
Programmable rate generator
Square wave generator
Complex waveform generator
DATA BUS BUFFER
This is 3-state bidirectional 8-bit buffer is used to interface the 8254 to the
system bus
READ/WRITE LOGIC
The read/write logic accepts the input from the system bus and generate
the
Control signal for the other functional block of the 8254
A1 and A0 select one of the three counter or the control word register to be
read /write
A low on the RD input tells the 8254 that the CPU is reading one of
the counter
A low on the WR input tells the 8254 that the CPU is writing either a
control
word or an initial count
CONTROL WORD REGISTER
The control word is selected by the read/write logic when A1,A0 =11
CPU does a write operation to the 8254 the data is stored in the control word
register
Control word is used to define the operation of the counters
Control word register is used only for written cannot be used for read
COUNTER 0,COUNTER 1,COUNTER 2
These three functional blocks are identical in operations so only single
counter are described
The counters are fully independent .
Each counter may operate in a different mode
Each counter has 3 logical line CLOCK,GATE and OUT
CLOCK and GATE are input signal and OUT are output signal
The function of these lines changes depending on how the
device is initialized
Gate signal act as a start pulse depending on the mode of operation of the
counter
The counter can easily read by the CPU
Read/Write control logic signal
Counter RD WR A0 A1 Function
Counter0 1 0 0 0 Load counter 0
0 1 0 0 Read counter 0
Counter 1 1 0 0 1 Load counter 1
0 1 0 1 Read counter 1
Counter 2 1 0 1 0 Load counter 2
0 1 1 0 Read counter 2
Control word 1 0 1 1 Write control
word register
Read/Write control supports five control signal RD,WR,A0,A1 and CS
Address line A0 and A1 selects counter0 or counter1 or counter2 or the
control word register
Based on the RD or WR signals are enabled at the particular time determined
the selected counter or control word register to perform read or write operation
Control word format
D7 D6 D5 D4 D3 D2 D1 D0
SC1 SC0 RL1 RL0 M2 M1 M0 BCD
SC-Select Counter
SC0 SC1 M2 M1 M0
0 0 Select counter 0 0 0 0 Mode 0
0 1 Select counter 1 0 0 0 Mode 1
1 0 Select counter 2 X 1 0 Mode 2
1 1 Read back X 1 1 Mode 3
command 1 0 0 Mode 4
1 0 0 Mode 5
BCD
0 Hexadecimal count
1 Binary coded decimal
RL0 RL1
0 0 Counter latch
0 1 Read/Write least significant bytes only
1 0 Read/Write most significant bytes only
1 1 Read/Write least significant bytes only first
them most significant byte
Read Back Command
This command allows the user to check the count value
Operating modes of 8254
Each of the three counters of 8254 can be operated in one of the following six
modes of operation
Mode 0 : Interrupt of Terminal Count TC
Mode 1 : Programmable On shot
Mode 2 : Rate generator
Mode 3 : Square wave generator
Mode 4 : Software Triggered Strobe
Mode 5 : Hardware Triggered Strobe
Mode 0: The output goes high
after the terminal count is
reached. The counter stops if
the Gate is low.. The timer Mode 0 count
count register is loaded with a when Gate is
count (say 6) when the WR high (enabled)
line is made low by the
processor. The counter unit
starts counting down with each
clock pulse. The output goes
high when the register value
reaches zero. In the mean time
if the GATE is made low the
Mode 0 count
count is suspended at the when Gate is
value(3) till the GATE is low
enabled again . temporarily
(disabled)
Mode 1 Programmable mono-shot
The output goes low with the Gate pulse
Mode 1 The Gate
for a predetermined period depending on goes high. The
the counter. The counter is disabled if output goes low
the GATE pulse goes momentarily low. for the period
The counter register is loaded with a depending on the
count
count value as in the previous case (say
5). The output responds to the GATE
input and goes low for period that equals
the count down period of the register (5
clock pulses in this period). By changing
the value of this count the duration of
Mode 1 The Gate
the output pulse can be changed. If the pulse is disabled
GATE becomes low before the count momentarily
down is completed then the counter causing the
will be suspended at that stage as long as counter to stop.
GATE is low. Thus it works as a mono-
shot.
Mode 2
Mode 2 The Gate
Programmable goes high.
Rate Generator
In this mode it operates as a
rate generator. The output
goes high for a period that
equals the
time of count down of the
count register (3 in this Mode 2 The Gate
case). The output goes pulse is disabled
low exactly for one clock momentarily.
period before it becomes
high again. This is a
periodic operation.
Mode 3 Programmable
Square Wave Rate
Generator
It is similar to Mode 2 but the output high
and low period is symmetrical. The output
goes high after the count is loaded and it
remains high for period which equals the
count down period of the counter register. The
output subsequently goes low for an equal
period and hence generates a symmetrical
square wave unlike Mode 2. The GATE has
no role here.
Mode 4
Triggered
Strobe
In this mode after the count is loaded by the
processor the count down starts. The output
goes low for one clock period after the count
down is complete. The count down can be
suspended by making the GATE low . This is
also called a software triggered strobe as the
count down is initiated by a program.
Mode 5
Hardware
Triggered
Strobe
The count is loaded by the processor
but the count down is initiated by the
GATE pulse. The transition from low to
high of the GATE pulse enables count
down. The output goes low for one
clock period after the count down is
complete.
Interfacing 8253/54 with 8085 microprocessor