8051 Interrupts Lab
8051 Interrupts Lab
Overview
• Interrupts are special signals through which other
processes and devices can request for CPU services.
• CPU services are provided by executing a certain peace of
code called ISR, Interrupt Service Routine or ISS Interrupt
Service Subroutine.
• Using interrupts, many operations can be controlled
simultaneously, without any large burden.
• An interrupt can be generated externally (from external
devices) or internally (by internal devices or software
instructions).
• Every processor has a set of rules to be followed when an
interrupt is recognized. However, a generalized sequence
of operation is listed next to get an idea.
8051 Interrupts – Manish Tiwari 2
Illustration of Interrupts
MAIN: ISR:
0500 MOV A,#21 t 2100 XCH A, R0
p
r ru
te
In
Bit Address AFH AEH ADH ACH ABH AAH A9H A8H
Bit No 7 6 5 4 3 2 1 0
Designation EA - - ES ET1 EX1 ET0 EX0
EA
P3.2
INT 0 IE0 EX0 0003H
P3.3
INT 1 IE1 EX1 0013H
UART 0023H
RI/TI ES
TX / RX
CONTROLLER RESET
TF=0 ISR BEGINS ; DEFINE FUNCTION as ISR.
RELOAD TIMER
COMPLEMENT IF TIME is Completed
RETURN ; Go back
EA
P3.2
INT 0 IE0 EX0 0003H
P3.3
INT 1 IE1 EX1 0013H
UART 0023H
RI/TI ES
TX / RX
Bit Address 8FH 8EH 8DH 8CH 8BH 8AH 89H 88H
Bit No 7 6 5 4 3 2 1 0
Designation TF1 TR1 TF0 TRO IE1 IT1 IE0 IT0
void main(void)
{
EA_bit =1; // Enable EA bit in IE.
IT0_bit=1; // Configure INT0 as Edge triggered interrupt.
EX0_bit =1; // Enable INT0 interrupt through IE.
while(1); // Wait for interrupt.
}
Experiment 5