Hammad Khan Lab07

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

Interrupt Handling In 8051

Hammad Khan (191216)


_________________________

BACHELOR OF ELECTRICAL ENGINEERING


Fall-19

Submitted To:
Engr. Mariam Sabir
Lab Engineer
____________

Department of Electrical Engineering


FACULTY OF ENGINEERING
AIR UNIVERSITY,ISLAMABAD
AIR UNIVERSITY
DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING

EXPERIMENT NO 7

Lab Title: Interrupt Handling in 8051

Student Name: Hammad Khan Reg. No: 191216

Objective: Introducing students to interrupt handling .Using external and internal interrupts and
visualize the outputs

LAB ASSESSMENT:

Excellent Good Average Satisfactory Unsatisfactory


Attributes (5) (4) (3) (2) (1)
Ability to Conduct
Experiment
Ability to assimilate the
results
Effective use of lab
equipment and follows
the lab safety rules

Total Marks: Obtained Marks:

LAB REPORT ASSESSMENT:

Excellent Good Average Satisfactory Unsatisfactory


Attributes
(5) (4) (3) (2) (1)

Data presentation

Experimental results

Conclusion

Total Marks: Obtained Marks:

Date: 25-11-2021 Signature:


Lab#07
Interrupt Handling In 8051
Objective:
 Using microcontroller ports as output
 Getting introduced to smart-pro 5000u burner and it’s software used to program
microcontroller using smart-pro 5000u burner
 Sending data bytes on data ports of microcontroller
 Getting introduced to machine cycle and learning to generate desired delay
 Generating different patterns and displaying the outputs on LEDs

Equipment:
Hardware:
1. 89c51 microcontroller
2. LEDs
Software:
1. Keil u-vision
2. Smart-pro 5000u

Discussion:
Introduction:
A single microcontroller can serve several devices by two ways:
•Polling:
The microcontroller continuously monitors the status of all the devices. Whenever any device
needs the service, it provides the service and moves on to the next device until everyone is
serviced. This will be done in an infinite loop.
•Interrupts:
Whenever any device needs its service, the device notifies the microcontroller by sending it an
interrupt signal. Upon receiving an interrupt signal, the microcontroller interrupts whatever it is
doing and serves the device. The program which is associated with the interrupt is called the
interrupt service routine (ISR) or interrupt handler.
Interrupts:
Interrupts are the events that temporarily suspend the main program, pass the control to the
external sources, and execute their task. It then passes the control to the main program where it
had left off. Once the controller detects the interrupt, it suspends the current job and executes a
special service routine know as Interrupt Service Routine(ISR).
Upon activation of an interrupt, the microcontroller follows the following steps:
• It completes the instruction it is executing and saves the address of the next instruction (PC) on
the stack. It also saves the current status of all the interrupts internally.
• The microcontroller gets the address of the ISR from the interrupt vector table and jumps to it. It
starts to execute the interrupt service subroutine until it reaches the last instruction of the
subroutine which is RETI (return from interrupt).
• Upon executing the RETI instruction, the microcontroller returns to the place where it was
interrupted. file is generated which contains the machine code and the original code and also
specifies the memory location for each command.
EXERCISE
Program Code
ORG 00H
LJMP MAIN
ORG 00013H
MOV A,#00H
MOV P1,A
SETB P2.0
MOV R3,#255
BACK:
DJNZ R3,BACK
CLR P2.0
RET
ORG 30H
MAIN:
MOV IE,#10000100B
START:
MOV A,#10101010B
MOV P1,A
ACALL DELAY
MOV A,#01010101B
MOV P1,A
ACALL DELAY
SJMP START
DELAY:
MOV R6,#25
L1: MOV R7,#25
L2: MOV R2,#255
L3:
DJNZ R2,L3
DJNZ R7, L2
DJNZ R6,L1
RET
END

Proteus Circuit

LAB TASKS
Task#01
Write an assembly language code to blink even odd LED patterns on port 1 and blink an
LED on and off on pin 2.0 by using external interrupt INT1. Write the code in Keil and
create the hex file. Burn the hex file in microcontroller and display the results. Verify these
results in Proteus as well.

Code
ORG 00H
LJMP MAIN
ORG 0003H
CLR A
MOV A,P1
MOV P2,A
RETI
MAIN:
MOV IE,#10000001B
SETB P1.0
BACK: MOV R4,#04H
LP0: MOV R1,#255H
LP1: MOV R2,#255H
LP2: MOV R3, #0EH
LP3: DJNZ R3, LP3
DJNZ R2, LP2
DJNZ R1, LP1
DJNZ R4, LP0
CPL P1.0
SJMP BACK
END

Proteus Circuit
Learning Outcomes:
In this lab, we had to learnt about the basics of interrupts. Interrupts are the events that
temporarily suspend the main program, pass the control to the external sources, and execute their
task. It then passes the control to the main program where it had left off. Once the controller
detects the interrupt, it suspends the current job and executes a special service routine know as
Interrupt Service Routine(ISR).

You might also like