8051 Interrupts
8051 Interrupts
8051 Interrupts
2
Interrupt
– Upon receiving an interrupt signal, the
microcontroller interrupts whatever it is doing
and serves the device.
– The program which is associated with the
interrupt is called the interrupt service routine
(ISR) .
3
Interrupt Vs Polling
1. Interrupts
Whenever any device needs its service, the device
notifies the microcontroller by sending it an interrupt signal.
Upon receiving an interrupt signal, the microcontroller interrupts
whatever it is doing and serves the device.
The program which is associated with the interrupt is called
the
interrupt service routine (ISR) or interrupt handler.
2. Polling
The microcontroller continuously monitors the status of a given
device.
When the conditions met, it performs the service.
After that, it moves on to monitor the next device until every one is
serviced.
Steps in Executing an Interrupt
1.It finishes the instruction it is executing and saves the address
of the next instruction (PC) on the stack.
2.It also saves the current status of all the interrupts internally
(i.e: not on the stack).
3.It jumps to a fixed location in memory, called the
interrupt vector table, that holds the address of the ISR.
4.The microcontroller gets the address of the ISR from
the interrupt vector table and jumps to it.
5.It starts to execute the interrupt service subroutine until
it reaches the last instruction of the subroutine which is
RETI (return from interrupt).
6.Upon executing the RETI instruction, the microcontroller
returns to the place where it was interrupted.
Steps in executing an interrupt
• Finish current instruction and saves the PC on stack.
8
8051 Interrupt related Registers
• The various registers associated with the use of
interrupts are:
– IE - interrupt Enable
– IP - Interrupts priority
9
Enabling and Disabling an Interrupt
• The register called IE (interrupt enable) that is
responsible for enabling (unmasking) and disabling
(masking) the interrupts.
10
Interrupt Enable (IE) Register
--
• EA : Global enable/disable.
• --- : Reserved for additional interrupt hardware.
11
Interrupt Priority
12
Interrupt Priority (IP)
Register
Reserved
PS PT1 PX1 PT0 PX0
Serial Port
Timer 1 Pin INT 0 Pin
13
64
8
Thank you