Programmable Interval Timer.
Programmable Interval Timer.
INTERVAL TIMER
(8253/8254)
INTRODUCTION
• Read/write logic
Accepts input from system bus.
Generates logic for the other functional blocks.
A1,A0 selects counters or control word register.
Low on RD` indicates to 8354 that microprocessor is performing a read.
A low on WR` indicates CPU is writing control word or initial count.
FUNCTIONAL BLOCKS OF 8253\54 (continued)
• Control word/register
Selected when A1 and A0 are both high(1).
Used in defining counter operation during write.
Read operations cannot be done on CWR.
After writing the CWR, it acts as a control word.
FUNCTIONAL BLOCKS OF 8253\54 (continued)
• D7-D0(data bus)
Bidirectional tri-stated data bus lines.
Connected to system data bus lines.
Count values for the timer is loaded into the registers of the
timer.
Are also used in initializing the timer.
PIN CONFIGURATION OF 8253/54 (continued)
• RD` (Read )
Active low input to timer.
Input is low during microprocessor read operations.
Signal is used to read status and counter values.
PIN CONFIGURATION OF 8253/54 (continued)
• WR` (Write)
Active low input signal.
It is low during write operations.
Used in writing word CWR.
Writes count values for counter registers.
PIN CONFIGURATION OF 8253/54 (continued)
• OUT0,OUT1,OUT2(output)
Output lines of the three counters.
Provides the output from the three counters.
PROGRAMMING THE 8253/54
• Formats for initializing control register and loading count registers is as shown:
WRITE OPERATIONS (continued)
• This command is written to the control word register, selected when A1,
A0 – 11.
• Like a control word, the SC1, SC1 bits select one of the three counters
• D5 and D4 distinguish this command from a control word.
COUNTER LATCH COMMAND (8353/8254)
(continued)
• Counter’s output latch (OL) latch the count when counter latch command is received.
• The count is then held by the CPU until it is read by the CPU or the counter is
reprogrammed.
• The count is then unlatched automatically and the OL return to “following “ the
countering element (CE)
• This allows for reading the contents of the counters “on the fly “ without affecting
counting.
COUNTER LATCH COMMAND (8353/8254)
(continued)
• This command may also be used to latch status information by setting STATUS bit D4 - 0.
• Status must be latched to be read.
• The status of the counter is accessed by a read from that counter.
• Bits D5 through D0 contain the counter’s programmed mode as written in the mode control
word.
• D7 contains the current state of the OUT pin, allowing the user to monitor the counter’s
output via software.
READ BACK COMMAND (ONLY 8254) (continued)
• Null count D6 indicated when last count written to CR has been loaded into CE
• The operation of the null count is as shown below:
OPERATING MODES PIT 8254
• If a new count is written to the counter during a one shot pulse , the current
one shot is not affected.
• The counter is loaded with the new count and the one shot pulse continues
until the new count expires.
• New counting starts after new trigger pulse.
MODE 2: RATE GENERATOR
• Functions like a divide-by-N counter and used to generate a Real Time Clock interrupt.
• OUT will initially be high.
• When the initial count N has decremented to 1, OUT goes low for one clock pulse.
• OUT then goes high again, the count N is reloaded, and the process is repeated.
• MODE 2 is periodic. The same sequence is repeated indefinitely.
MODE 2: RATE GENERATOR (continued)
.
MODE 5: HARDWARE TRIGGERED STRODE
(RETRIGGERABLE)
• The initial state of OUT is high.
• Counting is triggered by a rising edge of GATE.
• After the initial count has expired, OUT will go low for one CLK pulse and then go high again.
• The counter will not be loaded until the CLK pulse after a trigger
• This CLK pulse does not decrement the count.
MODE 5: HARDWARE TRIGGERED STRODE
(RETRIGGERABLE) (continued)
• A trigger results in the counter being loaded with the initial count on the next CLK pulse.
• The counting sequence is triggerable, and GATE has no effect on OUT.
• If a trigger occurs after the new count is written but before the current count expires,
• the counter will be loaded with the new count on the next CLK pulse, and counting will
continue from there.
OPERATION COMMON TO ALL MODES
• Gate Input
In modes 0, 2, 3, and 4, the Gate input is level sensitive and sampled on the rising
edge of CLK
In modes 1, 2, 3, and 5, the Gate input is rising-edge sensitive and triggers an edge-
sensitive flip-flop in the counter
The flip-flop is sampled on the next rising edge of CLK and immediately reset
Modes 2 and 3 have both edge and level sensitivity for the Gate input
OPERATION COMMON TO ALL MODES
(continued)
• Counter Operation
New counts are loaded and counters are decremented on the falling edge of CLK
The largest possible initial count is 0, equivalent to 216 for binary counting and 104
for BCD counting
The counter does not stop when it reaches zero
Modes 0, 1, 4, and 5 "wrap around" to the highest count (FFFF hex for binary
counting or 9999 for BCD counting) and continue counting
Modes 2 and 3 are periodic, reloading the initial count and continuing counting from
there.
GATE PIN OPERATION SUMMARY
SYSTEM INTERFACE OF 8353/54
SYSTEM INTERFACE OF 8353/54 (continued)
• The control signal generator produces four control signals: IOR, IOW, MEMR, and
MEMW.
• Two of these signals are connected to the RD and WR signals of 8253/54.
• The RD` and WR` signals of 8253/54 are connected to IOR and IOW signals for mapped
IO.
• MEMR and MEMW signals are used instead of IOR and IOW signals for memory
mapped IO.
• The A1 and A0 are connected to the demultiplexed A2 and AI address lines of the
processor to generate addresses.
SYSTEM INTERFACE OF 8353/54 (continued)
• BHE is used to enable the odd ports (counters/CWR) of 8253/54, while CS` enables the
8253/54 chip.
• The D0-D7 data lines of even 8253/54 are connected to the processor's D0-D7 data bus,
and D8-D15 lines of odd 8253/54.
• CLK, GATE, and OUT signals are connected to peripheral devices.
INTERFACING OF 8253/54 IN IO MAPPED IO
METHOD
• Chip select signal is used along with either A or BHE signals to generate final chip enable
signals for even or odd 8253/54.
• Address of different counters and CWR are determined based on chip select logic, A, A1,
An, or BHE signals.
𝑨𝟕 𝑨𝟔 𝑨𝟓 𝑨𝟒 𝑨𝟑 𝑨𝟐 𝑨𝟏 𝑨𝟎
1 1 1 O 1 0 0 0 E8H FOR COUNTER 0
1 1 1 O 1 0 1 0 EAH FOR COUNTER 1
1 1 1 O 1 1 0 0 ECH FOR COUNTER 2
1 1 1 O 1 1 1 0 EEH FOR CWR
• This method uses MEMR and MEMW as control signals instead of IOR and IOW.
• Chip select logic decodes all address lines from A3-A19.
INTERFACING OF 8253/54 IN MEMORY MAPPED IO
METHOD (continued)
• The complete interfacing circuit for memory mapped 10 technique can be illustrated as:
INTERFACING OF 8253/54 IN MEMORY MAPPED IO
METHOD (continued)
On the basis of chip select logic, A_2and A_1 signals the addresses of different counters
and CWR are:
EXAMPLE ON PROGRAMMING 8253/54
• Initializing 8253/54 in mode 1 to read and load lower 8-bits only assuming that 8253/54
is interfaced in memory mapped IO.
• Solution:
• 12H is the control word for 8253 with the counter in mode 1.
• Binary counter 0 is selected.
• Load lower 8-bits only.
• It latches the count and then stores it in register. So that it can be read.
• Let 05H is the lower 8-bit count
EXAMPLE ON PROGRAMMING 8253/54
• Solution:
• Assuming that the addresses of the counters and CWR are even:
3FFE8H Counter 0
3FFEAH Counter 1
3FFECH Counter 2
3FFEEH = CWR
• Also assuming that the content of the DS is 3000 and the corresponding logical addresses
FFE,H. FFEAH, FFECH, and FFEEH
EXAMPLE ON PROGRAMMING 8253/54
• Program:
MOV AL, 12H: Binary counter O, mode 1
MOV [FFEEH] AL: Read/load lower 8-bits
MOV AL, O5H: Lowers 8-bit count
MOV [FFE8H], AL
MOV AL, 02H Binary counter O, mode 1 counter latch
MOV [FFEEH], AL
MOV AL, [FFE8H] : LSB of counter
INT O3H.
REFERENCES