8051 Interrupts tutorials: Architecture, Priority, Vector Table & Programs

8051 Interrupt

8051 interrupts are a core feature that enable real-time event handling in embedded systems. Instead of continuously polling peripherals, the microcontroller responds immediately when a specific event occurs. This improves system efficiency, response time, and reliability. In this article, you will learn the complete 8051 interrupt architecture, types of interrupts, interrupt priority, vector table, and working mechanism with assembly programs and real-time applications.

Interrupts in the 8051 microcontroller allow the CPU to respond instantly to real-time events without continuous polling. Using the IE and IP registers, the controller manages interrupt enabling and priority efficiently. This enables faster, reliable, and power-efficient embedded system operation.

What You Will Learn in 8051 Interrupts

  • What interrupts are in the 8051 microcontroller
  • Types of interrupts and their vector addresses
  • 8051 interrupt architecture and handling mechanism
  • Interrupt priority using the IP register
  • Timer0 and Timer1 interrupt programs
  • Real-time applications of 8051 interrupts

Types of Interrupts in 8051

The 8051 microcontroller supports five interrupt sources.

InterruptSourceTrigger ConditionVector AddressFlag
INT0P3.2Falling edge / Low level0003HIE0
Timer0TF0Timer overflow000BHTF0
INT1P3.3Falling edge / Low level0013HIE1
Timer1TF1Timer overflow001BHTF1
SerialRI / TIData receive / transmit0023HRI / TI

8051 Interrupt Architecture

  • Interrupt flags
  • Interrupt Enable (IE) register
  • Interrupt Priority (IP) register
  • Interrupt vector table
  • Stack
  • Interrupt Service Routine (ISR)

8051 interrupt diagram

Start Your Training Journey Today

Step-by-Step Working of 8051 Interrupts

1. Interrupt Flag is Set

When an event occurs, the corresponding flag bit is set automatically.

EventFlag Bit
External INT0IE0
Timer0 overflowTF0
External INT1IE1
Timer1 overflowTF1
Serial Rx / TxRI / TI

2. Global Interrupt Enable (EA Bit)

The CPU checks the EA bit (IE.7):
EA = 1 → Interrupts enabled
EA = 0 → All interrupts disabled

3. Individual Interrupt Enable Check

InterruptEnable Bit
INT0EX0
Timer0ET0
INT1EX1
Timer1ET1
SerialES

4. Interrupt Priority Check (IP Register)

If multiple interrupts occur simultaneously:
IP bit = 1 → High priority
IP bit = 0 → Low priority
High-priority interrupts can interrupt low-priority ISRs.

5. Saving Program Counter

The current Program Counter (PC) value is pushed onto the stack.

6. Jump to Interrupt Vector Address

InterruptVector Address
INT00003H
Timer0000BH
INT10013H
Timer1001BH
Serial0023H

7. Execution of ISR

The Interrupt Service Routine executes the required task.

8. RETI – Return from Interrupt

The RETI instruction:
Pops the saved PC from the stack
Returns control to the main program

Explore Courses - Learn More

 

Interrupt Handling Mechanism in 8051

StepOperation
1Event occurs and flag is set
2CPU checks IE register
3Priority is verified
4Program Counter saved
5CPU jumps to ISR
6ISR executes
7RETI returns control

Programming Example – Timer0 Interrupt

ORG 0000H
LJMP MAIN

ORG 000BH
LJMP TIMER_ISR

MAIN:
MOV TMOD, #01H
MOV TH0, #0FCH
MOV TL0, #18H
SETB TR0
SETB ET0
SETB EA
SJMP $

TIMER_ISR:
CLR TF0
MOV TH0, #0FCH
MOV TL0, #18H
RETI
END

Solved Example – LED Blinking Using Timer0 Interrupt

ORG 0000H
LJMP MAIN

ORG 000BH
LJMP TIMER0_ISR

MAIN:
MOV TMOD, #01H
MOV TH0, #0FCH
MOV TL0, #018H
SETB P1.0
SETB ET0
SETB EA
SETB TR0

HERE:
SJMP HERE

TIMER0_ISR:
CLR TR0
CLR TF0
MOV TH0, #0FCH
MOV TL0, #018H
CPL P1.0
SETB TR0
RETI
END

Real-Time Example – Frequency Measurement Using Timer1 Interrupt

ORG 0000H
LJMP MAIN

ORG 001BH
LJMP TIMER1_ISR

MAIN:
MOV TMOD, #50H
MOV TH1, #00H
MOV TL1, #00H
SETB ET1
SETB EA
SETB TR1

HERE:
SJMP HERE

TIMER1_ISR:
CLR TR1
MOV P1, TL1
MOV TH1, #00H
MOV TL1, #00H
SETB TR1
RETI
END

Real-Time Applications of 8051 Interrupts

  • Digital clocks
  • LED blinking systems
  • Industrial timing systems
  • RPM and speed measurement
  • Task scheduling and multitasking

Advantages of Using Interrupts in 8051

  • Faster response time
  • Efficient CPU utilization
  • No continuous polling
  • Ideal for real-time systems

Conclusion

Interrupts are the backbone of real-time embedded systems. By using the interrupt structure, IE register, IP register, vector table, and ISR routines, the 8051 microcontroller can respond instantly to external and internal events without wasting CPU resources. Mastering 8051 interrupts is essential for building reliable, efficient, and industry-ready embedded applications.

Talk to Academic Advisor

Frequently Asked Questions on 8051 Interrupts

Interrupts allow immediate response to events without continuous polling, making systems faster and efficient.

The IE register enables or disables individual interrupts and controls the global interrupt enable.

The IP register assigns priority levels to interrupts when multiple interrupts occur.

The interrupt with higher priority, as defined by the IP register, is serviced first.

Author

Embedded Systems Trainer – IIES

Updated On: 29-12-25