
Interrupts in 8051 Microcontroller (AT89C52)
Interrupts in 8051
- Complete Video Course on AT89C52 Microcontroller
- Introduction
- What is an Interrupt?
- Types of Interrupts in AT89C52
- Interrupt Registers
- Example: External Interrupt 0 Using AT89C52
- Interrupt Vector Table
- Circuit Design in Proteus
- Applications
- Summary
- Learn More
- Complete Video Course on AT89C52 Microcontroller
- 💬Frequently Asked Questions (FAQ)
Would you like to join our comprehensive practical video course on the AT89C52 Microcontroller?
Complete Video Course on AT89C52 Microcontroller

Introduction
Interrupts in 8051: Interrupts are essential in embedded systems because they allow the microcontroller to respond immediately to external or internal events without continuously polling for changes. The AT89C52 microcontroller, based on the 8051 architecture, supports a well-structured interrupt system that enhances real-time performance. In this tutorial, you’ll learn about the interrupt structure, vector addresses, registers, and programming for handling interrupts in AT89C52 using Embedded C in Keil µVision.
What is an Interrupt?
An interrupt is a signal that temporarily halts the main program execution and transfers control to a special routine known as the Interrupt Service Routine (ISR). Once the ISR is executed, the program returns to its previous operation.
Benefits of Using Interrupts:
- Improves system response time
- Reduces CPU overhead (no continuous polling)
- Enables multitasking and event-driven programming
Types of Interrupts in AT89C52
The AT89C52 microcontroller supports five interrupt sources (hardware and software-based):
| Interrupt Source | Interrupt Flag | Vector Address | Priority | Description |
|---|---|---|---|---|
| External Interrupt 0 | IE0 | 0003H | Low/High | Triggered by a falling edge or low level on INT0 (P3.2) |
| Timer 0 Overflow | TF0 | 000BH | Low/High | Generated when Timer 0 overflows |
| External Interrupt 1 | IE1 | 0013H | Low/High | Triggered by a falling edge or low level on INT1 (P3.3) |
| Timer 1 Overflow | TF1 | 001BH | Low/High | Generated when Timer 1 overflows |
| Serial Port Interrupt | TI/RI | 0023H | Low/High | Occurs when serial data transmission or reception is complete |
Interrupts in 8051
Interrupt Registers
Interrupt Enable (IE) Register
The IE register enables or disables specific interrupts.
| Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|---|---|---|---|---|---|---|---|---|
| Function | EA | — | — | ES | ET1 | EX1 | ET0 | EX0 |
- EA (Bit 7): Global Interrupt Enable (1 = enable all, 0 = disable all)
- ES: Enables/disables Serial Port Interrupt
- ET1: Enables/disables Timer 1 Interrupt
- EX1: Enables/disables External Interrupt 1
- ET0: Enables/disables Timer 0 Interrupt
- EX0: Enables/disables External Interrupt 0
Interrupt Priority (IP) Register
The IP register defines which interrupts have higher priority when multiple interrupts occur simultaneously.
| Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|---|---|---|---|---|---|---|---|---|
| Function | — | — | — | PS | PT1 | PX1 | PT0 | PX0 |
- PX0: Priority bit for External Interrupt 0
- PT0: Priority bit for Timer 0
- PX1: Priority bit for External Interrupt 1
- PT1: Priority bit for Timer 1
- PS: Priority bit for Serial Port
When a priority bit is set to 1, that interrupt is assigned high priority; otherwise, it has low priority.
Example: External Interrupt 0 Using AT89C52
This example turns ON an LED when an external interrupt (INT0) occurs.
Circuit Description:
- Connect a push button to P3.2 (INT0) pin.
- Connect an LED to P1.0 with a 220Ω resistor.
- The interrupt triggers when the button is pressed.
#include <reg51.h>
sbit LED = P1^0;
void delay(unsigned int t)
{
unsigned int i, j;
for(i=0;i<t;i++)
for(j=0;j<1275;j++);
}
void ext_int0(void) interrupt 0 // ISR for External Interrupt 0
{
LED = ~LED; // Toggle LED state
delay(200);
}
void main()
{
LED = 0; // Initialize LED OFF
IE = 0x81; // Enable External Interrupt 0 (EX0=1, EA=1)
IT0 = 1; // Set edge-triggered interrupt (falling edge)
while(1); // Wait for interrupt
}CWorking Explanation
- IT0 = 1 configures External Interrupt 0 to trigger on a falling edge.
- IE = 0x81 enables the external interrupt and the global interrupt system.
- When the button connected to INT0 is pressed, the ISR (Interrupt Service Routine) is executed.
- The LED toggles its state inside the ISR.
Interrupts in 8051
Interrupt Vector Table
| Interrupt Source | Vector Address |
|---|---|
| External Interrupt 0 | 0003H |
| Timer 0 Overflow | 000BH |
| External Interrupt 1 | 0013H |
| Timer 1 Overflow | 001BH |
| Serial Port | 0023H |
The compiler automatically places the ISR address at these vector locations during compilation.
Circuit Design in Proteus
In Proteus, place:
- AT89C52 microcontroller
- Push button (for INT0) connected to P3.2
- LED (through 220Ω resistor) connected to P1.0
- 5V power supply and ground connections
Run the simulation. When you press the button, the LED toggles its state, confirming the interrupt’s operation.
Applications
- Real-time event detection
- Switch debouncing
- External sensor triggering (IR, ultrasonic, etc.)
- Serial data reception
- Timer-based periodic task execution
Summary
The interrupt system of AT89C52 allows the processor to react to important events instantly. Understanding how to configure the IE, IP, and TCON registers helps in writing efficient, event-driven programs. External interrupts can be used for user input, while timer and serial interrupts enable precise timing and data handling.
Learn More
Do you want to go beyond just configuration and build real embedded projects?
🎓 Join our Complete Practical Video Course to Master the AT89C52 Microcontroller.
Get step-by-step guidance on Timers, Interrupts, UART, I/O Interfacing, ADC (using ADC0804), and I²C/SPI (Software Implementation) — with real circuits, simulations, and hardware demonstrations!
Complete Video Course on AT89C52 Microcontroller

Downloading and Installing Keil µVision IDE
- Visit the official Keil website at https://www.keil.com or KEIL IDE
- Navigate to the Downloads → C51 Compiler section.
- Register (if required) and download the latest version of Keil µVision for 8051 (C51).
- Run the installer and follow the on-screen instructions.
- Once installed, launch the Keil µVision IDE from the Start Menu.


