You are currently viewing How to Interface Interrupts with 8051 Development Board

How to Interface Interrupts with 8051 Development Board

Spread the love

8051 Development Board

The 8051 Development Board is specifically designed to help students to master the required skills in the area of embedded systems. The kit is designed in such way that all the possible features of the microcontroller will be easily used by the students. The kit supports in system programming (ISP) which is done through serial port.

NXP’s 8051 (AT89V51RD2), 8051 Development Kit is proposed to smooth the progress of developing and debugging of various designs encompassing of speed 8-bit Microcontrollers.

External Interrupts

An interrupt caused by an external source such as the computer operator, external sensor or monitoring device, or another computer. Interrupts are special events that require immediate attention.

Interfacing External Interrupts

Fig. 1 shows how to interface the External Interrupt to microcontrollerInterrupts cause the processor to cease the running task to serve a special task for which the interrupt event had occurred. After the special task is over, the processor resumes performing the original task.

The processor can also serve these events by polling method. But polling is an inefficient technique as compared to interrupts. In the polling method, the processor has to continuously wait for the event signal. Thus it always remains busy using extra resources.

How to Interface Interrupts with 8051 Development Board
Fig. 1 Interfacing External Interrupts to Microcontroller

Interfacing External Interrupts with 8051

We now want to display some messages in PC when occur an external interrupt signal in 8051 Development Board. The Interrupt signal is occurred by using switches. When the switch is pressed to LOW, then the external interrupt is occurred.

The Vectored Interrupt Controller (VIC) takes 5 interrupt request inputs and programmable assigns them into 3 categories, timer, external and serial interrupts.

The 8051 Development Board has two numbers of External Interrupts, connected with I/O Port lines (P0.14 & P0.15) as switches.

Pin Assignment with 8051

Circuit Diagram to Interface Ext-Interrupt with 8051

Source Code

The Interfacing External Interrupt with 8051 program is very simple and straight forward, that accessed by using switches. When the two external interrupts occurring, some messages are displayed in PC through serial port at 9600 baud rate. The C programs are written in Keil software.

C Program to interface Ext-Interrupt using 8051


Title : Program to interface an external Interrupt



// Define LPC2148 Header File int volatile EINT2 = 0;

void ExtInt_Serve2(void)__irq;

void ExtInt_Serve1(void)__irq



EXTINT |= 2;

VICVectAddr = 1;


void ExtInt_Serve2(void)__irq



EXTINT |= 4;

VICVectAddr = 0;


void main(void)




//Initialize Interrupt 1 ExtInt_Init2();

//Initialize Interrupt 2 putchar(0x0C);

printf ("***************** External Interrupt Demo ***************************\n\n\r");


printf (">>> Press Interrupt Keys SW2(INT1) and SW3(INT2) for Output... \n\n\n\r");





printf("INT1 Generated : %d | INT2 Generated : %d \r", EINT1, EINT2); DelayMs(500);



void ExtInt_Init2(void)



//Edge sensitive mode on EINT2 EXTPOLAR = 0;

//Falling Edge Sensitive PINSEL0 |= 0x80000000;

//Enable EINT2 on P0.15 VICVectCntl1 = 0x20 | 16;

// 16 is index of EINT2 VICVectAddr1 = (unsigned long) ExtInt_Serve2;

VICIntEnable |= 1<<16;

//Enable EINT2


void ExtInt_Init1(void)



//Edge sensitive mode on EINT1 EXTPOLAR = 0;

//Falling Edge Sensitive PINSEL0 |= 0x20000000;

//Enable EINT2 on P0.14 VICVectCntl0 = 0x20 | 15;

//15 is index of EINT1 VICVectAddr0 = (unsigned long) ExtInt_Serve1;

VICIntEnable |= 1<<15;

//Enable EINT1


void Serial_Init(void)


PINSEL0 |= 0X00000005;

//Enable Txd0 and Rxd0 U0LCR = 0x00000083;

//8-bit data,1-stop bit U0DLL = 0x00000061;

//XTAL = 12MHz U0LCR = 0x00000003;

//DLAB = 0;


void DelayMs(unsigned int count)


unsigned int i,j;






Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.