ExternalInterrupt PPT
ExternalInterrupt PPT
8051 Microcontroller.
An interrupt is an external or internal event that interrupts the
microcontroller to inform it that a device needs its service.
A single microcontroller can serve several devices.
There are two ways to do that
◦ Polling
◦ Interrupt
In Polling:
The microcontroller continuously monitors the status of
device.
When the status condition is met, it performs the service.
After that it moves to next device until each one is serviced.
Polling can monitor the status of several devices and serve
for service.
This is not possible for the polling method.
For every interrupt, there must be an interrupt service routine
(ISR), or interrupt handler.
When an interrupt is invoked, the micro-controller runs the
EA (enable all) must be set to 1 in order to enable interrupts that need to be enabled(Global Enable)
Switch
27
LED 25
8051
(P 1.5)
Microcontroller
2x16 LCD
LED TOGGLES UPON
EACH EXT INT0
1. INCLUDE HEADER FILE at89c51ed2.h
2. LCD FUNCTION PROTOTYPE DECLARATION (INITIALIZATION,
COMMAND, DATA, CLEAR).
3. CLEAR TEMP1 REGISTER, DECLARE TEMP2 REGISTER.
lcd_backlight(sbit).
7. BEGIN MAIN
8. AUXR=0X10 TO ACCESS FULL XRAM.
9. CLEAR INTERRUPT FLAG: IE=0.
10. IT0=1.
11. ENABLE EXTERNAL INTERRUPT 0: EX0=1.
12. ENABLE GLOBAL INTERRUPT: EA=1.
13. CLEAR L: LED L25=0.
14. CLEAR LCD.
15. LCD INTIALIZATION.
16. DISPLAY FIRST MESSAGE ON FIRST LINE OF LCD STARTING
FROM FIRST POSITION(LCD_COMMAND=0X80, LCD_DATA).
17. DISPLAY SECOND MESSAGE ON SECOND LINE OF LCD
STARTING FROM FIRST POSITION(LCD_COMMAND=0XC0,
LCD_DATA).
18. UPON INTERRUPT, INTERRUPT SERVICE ROUTINE FOR
EXTERNAL INTERRUPT 0 EXECUTES (i.e., WHEN SWITCH 27 IS
PRESSED, LED CONNECTED TO P1.5 SHOULD TOGGLE).
19. DISABLE INTERRUPT: IE0=0.
20.END
#include "at89c51ed2.h"
void main(void)
{
AUXR = 0x10; //Accesiing Ful XRAM
temp1 = 0x80; // Display the data from first position of first line
lcd_comm(); // Command Writing
for(i=0;i<16;i++)
{
temp2 = arr1[i];
lcd_data(); // Data Writing
}
temp1 = 0xC0; // Display the data from first position of
//first line
lcd_comm(); // Command Writing
for(i=0;i<16;i++)
{
temp2 = arr2[i];
lcd_data(); // Data Writing
}
while(1);
}
void ie0_isr(void) interrupt 0
{
L=~L;
IE0 = 0;
}
Pin-1&2 of the Jumper JP4 are shorted.
Connect CN2 to CN11 and similarly CN3 to CN6 using 10 core