100% found this document useful (3 votes)
6K views

Programmable Interval Timer 8253 or 8254

The Intel 8253/54 programmable interval timer contains 3 independent 16-bit counters that can generate timing signals and interrupts, and is commonly used to control real-time events like clocks. It is programmed by writing control words to select the counter, mode, and count, and can generate waveforms and pulses on its outputs. An example shows programming the timer to output a 100KHz square wave on one counter and a 200KHz pulse on another using an 8MHz clock.

Uploaded by

api-3749180
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
100% found this document useful (3 votes)
6K views

Programmable Interval Timer 8253 or 8254

The Intel 8253/54 programmable interval timer contains 3 independent 16-bit counters that can generate timing signals and interrupts, and is commonly used to control real-time events like clocks. It is programmed by writing control words to select the counter, mode, and count, and can generate waveforms and pulses on its outputs. An example shows programming the timer to output a 100KHz square wave on one counter and a 200KHz pulse on another using an 8MHz clock.

Uploaded by

api-3749180
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 13

Programmable interval timer –

Intel 8253 /54


•Three independent 16-bit programmable counters (timers).
• Each capable in of counting in binary or BCD with a maximum
frequency of 10MHz.

•Used for controlling real-time events such as real-time clock, events


counter, and motor speed and direction control.
 
•Usually decoded at port address 40H-43H and has following functions
for a PC :
•Generates a basic timer interrupt that occurs at approximately 18.2Hz.
•Interrupts the micro at interrupt vector 8 for a clock tick.
•Causes DRAM memory system to be refreshed.
•Programmed with 15us on the PC/XT.
•Provides a timing source to the internal speaker and other devices.
on

                                                                                                                       
8254 Pin Definitions
•A1, A0:The address inputs select one of the four internal registers with the 8254 as 
follows: 

                                                                   

         
•CLK: The clock input is the timing source for each of the internal counters. 
•It is often connected to the PCLK signal from the bus controller. 
•CS: Chip Select enables the 8254 for programming, and reading and writing. 
•G: The gate input controls the operation of the counter in some modes. 
•OUT: A counter output is where the wave­form generated by the timer is available. 
•RD/WR: Read/Write causes data to be read/written from the 8254 and often connects 
to the IORC/IOWC. 
8254 Programming
•Each counter is individually programmed by writing a control word, followed by the 
initial count. 
 
•The control word allows the programmer to select the counter, model of operation, 
binary or BCD count and type of operation (read/write). 

                                                             

                                     
•Each counter may be programmed with a count of 1 to FFFFH. 
•Minimum count is 1 all modes except 2 and 3 with minimum count of 2. 
 
•Each counter has a program control word used to select the way the counter operates. 
•If two bytes are programmed, then the first byte (LSB) stops the count, and the 
second byte (MSB) starts the counter with the new count. 
 
•There are 6 modes of operation for each counter: 
Mode 0: An events counter enabled with G.
•The output becomes a logic 0 when the control word is written and remains there 
until N plus the number of programmed counts. 

                                                                    
                              
riggers the counter to output a 0 pulse for `count' clocks. 
aded if G is pulsed again. 

                                                                         

enerates a series of pulses 1 clock pulse wide.


n between pulses is determined by the count. 
epeated until reprogrammed or G pin set to 0. 

                                                                         
us square-wave with G set to 1.
en, 50% duty cycle otherwise OUT is high 1 cycle longer. 

                                                                         
triggered one-shot (G must be 1).

                                                                         

triggered one-shot. G controls similar to Mode 1.


8254 programming
• Reading a counter
SCO SC1 0 0 XXXX

• SC0 and SC1 set to 11 is the read back


command
• Latch normally follows the counter and if
programmed will latch the counter value till
read
8254 read back control word

1 1 /CNT /ST CNT2 CNT1 CNT0 0

Select counter bits

Latch status of selected


counters

Latch count of selected


counters
8254 Status register

OUT Null RW1 RW0 M2 M1 M0 BCD

Logic 1 for BCD counter

Counter Mode

Read /write operation

Null = 1 , if counter is 0

The level of the out pin


An Example of 8254 programming
• To program 100 Khz Square wave in out 0 and
200Khz continuous pulse in out 1
• Input clock is 8 Mhz; G input is pulled up
• 700H, 702H, 704H and 706H are the four
registers for control
• Find out the counter values for loading
• 8Mhz/ 100Khz = 80 decimal for counter 0
• 8Mhz/ 200Khz = 40 decimal for counter 1
• Find the control words for counters
– 00 11 011 0 for counter 0
– 01 11 100 0 for counter 1
Programming 8254 Programmable
interval timer
• Time proc Near
» Push AX
» Push DX
» MOV DX, 706H ; ADDRESS CONTROL WORD
» MOV AL, 00110110B; PROGRAM COUNTER 0
» OUT DX, AL
» MOV AL, 01110100B ; PROGRAM COUNTER 1
» OUT DX, AL; FOR MODE 3
» MOV DX,700H; ADRESS COUNTER 0
» MOV AL, 80; LOAD COUNT OF 80 ON MSB
» OUT DX,AL
» XOR AL,AL
» OUT DX, AL
» MOV DX,702H; ADDRESS COUNTER 1
» MOV AL,40; LOAD COUNT 40
» OUT DX,AL
» XOR AL,AL
» OUT DX,AL
» POP DX
» POP AX
» RET
• Time endp

You might also like