You are on page 1of 1

External Interrupt programming in 8051

ALP:
org 50h
db 0c0h,0f9h,0a4h,0b0h,99h,92h,82h,0f8h,80h,90h ;number code for SSD
display
org 00h
sjmp main ;jump to main
org 003h ;INT0 vector address
inc dptr ;increment dptr
movc a,@a+dptr ;move the dptr address value to a
mov p0,a ;move the value of a to port0
reti
org 30h
main:mov ie,#81h ;enable external interrupt 1
setb tcon.0 ;set it to edge-triggered
mov dptr,#50h ;first number address
mov p2,#08h ;select SSD 1
here: clr a
sjmp here ;idle main loop
end
C-code:
#include<reg51.h>
unsigned int i;
void counter() interrupt 0 //ISR declaration
{unsigned int
nums[10]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
//number codes for SSD
P0=nums[i]; //move the ith element of array to port 0
i++;
//next number code address
}
void main() //main loop
{i=0;
IE=0x81; //enable externam interrupt 0
IT0=1; //edge-triggered
P2=0x08; //select SSD
while(1); //idle loop
}

You might also like