SlideShare a Scribd company logo
1 of 19
Biomedical Engineering
B.E III Year
Embedded Systems
Unit-TWO
Microcontroller And Programming
Lesson - 7
8051-Microcontoller Interrupts
 Interrupts Vs. Polling:
• A single microcontroller can serve several devices.
• There are two ways to do that: ‘Interrupt or Polling’
• In the ‘Interrupt’ method, 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 associated with the interrupt is called “Interrupt
Service Routine (ISR) or Interrupt Handler”.
Cont.
• In ‘Polling’ the microcontroller continuously monitors the
status of a given device, when the status condition is met, it
performs the service.
• After that, it moves on to monitor the next device until each
one is serviced.
• Although polling can monitor the status of several devices and
serve each of them as certain conditions are met, it is not an
efficient use of the microcontroller.
• The advantage of interrupt is that the microcontroller can serve
many devices (not all at the same time) each device can get the
attention of the microcontroller based on the priority assigned
to it.
Cont.
• The polling method cannot assign priority since it checks all
devices in a round-robin fashion.
• More importantly, in the interrupt method the microcontroller
can also ignore (mask) a device request for service, this is
again not possible with the polling method.
• The most important reason that the interrupt method is
preferable is that the polling method wastes much of the
microcontroller time by polling devices that do not need
service.
 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
ISR.
• For every interrupt, there is a fixed location in the memory that
holds the address of its ISR.
• The group of memory locations set aside to hold the addresses
of ISR’s is called the ‘Interrupt Vector Table’.
Interrupt Vector Table for 8051-Microcontroller:
Interrupt ROM Location
(Hex)
Pin Flag Clearing
RESET 0000 9 Auto
Ext. Hardware
Interrupt 0 (INT0)
0003 P 3.2 (12) Auto
Timer 0 Interrupt
(TFO)
000B Auto
Ext. Hardware
Interrupt 1 (INT1)
0013 P 3.3 (13) Auto
Timer 1 Interrupt
(TF1)
001B Auto
Serial
Communication
Interrupt (RI & TI)
0023 Programmer Clears
it
 Steps In Executing an Interrupt:
• Upon activation of an interrupt, the microcontroller goes
through the following steps.
• It finishes the instruction it is executing and saves the address
of the next instruction (P.C) on the stack.
• It also saves the current status of all the interrupts internally.
• It jumps to a fixed location in memory called the interrupt
vector table that holds the address of the Interrupt Service
Routine.
• 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 inst. Of the subroutine, which is RETI (Return
from Interrupt).
Cont.
• Upon executing the RETI instruction, the microcontroller
returns to the place where it was interrupted.
• First it gets the (P.C) address from the stack by popping the top
two bytes of the stack into the P.C. then it starts to execute
from that address.
 Six Interrupts In 8051:
• In reality only five interrupts are available to the user in the
8051, but many manufacturers data sheet state that there are
six interrupts since they include RESET.
• RESET, when the reset pin is activated, the 8051 jumps to
address location 0000. this is power up-reset.
• Two interrupts are set aside for the timers: one for timer 0 and
one for timer 1, memory locations 000BH & 001BH in the
interrupt vector table belongs to Timer 0 & Timer 1.
• Two interrupts are set aside for hardware, external hardware
interrupt. Pin no. 12 and 13 in port 3are for the external
hardware interrupt INT0 & INT1. These external interrupts are
also referred to as EX1 & EX2, memory locations 0003H and
0013H are assigned to INT0 & INT1.
Cont.
• Serial communication has a single interrupt that belongs to
both receive and transmit. The interrupt vector table location
0023H belongs to this interrupt.
 Enabling & Disabling An Interrupt:
• Upon reset, all interrupts are disabled (masked), meaning that
none will be responded to by the microcontroller if they are
activated.
• The interrupts must be enabled by software in order for the
microcontroller to respond to them.
• There is a register called IE (Interrupt Enable) that is
responsible for enabling (unmasking) and disabling (masking)
the interrupt. IE is a bit addressable register.
 I.E (Interrupt Enable) Register:
Cont.
 Steps In Enabling an Interrupt:
• Bit D7 of the Interrupt Priority Register (EA) must be set to
high to allow the rest of register to take effect.
• If EA=1, interrupts are enabled and will be responded to if
their corresponding bits in I.E are high.
• If EA=0, no interrupt will be responded to, even if the
associated bit in the I.E register is high.
Cont.
 Interrupt Priority (I.P) SFR:
Bit Symbol Function
7 ------ NOT IMPLEMENTED
6 ------ NOT IMPLEMENTED
5 PT2 RESERVED FOR FUTURE USE
4 PS PRIORITY OF SERIAL PORT INTERRUPT
3 PT1 PRIORITY OF TIMER 1 OVERFLOW INTERRUPT
2 PX1 PRIORITY OF EXTERNAL INTERRUPT 1
1 PT0 PRIORITY OF TIMER 0 OVERFLOW INTERRUPT
0 PX0 PRIORITY OF EXTERNAL INTERRUPT 0
 Timer Flag Interrupt:
• When a Timer/Counter overflows, the corresponding timer
flag, TF0 or TF1 is set to 1.
• The flag is cleared to 0, when the resulting interrupt generates
a program call to the appropriate timer subroutine in memory.
 Serial Port Interrupt:
• If a data is received, an interrupt bit, R1 is set to 1in the SCON
register.
• When a data byte has been transmitted on interrupt bit, T1, is
set in SCON.
• These are Ored together to provide a single interrupt to the
processor, the serial port interrupt.
• The program that handles serial data communication must
reset R1 or T1 to 0, to enable the next data communication
operation.
Cont.
 External Interrupts:
• Pins INT0 & INT1 are used by external circuitry.
• Inputs on these pins can set the interrupt flags IE0 & IE1 in the
TCON register to 1 by two different methods.
• The IEX flags may be set when the INTX pin signal reaches a
low level, or the flags may be set when a high-to-low
transition takes place on the INTX pin.
• Bits IT0 & IT1 in TCON, program the INTX pins for low-
level interrupt.
• When set to 0 and program the INTX pins for transition
interrupt when set to 1
Cont.
 RESET:
• A reset can be considered to be the ultimate interrupt because
the program may not block the action of the voltage on the
RST pin.
• This type of interrupt is often called non-maskable, because no
combination of bits in any register can stop or mask the reset
action.
• Whenever a high level is applied to the RST pin, the 8051
enters a reset condition.
• After the RST pin is bought low, the internal registers will
have the different values.
• Internal RAM contents may change during reset.
• Register bank 0 is selected on reset as all bits in PSW are 0.
 Interrupt Priority:
• Register IP bits determine if any interrupt is to have a high or
low priority.
• Bits set to 1 give the accompanying interrupt a high priority, a
0 assigns a low priority.
• Interrupts with a high priority can interrupt another interrupt
with a lower priority, the lower priority interrupt continues
after the higher is finished.
• If two interrupts with the same priority occurs at the same
time, then they have the following ranking:
1. IE0
2. TF0
3. IE1
4. TF1
5. Serial = R1 or T1
Thank-You
 Learning outcomes of today’s lesson:
• Interrupt vs. Polling
• Interrupt Service Routine
• Interrupt Vector Table
• Steps in Executing an Interrupt
• 8051 Interrupts
• Enabling & Disabling an Interrupt
• Interrupt Enable (I.E) Register
• Interrupt Priority

More Related Content

What's hot

Interrupts on 8086 microprocessor by vijay kumar.k
Interrupts on 8086 microprocessor by vijay kumar.kInterrupts on 8086 microprocessor by vijay kumar.k
Interrupts on 8086 microprocessor by vijay kumar.kVijay Kumar
 
Interrupt programming with 8051 microcontroller
Interrupt programming with 8051  microcontrollerInterrupt programming with 8051  microcontroller
Interrupt programming with 8051 microcontrollerAnkit Bhatnagar
 
Types of Interrupts with details Mi ppt
Types of Interrupts with details Mi pptTypes of Interrupts with details Mi ppt
Types of Interrupts with details Mi pptsanjaytron
 
Interrupt of 8085
Interrupt of 8085Interrupt of 8085
Interrupt of 8085Nitin Ahire
 
Microprocessor Architecture 4
Microprocessor Architecture  4Microprocessor Architecture  4
Microprocessor Architecture 4Dr.YNM
 
Interrupts of 8085
Interrupts of 8085Interrupts of 8085
Interrupts of 8085ShivamSood22
 
8051 microcontroller and it’s interface
8051 microcontroller and it’s interface8051 microcontroller and it’s interface
8051 microcontroller and it’s interfaceAbhishek Choksi
 
Keypad Interfacing with 8051 Microcontroller
Keypad Interfacing with 8051 MicrocontrollerKeypad Interfacing with 8051 Microcontroller
Keypad Interfacing with 8051 MicrocontrollerSudhanshu Janwadkar
 
1206 Interrupts Of 8085
1206 Interrupts Of 80851206 Interrupts Of 8085
1206 Interrupts Of 8085techbed
 

What's hot (19)

Interrupts on 8086 microprocessor by vijay kumar.k
Interrupts on 8086 microprocessor by vijay kumar.kInterrupts on 8086 microprocessor by vijay kumar.k
Interrupts on 8086 microprocessor by vijay kumar.k
 
Hardware View of Intel 8051
Hardware View of Intel 8051Hardware View of Intel 8051
Hardware View of Intel 8051
 
Interrupt 8085
Interrupt 8085Interrupt 8085
Interrupt 8085
 
Interrupt programming with 8051 microcontroller
Interrupt programming with 8051  microcontrollerInterrupt programming with 8051  microcontroller
Interrupt programming with 8051 microcontroller
 
8085 interrupts
8085 interrupts8085 interrupts
8085 interrupts
 
Interrupts of microprocessor 8085
Interrupts of microprocessor  8085Interrupts of microprocessor  8085
Interrupts of microprocessor 8085
 
8051 interrupts
8051 interrupts8051 interrupts
8051 interrupts
 
Interrupts
InterruptsInterrupts
Interrupts
 
Types of Interrupts with details Mi ppt
Types of Interrupts with details Mi pptTypes of Interrupts with details Mi ppt
Types of Interrupts with details Mi ppt
 
Mc module5 ppt_msj
Mc module5 ppt_msjMc module5 ppt_msj
Mc module5 ppt_msj
 
Interrupt of 8085
Interrupt of 8085Interrupt of 8085
Interrupt of 8085
 
Microprocessor Architecture 4
Microprocessor Architecture  4Microprocessor Architecture  4
Microprocessor Architecture 4
 
Interrupt
InterruptInterrupt
Interrupt
 
Interrupts of 8085
Interrupts of 8085Interrupts of 8085
Interrupts of 8085
 
Interrupt
InterruptInterrupt
Interrupt
 
8051 microcontroller and it’s interface
8051 microcontroller and it’s interface8051 microcontroller and it’s interface
8051 microcontroller and it’s interface
 
Keypad Interfacing with 8051 Microcontroller
Keypad Interfacing with 8051 MicrocontrollerKeypad Interfacing with 8051 Microcontroller
Keypad Interfacing with 8051 Microcontroller
 
1206 Interrupts Of 8085
1206 Interrupts Of 80851206 Interrupts Of 8085
1206 Interrupts Of 8085
 
Interrupts
InterruptsInterrupts
Interrupts
 

Similar to Embedded systems, lesson 16

Interrupt programming
Interrupt programming Interrupt programming
Interrupt programming vijaydeepakg
 
Interrupt in ATMEGA328P.pptx
Interrupt in ATMEGA328P.pptxInterrupt in ATMEGA328P.pptx
Interrupt in ATMEGA328P.pptxSujalKumar73
 
unit 3 a.pptxppppppppppppppppppppppppppp
unit 3 a.pptxpppppppppppppppppppppppppppunit 3 a.pptxppppppppppppppppppppppppppp
unit 3 a.pptxpppppppppppppppppppppppppppsachin397946
 
Interrupts for PIC18
Interrupts for PIC18Interrupts for PIC18
Interrupts for PIC18raosandy11
 
8051 Microcontroller Overview by Venkatrao Ramisetti
8051 Microcontroller Overview by Venkatrao Ramisetti 8051 Microcontroller Overview by Venkatrao Ramisetti
8051 Microcontroller Overview by Venkatrao Ramisetti VenkatraoRamisetti
 
New Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptxNew Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptxRAJEEVKUMARYADAV11
 
Microprocessor 8051
Microprocessor 8051Microprocessor 8051
Microprocessor 8051Anil Maurya
 
UNIT 5 Interfacing and Mixed Signal Controller.pptx
UNIT 5 Interfacing and Mixed Signal Controller.pptxUNIT 5 Interfacing and Mixed Signal Controller.pptx
UNIT 5 Interfacing and Mixed Signal Controller.pptxGowrishankar C
 
Unit 3 timer and counter and there application .pptx
Unit 3 timer and counter and there application .pptxUnit 3 timer and counter and there application .pptx
Unit 3 timer and counter and there application .pptxnaveen088888
 
Advanced Microprocessor 6.pptx
Advanced Microprocessor 6.pptxAdvanced Microprocessor 6.pptx
Advanced Microprocessor 6.pptxShanDimantha1
 
Live B tech Projects & Industrial Training @Technogroovy
Live B tech Projects & Industrial Training @Technogroovy Live B tech Projects & Industrial Training @Technogroovy
Live B tech Projects & Industrial Training @Technogroovy Technogroovy India
 
8051 training an interactive tutorial
8051 training an interactive tutorial8051 training an interactive tutorial
8051 training an interactive tutorialFutura infotech
 
Unit 5_interrupt programming_Part 1
Unit 5_interrupt programming_Part 1Unit 5_interrupt programming_Part 1
Unit 5_interrupt programming_Part 1KanchanPatil34
 

Similar to Embedded systems, lesson 16 (20)

Interrupt programming
Interrupt programming Interrupt programming
Interrupt programming
 
Interrupt in ATMEGA328P.pptx
Interrupt in ATMEGA328P.pptxInterrupt in ATMEGA328P.pptx
Interrupt in ATMEGA328P.pptx
 
unit 3 a.pptxppppppppppppppppppppppppppp
unit 3 a.pptxpppppppppppppppppppppppppppunit 3 a.pptxppppppppppppppppppppppppppp
unit 3 a.pptxppppppppppppppppppppppppppp
 
8051 Interrupts
8051 Interrupts8051 Interrupts
8051 Interrupts
 
Interrupts for PIC18
Interrupts for PIC18Interrupts for PIC18
Interrupts for PIC18
 
8051 Microcontroller Overview by Venkatrao Ramisetti
8051 Microcontroller Overview by Venkatrao Ramisetti 8051 Microcontroller Overview by Venkatrao Ramisetti
8051 Microcontroller Overview by Venkatrao Ramisetti
 
New Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptxNew Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptx
 
Interrupt
InterruptInterrupt
Interrupt
 
Interrupt
InterruptInterrupt
Interrupt
 
Microprocessor 8051
Microprocessor 8051Microprocessor 8051
Microprocessor 8051
 
Interrupt.pptx
Interrupt.pptxInterrupt.pptx
Interrupt.pptx
 
UNIT 5 Interfacing and Mixed Signal Controller.pptx
UNIT 5 Interfacing and Mixed Signal Controller.pptxUNIT 5 Interfacing and Mixed Signal Controller.pptx
UNIT 5 Interfacing and Mixed Signal Controller.pptx
 
UNIT 5.pptx
UNIT 5.pptxUNIT 5.pptx
UNIT 5.pptx
 
Unit 3 timer and counter and there application .pptx
Unit 3 timer and counter and there application .pptxUnit 3 timer and counter and there application .pptx
Unit 3 timer and counter and there application .pptx
 
Advanced Microprocessor 6.pptx
Advanced Microprocessor 6.pptxAdvanced Microprocessor 6.pptx
Advanced Microprocessor 6.pptx
 
8051
80518051
8051
 
Live B tech Projects & Industrial Training @Technogroovy
Live B tech Projects & Industrial Training @Technogroovy Live B tech Projects & Industrial Training @Technogroovy
Live B tech Projects & Industrial Training @Technogroovy
 
8051
80518051
8051
 
8051 training an interactive tutorial
8051 training an interactive tutorial8051 training an interactive tutorial
8051 training an interactive tutorial
 
Unit 5_interrupt programming_Part 1
Unit 5_interrupt programming_Part 1Unit 5_interrupt programming_Part 1
Unit 5_interrupt programming_Part 1
 

Recently uploaded

Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Christo Ananth
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdfankushspencer015
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).pptssuser5c9d4b1
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 

Recently uploaded (20)

Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 

Embedded systems, lesson 16

  • 1. Biomedical Engineering B.E III Year Embedded Systems Unit-TWO Microcontroller And Programming Lesson - 7
  • 2. 8051-Microcontoller Interrupts  Interrupts Vs. Polling: • A single microcontroller can serve several devices. • There are two ways to do that: ‘Interrupt or Polling’ • In the ‘Interrupt’ method, 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 associated with the interrupt is called “Interrupt Service Routine (ISR) or Interrupt Handler”.
  • 3. Cont. • In ‘Polling’ the microcontroller continuously monitors the status of a given device, when the status condition is met, it performs the service. • After that, it moves on to monitor the next device until each one is serviced. • Although polling can monitor the status of several devices and serve each of them as certain conditions are met, it is not an efficient use of the microcontroller. • The advantage of interrupt is that the microcontroller can serve many devices (not all at the same time) each device can get the attention of the microcontroller based on the priority assigned to it.
  • 4. Cont. • The polling method cannot assign priority since it checks all devices in a round-robin fashion. • More importantly, in the interrupt method the microcontroller can also ignore (mask) a device request for service, this is again not possible with the polling method. • The most important reason that the interrupt method is preferable is that the polling method wastes much of the microcontroller time by polling devices that do not need service.
  • 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 ISR. • For every interrupt, there is a fixed location in the memory that holds the address of its ISR. • The group of memory locations set aside to hold the addresses of ISR’s is called the ‘Interrupt Vector Table’.
  • 6. Interrupt Vector Table for 8051-Microcontroller: Interrupt ROM Location (Hex) Pin Flag Clearing RESET 0000 9 Auto Ext. Hardware Interrupt 0 (INT0) 0003 P 3.2 (12) Auto Timer 0 Interrupt (TFO) 000B Auto Ext. Hardware Interrupt 1 (INT1) 0013 P 3.3 (13) Auto Timer 1 Interrupt (TF1) 001B Auto Serial Communication Interrupt (RI & TI) 0023 Programmer Clears it
  • 7.  Steps In Executing an Interrupt: • Upon activation of an interrupt, the microcontroller goes through the following steps. • It finishes the instruction it is executing and saves the address of the next instruction (P.C) on the stack. • It also saves the current status of all the interrupts internally. • It jumps to a fixed location in memory called the interrupt vector table that holds the address of the Interrupt Service Routine. • 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 inst. Of the subroutine, which is RETI (Return from Interrupt).
  • 8. Cont. • Upon executing the RETI instruction, the microcontroller returns to the place where it was interrupted. • First it gets the (P.C) address from the stack by popping the top two bytes of the stack into the P.C. then it starts to execute from that address.
  • 9.  Six Interrupts In 8051: • In reality only five interrupts are available to the user in the 8051, but many manufacturers data sheet state that there are six interrupts since they include RESET. • RESET, when the reset pin is activated, the 8051 jumps to address location 0000. this is power up-reset. • Two interrupts are set aside for the timers: one for timer 0 and one for timer 1, memory locations 000BH & 001BH in the interrupt vector table belongs to Timer 0 & Timer 1. • Two interrupts are set aside for hardware, external hardware interrupt. Pin no. 12 and 13 in port 3are for the external hardware interrupt INT0 & INT1. These external interrupts are also referred to as EX1 & EX2, memory locations 0003H and 0013H are assigned to INT0 & INT1.
  • 10. Cont. • Serial communication has a single interrupt that belongs to both receive and transmit. The interrupt vector table location 0023H belongs to this interrupt.  Enabling & Disabling An Interrupt: • Upon reset, all interrupts are disabled (masked), meaning that none will be responded to by the microcontroller if they are activated. • The interrupts must be enabled by software in order for the microcontroller to respond to them. • There is a register called IE (Interrupt Enable) that is responsible for enabling (unmasking) and disabling (masking) the interrupt. IE is a bit addressable register.
  • 11.  I.E (Interrupt Enable) Register:
  • 12. Cont.  Steps In Enabling an Interrupt: • Bit D7 of the Interrupt Priority Register (EA) must be set to high to allow the rest of register to take effect. • If EA=1, interrupts are enabled and will be responded to if their corresponding bits in I.E are high. • If EA=0, no interrupt will be responded to, even if the associated bit in the I.E register is high.
  • 13. Cont.
  • 14.  Interrupt Priority (I.P) SFR: Bit Symbol Function 7 ------ NOT IMPLEMENTED 6 ------ NOT IMPLEMENTED 5 PT2 RESERVED FOR FUTURE USE 4 PS PRIORITY OF SERIAL PORT INTERRUPT 3 PT1 PRIORITY OF TIMER 1 OVERFLOW INTERRUPT 2 PX1 PRIORITY OF EXTERNAL INTERRUPT 1 1 PT0 PRIORITY OF TIMER 0 OVERFLOW INTERRUPT 0 PX0 PRIORITY OF EXTERNAL INTERRUPT 0
  • 15.  Timer Flag Interrupt: • When a Timer/Counter overflows, the corresponding timer flag, TF0 or TF1 is set to 1. • The flag is cleared to 0, when the resulting interrupt generates a program call to the appropriate timer subroutine in memory.  Serial Port Interrupt: • If a data is received, an interrupt bit, R1 is set to 1in the SCON register. • When a data byte has been transmitted on interrupt bit, T1, is set in SCON. • These are Ored together to provide a single interrupt to the processor, the serial port interrupt. • The program that handles serial data communication must reset R1 or T1 to 0, to enable the next data communication operation.
  • 16. Cont.  External Interrupts: • Pins INT0 & INT1 are used by external circuitry. • Inputs on these pins can set the interrupt flags IE0 & IE1 in the TCON register to 1 by two different methods. • The IEX flags may be set when the INTX pin signal reaches a low level, or the flags may be set when a high-to-low transition takes place on the INTX pin. • Bits IT0 & IT1 in TCON, program the INTX pins for low- level interrupt. • When set to 0 and program the INTX pins for transition interrupt when set to 1
  • 17. Cont.  RESET: • A reset can be considered to be the ultimate interrupt because the program may not block the action of the voltage on the RST pin. • This type of interrupt is often called non-maskable, because no combination of bits in any register can stop or mask the reset action. • Whenever a high level is applied to the RST pin, the 8051 enters a reset condition. • After the RST pin is bought low, the internal registers will have the different values. • Internal RAM contents may change during reset. • Register bank 0 is selected on reset as all bits in PSW are 0.
  • 18.  Interrupt Priority: • Register IP bits determine if any interrupt is to have a high or low priority. • Bits set to 1 give the accompanying interrupt a high priority, a 0 assigns a low priority. • Interrupts with a high priority can interrupt another interrupt with a lower priority, the lower priority interrupt continues after the higher is finished. • If two interrupts with the same priority occurs at the same time, then they have the following ranking: 1. IE0 2. TF0 3. IE1 4. TF1 5. Serial = R1 or T1
  • 19. Thank-You  Learning outcomes of today’s lesson: • Interrupt vs. Polling • Interrupt Service Routine • Interrupt Vector Table • Steps in Executing an Interrupt • 8051 Interrupts • Enabling & Disabling an Interrupt • Interrupt Enable (I.E) Register • Interrupt Priority