New York, NY IMG HI 58° LO 56° Home About Contact
Home Electrical and Electronics Microprocessor & Interfacing Write an assembly language program to interfacing 8253 Timer with 8086 in mode 0.
Microprocessor & Interfacing Lab Experiments

Write an assembly language program to interfacing 8253 Timer with 8086 in mode 0.


Write an assembly language program to interfacing 8253 Timer with 8086 in mode 0.

Theory:The Intel 8253 is a Programmable Interval Timers (PITs), which perform timing and counting functions.

The 8253/54 solves one of most common problem in any microcomputer system, the generation of accurate time delays under software control. Instead of setting up timing loops in system software, the programmer configures the 8253 to match his requirements, initializes one of the counters of the 8253 with the desired quantity, then upon command the 8253 will count out the delay and interrupt the CPU when it has completed its tasks. 8253/54 can be operated in 6 different modes with the use of Control word Register


  1. Step 1: “7FH” is the command used to unmask IRQ7. Do the connection as follows:
  2. setup
  3. Step 2:“30H” is the control word for 8253. Binary counter 0 is selected. Timer mode is 0. Lower 8-bit count should be loaded first and then higher 8-bit count should be loaded.
  4. Step 3:0005H is the 16-bit count that is loaded into the counter. First the LSB count should be loaded followed by the LSB count.
  5. Step 4:“00H” is the control word for 8253 to latch the count. If the 4th and 5th bits of control words are 0 then the count can be latched. MSB and LSB count can be stored in a reg. pair so that it can be read
  6. code
  7. Step 5:A pulse can be given to the pulser clock as shown in figure and the output can be observed at the OUT0 pin.
  8. setup-1
  9. Step 6:After 5 pulses OUT0 goes high generating IRQ7.

Apparatus:Dyna 8086 microprocessor kit and PPI card (8253).

Address Opcode Mnemonics Operand Comments
1000 B0 7F MOV AL, 07FH Unmask IRQ 7
1002 E6 02 OUT 02 (OCW1) ,AL Send OCW1
1004 FB STI Enable Interrupts
1005 B0 30 MOV AL,30H Binary counter_0 selected, mode 0 read / load LSB first & then MSB
1007 E6 33 OUT 33 (CMD_PORT_53), AL Out the content of AL to CMD_PORT_53
1009 B0 05 MOV AL, 05H Load 05 to 16 bit counter
100B E6 30 OUT 30 (COUNTER_0), AL Counter_0 LBS
100D B0 00 MOV AL, 00H Load control word 00H
100F E6 30 OUT 30 (COUNTER_0), AL Counter_0 MSB
1011 E4 30 IN AL, 30 (Counter_0) Read_LSB
1013 8A D0 MOV DL, AL Move AL to DL
1015 E4 30 IN AL, 30 (Counter_0) Read MSB
1017 8A F0 MOV DH, AL Move AL to DH
1019 EB 0D 10 JMP 1101 JMP 1101 Jump to address 1011

Result: LED1will glow after 5 pulser compression key as shown in figure below.


Viva Questions:

  1. State the number of counters that are present in the programmable timer device 8253?
  2. Name the mode that is used to interrupt the processor by setting a suitable terminal count is?
  3. Name the counter which is selected when in control word register is SC1=0 and SC0=1?
  4. What operation is performed by 8254 when in control word register, RL1=1, RL0=1?
  5. Which mode of 8253 can provide pulse width modulation?

Procedure for writing and compiling program through μ vision keil :

Software environment and microcontroller description:

Procedure to write the program in μ Vision Keil:

  1. Create a New Project.
  2. Give an appropriate name to the project.
  3. Select Target as Atmel AT89C52.
  4. After creation of project open a new file. Start writing your program.
  5. If the program needs to be included then include the program in Target1 as :
  6. Right click on “Source Group1” to add the file as: (Add file to group “Source Group 1”)

  7. Now, file will be included in the target.
  8. Right click on Target1 → click option for Target1 → Output Tab →tick the check box “Create the Hex file”.
  9. Now build the target & rebuild it.
  10. Debug the errors (if any).
  11. Open the Flash Magic.
  12. Select Device “89LV51RD2” as written on the microcontroller.
  13. IMP: Check the COM port each time we connect the microcontroller through USB. e.g. „COM12‟ (Check from device manager).
  14. Select the same COM port in the COM port drop down box in the flash magic as given in step 13.
  15. Select the baud rate as 9600.
  16. Select the check box “Interface Non (ISP)”.
  17. Check “Erase all Flash”.
  18. Select the Hex file from the directory
  19. IMP: make sure go to options→ Advance options → Hwdr Config..-->”Use DTR to control RST ” box is unchekcked.
  20. Now, Make sure that jumper settings are as per 4-bit and 8-bit operation. (Refer Dyna51 User Manual).
  21. Press Start.
  22. At bottom of the Flash Magic window “Finished ” will be displayed.