SlideShare a Scribd company logo
Module 5: INTERRUPTS PROGRAMMING
INTERRUPTS
Interrupts vs. Polling
 An interrupt is an external or internal event that interrupts the microcontroller to inform
a microcontroller that a device needs its service
 A single microcontroller can serve several devices by two ways
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
Interrupt Method Polling Method
Microcontroller time is used efficiently Microcontroller time is not used
efficiently Ex: JNB TFx, target
Priority can be assigned to the devices Priority cannot be assigned. The devices
are served in round robin fashion
Microcontroller can enable/disable the
interrupts
It is not possible in polling method
Interrupts vs. Polling
Six Interrupts in 8051
Six interrupts are allocated as follows
• Reset –power-up reset
• Two interrupts are set aside for the timers: one for timer 0 and one
for timer 1
• Two interrupts are set aside for hardware external interrupts
 P3.2 and P3.3 are for the external hardware interrupts INT0 (or
EX1), and INT1 (or EX2)
• Serial communication has a single interrupt that belongs to both
receive and transfer(RI and TI)
Interrupt Service Routine
For every interrupt, there must be an interrupt service
routine (ISR), or interrupt handler
• When an interrupt is invoked, the microcontroller runs the
interrupt service routine
• For every interrupt, there is a fixed location in memory that
holds the address of its ISR
• The group of memory locations set aside to hold the
addresses of ISR’s is called interrupt vector table
hardware interrupts in 8051 microcontroller
Steps in Executing an Interrupt
Upon activation of an interrupt, the microcontroller goes through the following steps
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
• It starts to execute the interrupt service subroutine until it reaches the last instruction of the
subroutine which is RETI (return from interrupt)
5.Upon executing the RETI instruction, the microcontroller returns to the place where it was
interrupted
• First, it gets the program counter (PC) address from the stack by popping the top two bytes of
the stack into the PC
• Then it starts to execute from that address

More Related Content

PPTX
Interrupts in 8051
PPTX
Interrupts of 8051 microcontroller.newpp
PPTX
Micro controller 8051 Interrupts
PPTX
Interrupts programming in embedded C using 8051
PPTX
Interrupt 8085
PPTX
Mc module5 ppt_msj
PDF
Microcontroller 8085.ppt mmmmmmmmmmmmmmmmmm
PPTX
Interrupts
Interrupts in 8051
Interrupts of 8051 microcontroller.newpp
Micro controller 8051 Interrupts
Interrupts programming in embedded C using 8051
Interrupt 8085
Mc module5 ppt_msj
Microcontroller 8085.ppt mmmmmmmmmmmmmmmmmm
Interrupts

Similar to hardware interrupts in 8051 microcontroller (20)

PPTX
Unit 3 timer and counter and there application .pptx
PPTX
Interrupt in 8051
PPTX
Module 5 Part 1-IO ORGANIZATION IMP.pptx
PPTX
INTERRUPT ROUTINES IN RTOS EN VIRONMENT HANDELING OF INTERRUPT SOURCE CALLS
PPTX
3 4- computer organization and archietecture- COA- CO- Computer organization
PPTX
Interrupts of 8085
PPT
Interrupt
PPTX
Chapter 3 part 2 Interconnections Computer organization
PPT
Interrupt
PPTX
Embedded systems, lesson 16
PDF
Interrupts in CPU
PPT
Types of Interrupts with details Mi ppt
PPT
Interrupts for PIC18
PPTX
MICROPROCESSOR_Anurad gor systej ndjksauduiha MAITY.pptx
PDF
5a_8085 Interrupts & Direct Memory Access_pptx.pdf
PPTX
Interrupts on 8086 microprocessor by vijay kumar.k
PPTX
operating system presentation use critical fifo
PPTX
LECTURE_8 Interrupts.pptx hello and thanks for the University of
PPTX
Chapter 4 - Interrupts of 8085
PPT
03_Top Level View of Computer Function and Interconnection.ppt
Unit 3 timer and counter and there application .pptx
Interrupt in 8051
Module 5 Part 1-IO ORGANIZATION IMP.pptx
INTERRUPT ROUTINES IN RTOS EN VIRONMENT HANDELING OF INTERRUPT SOURCE CALLS
3 4- computer organization and archietecture- COA- CO- Computer organization
Interrupts of 8085
Interrupt
Chapter 3 part 2 Interconnections Computer organization
Interrupt
Embedded systems, lesson 16
Interrupts in CPU
Types of Interrupts with details Mi ppt
Interrupts for PIC18
MICROPROCESSOR_Anurad gor systej ndjksauduiha MAITY.pptx
5a_8085 Interrupts & Direct Memory Access_pptx.pdf
Interrupts on 8086 microprocessor by vijay kumar.k
operating system presentation use critical fifo
LECTURE_8 Interrupts.pptx hello and thanks for the University of
Chapter 4 - Interrupts of 8085
03_Top Level View of Computer Function and Interconnection.ppt
Ad

Recently uploaded (20)

PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PPTX
Strings in CPP - Strings in C++ are sequences of characters used to store and...
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PPTX
Lecture Notes Electrical Wiring System Components
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PPTX
Welding lecture in detail for understanding
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PDF
Arduino robotics embedded978-1-4302-3184-4.pdf
PDF
Well-logging-methods_new................
PDF
composite construction of structures.pdf
PPTX
Sustainable Sites - Green Building Construction
DOCX
573137875-Attendance-Management-System-original
PDF
PPT on Performance Review to get promotions
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PDF
Digital Logic Computer Design lecture notes
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
Embodied AI: Ushering in the Next Era of Intelligent Systems
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
Strings in CPP - Strings in C++ are sequences of characters used to store and...
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
Lecture Notes Electrical Wiring System Components
CYBER-CRIMES AND SECURITY A guide to understanding
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
Welding lecture in detail for understanding
Model Code of Practice - Construction Work - 21102022 .pdf
Arduino robotics embedded978-1-4302-3184-4.pdf
Well-logging-methods_new................
composite construction of structures.pdf
Sustainable Sites - Green Building Construction
573137875-Attendance-Management-System-original
PPT on Performance Review to get promotions
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
Digital Logic Computer Design lecture notes
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
Ad

hardware interrupts in 8051 microcontroller

  • 1. Module 5: INTERRUPTS PROGRAMMING
  • 2. INTERRUPTS Interrupts vs. Polling  An interrupt is an external or internal event that interrupts the microcontroller to inform a microcontroller that a device needs its service  A single microcontroller can serve several devices by two ways 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
  • 3. Interrupt Method Polling Method Microcontroller time is used efficiently Microcontroller time is not used efficiently Ex: JNB TFx, target Priority can be assigned to the devices Priority cannot be assigned. The devices are served in round robin fashion Microcontroller can enable/disable the interrupts It is not possible in polling method Interrupts vs. Polling
  • 4. Six Interrupts in 8051 Six interrupts are allocated as follows • Reset –power-up reset • Two interrupts are set aside for the timers: one for timer 0 and one for timer 1 • Two interrupts are set aside for hardware external interrupts  P3.2 and P3.3 are for the external hardware interrupts INT0 (or EX1), and INT1 (or EX2) • Serial communication has a single interrupt that belongs to both receive and transfer(RI and TI)
  • 5. Interrupt Service Routine For every interrupt, there must be an interrupt service routine (ISR), or interrupt handler • When an interrupt is invoked, the microcontroller runs the interrupt service routine • For every interrupt, there is a fixed location in memory that holds the address of its ISR • The group of memory locations set aside to hold the addresses of ISR’s is called interrupt vector table
  • 7. Steps in Executing an Interrupt Upon activation of an interrupt, the microcontroller goes through the following steps 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 • It starts to execute the interrupt service subroutine until it reaches the last instruction of the subroutine which is RETI (return from interrupt) 5.Upon executing the RETI instruction, the microcontroller returns to the place where it was interrupted • First, it gets the program counter (PC) address from the stack by popping the top two bytes of the stack into the PC • Then it starts to execute from that address