Nothing Special   »   [go: up one dir, main page]

8051 Interrupts

Download as pdf or txt
Download as pdf or txt
You are on page 1of 16

INTERRUPTS

• An interrupt is an external or internal event that


interrupts the microcontroller to inform it that a device
needs its service

• A single microcontroller can serve several devices by two


ways:
1. Interrupt
2. Polling

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.

• Jumps to a fixed location in memory depend on type of


interrupt

• Starts to execute the interrupt service routine until


RETI (return from interrupt)

• Upon executing the RETI the microcontroller returns to the


place where it was interrupted. Get pop PC from stack
• Original 8051 has 6 sources of interrupts
– Reset (RST)
– Timer 0 overflow (TF0)
– Timer 1 overflow (TF1)
– External Interrupt 0 (INT0)
– External Interrupt 1 (INT1)
– Serial Port events (RI+TI)
• {Reception/Transmission of Serial Character}
8051 Interrupt Vectors

8
8051 Interrupt related Registers
• The various registers associated with the use of
interrupts are:

– TCON - Edge and Type bits for External Interrupts 0/1

– SCON - RI and TI interrupt flags for


RS232 {SERIAL COMMUNICATION}

– 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.

MOV IE,#08h • ES : Enable Serial port interrupt.


or
SETB ET1
• ET1 : Enable Timer 1 control bit.
• EX1 : Enable External 1 interrupt.
• ET0 : Enable Timer 0 control bit.
• EX0 : Enable External 0 interrupt.

11
Interrupt Priority

12
Interrupt Priority (IP)
Register

Reserved
PS PT1 PX1 PT0 PX0

Serial Port
Timer 1 Pin INT 0 Pin

INT 1 Pin Timer 0 Pin


Priority bit=1 assigns high priority
Priority bit=0 assigns low priority

13
64
8
Thank you

You might also like