Microprocessor & Interfacing Lab Experiments
Write an assembly language program to interfacing 8253 Timer with 8086 in mode 0.
Sep 24 2023
Aim
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
Procedure:
- Step 1: “7FH” is the command used to unmask IRQ7. Do the connection as follows:
- 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.
- 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.
- 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
- 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.
- 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:
- State the number of counters that are present in the programmable timer device 8253?
- Name the mode that is used to interrupt the processor by setting a suitable terminal count is?
- Name the counter which is selected when in control word register is SC1=0 and SC0=1?
- What operation is performed by 8254 when in control word register, RL1=1, RL0=1?
- 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:
- Create a New Project.
- Give an appropriate name to the project.
- Select Target as Atmel AT89C52.
- After creation of project open a new file. Start writing your program.
- If the program needs to be included then include the program in Target1 as :
Right click on “Source Group1” to add the file as: (Add file to group “Source Group 1”)
- Now, file will be included in the target.
- Right click on Target1 → click option for Target1 → Output Tab →tick the check box “Create the Hex file”.
- Now build the target & rebuild it.
- Debug the errors (if any).
- Open the Flash Magic.
- Select Device “89LV51RD2” as written on the microcontroller.
- IMP: Check the COM port each time we connect the microcontroller through USB. e.g. „COM12‟ (Check from device manager).
- Select the same COM port in the COM port drop down box in the flash magic as given in step 13.
- Select the baud rate as 9600.
- Select the check box “Interface Non (ISP)”.
- Check “Erase all Flash”.
- Select the Hex file from the directory
- IMP: make sure go to options→ Advance options → Hwdr Config..-->”Use DTR to control RST ” box is unchekcked.
- Now, Make sure that jumper settings are as per 4-bit and 8-bit operation. (Refer Dyna51 User Manual).
- Press Start.
- At bottom of the Flash Magic window “Finished ” will be displayed.