Interrupts in The 8051 Microcontroller
Interrupts in The 8051 Microcontroller
Interrupts are a mechanism in the 8051 microcontroller that allow it to respond to external
events or internal triggers, temporarily suspending the main program's execution to handle
these events. This provides a way to handle time-critical tasks or unexpected events without
constantly polling for them in the main program loop.
Interrupt Sources
The 8051 has five hardware resources that can generate interrupt requests:
Each interrupt source has a dedicated address in program memory where its corresponding
interrupt service routine (ISR) is located. When an interrupt occurs, the program counter
(PC) is pushed onto the stack, and the CPU jumps to the ISR's address to execute the code
that handles the interrupt.
Interrupts can be individually enabled or disabled using the Interrupt Enable (IE) register.
Additionally, each interrupt can be assigned a priority level (high or low) using the Interrupt
Priority (IP) register. High-priority interrupts can interrupt low-priority interrupt service
routines, but not vice versa.
Context Saving: The current program counter (PC) is pushed onto the stack.
👇
Vectoring to ISR: The CPU jumps to the starting address of the ISR for the triggered
interrupt.
👇
Return from Interrupt (RETI): The RETI instruction is executed at the end of the ISR, restoring
the PC from the stack and resuming the main program.
Essential reading: 2.8 INTERRUPT SYSTEM of the INTEL 8051 Architectural Specification
Chapter 10 in suppliementary material
What are the five hardware resources that can generate an interrupt request in the 8051 and
list the vector address (sources).