SlideShare a Scribd company logo
1 of 26
Download to read offline
Interrupts
Eman Aboelatta

Copyright © 2012 Embedded Systems
Committee
Agenda:
•
•
•
•
•
•
•
•
•
•

Introduction
Interrupts
Interrupt sequence
So how to we define an ISR?
Interrupt Vector Table
Modifying Interrupt Vector Table of ATmega16
Registers Used
Interrupt priorities
Interrupt nesting
Nested Interrupt Priorities

Copyright © 2012 Embedded Systems
Committee
Introduction:
At first we have two methods for receiving data or get status

Polling

Interrupt

Copyright © 2012 Embedded Systems
Committee
Introduction:con’t
Polling :
which involves reading the status of the port at fixed intervals to
determine whether any data has been received or a change of status
has occurred. If so, then we can branch to a routine to service the
ports requests.
oTakes CPU time even when no requests pending.

oOverhead.
“Polling is like picking up your phone every few seconds to see if
you have a call. …”

Other alternative would be to use Interrupts.
Copyright © 2012 Embedded Systems
Committee
Interrupts (IR):
 Interrupts can be used to interrupt the sequential execution of
the program flow(called asynchronous processing - that is, we are
processing the interrupt events outside the regular execution of the
main program.)

 Interrupt sources can be
- external events (e.g. change of signal at PORTB2).
- internal events.

Hardware interrupt
(e.g. timer
overflow).

Software interrupt

(which occur in response
to a command issued in
software-Exception
Handling )
Copyright © 2012 Embedded Systems
Committee
Interrupts (IR):con’t
Non Maskable Interrupts :

doesn’t depend on global interrupt enable in processor status word
Usually it’s external interrupt(Ex : Reset).
Maskable Interrupts:
Depends on global interrupt enable in processor status word
May be :
External interrupt from external pin
Internal interrupt from peripheral

Copyright © 2012 Embedded Systems
Committee
Interrupts (IR):Con’t




In the case of an interrupt event
the execution of the main
routine is interrupted and the
interrupt service routine (ISR)
of the according event is
executed.

After executing the ISR the
execution proceeds where it has
been interrupted.

Copyright © 2012 Embedded Systems
Committee
Interrupt sequence:
When the CPU detects

The CPU finishes its current instruction.
The contents of the program counter and the condition code
register(status register or Processor status word) are pushed
onto the stack(because the interrupt routine will almost
certainly modify the condition code bits).
Further interrupts are disabled to avoid an interrupt being
interrupted.
The CPU deals with the cause of the interrupt by executing
a program called an interrupt handler(ISR)(Interrupt service
routine).
The CPU executes a return from interrupt instruction at the
end of the interrupt handler. Executing this instruction pulls
the PC and PSW off the stack and execution then continues
normally—as if the interrupt had never happened.
Copyright © 2012 Embedded Systems
Committee
Interrupt sequence: con’t

o PSR : Processor Status
Register ==status
register==Condition Code
register

o PC : Program Counter

(contains Address of next
instruction to be executed)

Copyright © 2012 Embedded Systems
Committee
So how to we define an ISR?
For an ISR to be called, we need three conditions to be
true:
Firstly, the AVR's global Interrupts Enable bit (I) must be set in
the MCU control register SREG.

Secondly, the individual interrupt source's enable bit must be

set. Each interrupt source has a separate interrupt enable bit in
the related peripheral's control registers, which turns on the
ISR for that interrupt.

Thirdly, The condition for the interrupt must be met - for

example, for the USART Receive Complete (USART RX)
interrupt, a character must have been received(i.e flag that
indicate interrupt raised)
Copyright © 2012 Embedded Systems
Committee
So how to we define an ISR?con’t
Enable Global interrupt (I)

Execute ISR

Enable peripheral interrupt
Interrupt occurred (flag
raised)

Copyright © 2012 Embedded Systems
Committee
• Constant table in ROM.
• Special addresses with respect to CPU.
• Each interrupt has specific address in interrupt vector
table .
• This specific address should be programmed to have the
address of ISR of this interrupt.
• At interrupt processing PC will contain this address or it
will be an instruction to jump to this address
Copyright © 2012 Embedded Systems
Committee
Interrupt Vector Table:cont
• From Datasheet ATmega32/16.

Copyright © 2012 Embedded Systems
Committee
Modifying Interrupt Vector Table of
ATmega16:
 Assembly 
.org $000
rjmp Reset
.
.
.
.
.
Reset:
//instructions

C

ISR ({Vector Source}_vect)
{
// ISR code to execute here
}
Copyright © 2012 Embedded Systems
Committee
Registers Used
Status Register (SREG):To Enable Global Interrupt

• The status register contains:
– Six bits status indicators ( Z,C,H,V,N,S )
– One bit for global interrupt enable ( I )
• The status bits reflect the results of CPU operation as it executes
instructions
Copyright © 2012 Embedded Systems
Committee
Registers Used with Atmega32/16:
To Set/Clear global interrupt enable:

• Set global interrupt enable: (Allow)

• Clear global interrupt enable: (prevent)

The I-bit is cleared by hardware after an interrupt has
occurred, and is set by the RETI instruction to enable
subsequent interrupts.
Copyright © 2012 Embedded Systems
Committee
Registers Used with Atmega32/16:
GICR (General Interrupt Control Register):P.no 47

Copyright © 2012 Embedded Systems
Committee
Registers Used with Atmega32/16:
MCUCR (MCU Control Register) P.66

Copyright © 2012 Embedded Systems
Committee
Registers Used with Atmega32/16:
MCUCSR (MCU Control and Status Register) P67

Copyright © 2012 Embedded Systems
Committee
Registers Used with Atmega32/16:
GIFR (General Interrupt Flag Register)

Copyright © 2012 Embedded Systems
Committee
Defining ISR :
• ISR(Interrupt Service Routine)
#include <avr/interrupt.h>

ISR({Vector Source}_vect)
{
// ISR code to execute here
}

Copyright © 2012 Embedded Systems
Committee
Interrupt priorities:
• Each interrupt has default priority by its location in
interrupt vector table
• Some controllers provide more intelligent interrupt
controller which give interrupt priority level for each
interrupt
• If two interrupts have a same priority level then the rule
to return to the default priority

Copyright © 2012 Embedded Systems
Committee
Interrupt nesting:
• Interrupt Nesting: ability to leave the current interrupt
and serve another interrupt

• Usually done if global interrupt is enabled and this
interrupt has more priority
• Some controllers support the nesting of context switching
in hardware and others leave it to be done in software

Copyright © 2012 Embedded Systems
Committee
Nested Interrupt Priorities:

Copyright © 2012 Embedded Systems
Committee
References
• ATmega16 Datasheet.
• http://www.avrfreaks.net/

Copyright © 2012 Embedded Systems
Committee
info@escommittee.net

Copyright © 2012 Embedded Systems
Committee

More Related Content

What's hot

ARM Processor architecture
ARM Processor  architectureARM Processor  architecture
ARM Processor architecturerajkciitr
 
Chapter 3 Charateristics and Quality Attributes of Embedded System
Chapter 3 Charateristics and Quality Attributes of Embedded SystemChapter 3 Charateristics and Quality Attributes of Embedded System
Chapter 3 Charateristics and Quality Attributes of Embedded SystemMoe Moe Myint
 
ARM architcture
ARM architcture ARM architcture
ARM architcture Hossam Adel
 
8237 dma controller
8237 dma controller8237 dma controller
8237 dma controllerTech_MX
 
Embedded System Programming on ARM Cortex M3 and M4 Course
Embedded System Programming on ARM Cortex M3 and M4 CourseEmbedded System Programming on ARM Cortex M3 and M4 Course
Embedded System Programming on ARM Cortex M3 and M4 CourseFastBit Embedded Brain Academy
 
Unit II Arm7 Thumb Instruction
Unit II Arm7 Thumb InstructionUnit II Arm7 Thumb Instruction
Unit II Arm7 Thumb InstructionDr. Pankaj Zope
 
Microcontoller and Embedded System
Microcontoller and Embedded SystemMicrocontoller and Embedded System
Microcontoller and Embedded SystemKaran Thakkar
 
Pic 18 microcontroller
Pic 18 microcontrollerPic 18 microcontroller
Pic 18 microcontrollerAshish Ranjan
 
Arm assembly language programming
Arm assembly language programmingArm assembly language programming
Arm assembly language programmingv Kalairajan
 
Project Report on Embedded Systems
Project Report on Embedded Systems Project Report on Embedded Systems
Project Report on Embedded Systems Suhani Singh
 
PIC MICROCONTROLLERS -CLASS NOTES
PIC MICROCONTROLLERS -CLASS NOTESPIC MICROCONTROLLERS -CLASS NOTES
PIC MICROCONTROLLERS -CLASS NOTESDr.YNM
 
Arm cortex-m4 programmer model
Arm cortex-m4 programmer modelArm cortex-m4 programmer model
Arm cortex-m4 programmer modelMohammed Gomaa
 
Design challenges in embedded systems
Design challenges in embedded systemsDesign challenges in embedded systems
Design challenges in embedded systemsmahalakshmimalini
 

What's hot (20)

Embedded System Basics
Embedded System BasicsEmbedded System Basics
Embedded System Basics
 
ARM Processor architecture
ARM Processor  architectureARM Processor  architecture
ARM Processor architecture
 
Microprogrammed Control Unit
Microprogrammed Control UnitMicroprogrammed Control Unit
Microprogrammed Control Unit
 
PIC Microcontrollers
PIC MicrocontrollersPIC Microcontrollers
PIC Microcontrollers
 
Chapter 3 Charateristics and Quality Attributes of Embedded System
Chapter 3 Charateristics and Quality Attributes of Embedded SystemChapter 3 Charateristics and Quality Attributes of Embedded System
Chapter 3 Charateristics and Quality Attributes of Embedded System
 
Hardware-Software Codesign
Hardware-Software CodesignHardware-Software Codesign
Hardware-Software Codesign
 
UART
UARTUART
UART
 
E.s unit 4 and 5
E.s unit 4 and 5E.s unit 4 and 5
E.s unit 4 and 5
 
ARM architcture
ARM architcture ARM architcture
ARM architcture
 
MicroC/OS-II
MicroC/OS-IIMicroC/OS-II
MicroC/OS-II
 
8237 dma controller
8237 dma controller8237 dma controller
8237 dma controller
 
Embedded System Programming on ARM Cortex M3 and M4 Course
Embedded System Programming on ARM Cortex M3 and M4 CourseEmbedded System Programming on ARM Cortex M3 and M4 Course
Embedded System Programming on ARM Cortex M3 and M4 Course
 
Unit II Arm7 Thumb Instruction
Unit II Arm7 Thumb InstructionUnit II Arm7 Thumb Instruction
Unit II Arm7 Thumb Instruction
 
Microcontoller and Embedded System
Microcontoller and Embedded SystemMicrocontoller and Embedded System
Microcontoller and Embedded System
 
Pic 18 microcontroller
Pic 18 microcontrollerPic 18 microcontroller
Pic 18 microcontroller
 
Arm assembly language programming
Arm assembly language programmingArm assembly language programming
Arm assembly language programming
 
Project Report on Embedded Systems
Project Report on Embedded Systems Project Report on Embedded Systems
Project Report on Embedded Systems
 
PIC MICROCONTROLLERS -CLASS NOTES
PIC MICROCONTROLLERS -CLASS NOTESPIC MICROCONTROLLERS -CLASS NOTES
PIC MICROCONTROLLERS -CLASS NOTES
 
Arm cortex-m4 programmer model
Arm cortex-m4 programmer modelArm cortex-m4 programmer model
Arm cortex-m4 programmer model
 
Design challenges in embedded systems
Design challenges in embedded systemsDesign challenges in embedded systems
Design challenges in embedded systems
 

Similar to Interrupts

Device drivers and interrupt service mechanism
Device drivers and interrupt service mechanismDevice drivers and interrupt service mechanism
Device drivers and interrupt service mechanismVijay Kumar
 
ESD III UNIT.pptx
ESD III UNIT.pptxESD III UNIT.pptx
ESD III UNIT.pptxECEHOD19
 
AAME ARM Techcon2013 002v02 Advanced Features
AAME ARM Techcon2013 002v02 Advanced FeaturesAAME ARM Techcon2013 002v02 Advanced Features
AAME ARM Techcon2013 002v02 Advanced FeaturesAnh Dung NGUYEN
 
Mca admission in india
Mca admission in indiaMca admission in india
Mca admission in indiaEdhole.com
 
UNIT 5- UNDERSTANDING THE SYSTEM DESIGN PROCESS.pptx
UNIT 5- UNDERSTANDING THE SYSTEM DESIGN PROCESS.pptxUNIT 5- UNDERSTANDING THE SYSTEM DESIGN PROCESS.pptx
UNIT 5- UNDERSTANDING THE SYSTEM DESIGN PROCESS.pptxLeahRachael
 
Assembly programming
Assembly programmingAssembly programming
Assembly programmingOmar Sanchez
 
Advanced Embedded System Subject seminar on SCB,DEBUG,RESET
Advanced Embedded System Subject seminar on SCB,DEBUG,RESETAdvanced Embedded System Subject seminar on SCB,DEBUG,RESET
Advanced Embedded System Subject seminar on SCB,DEBUG,RESETರೇಣುಕ ಭುವನ್
 
Interrupts of 8085
Interrupts of 8085Interrupts of 8085
Interrupts of 8085ShivamSood22
 
Unit 1 intro-embedded
Unit 1 intro-embeddedUnit 1 intro-embedded
Unit 1 intro-embeddedPavithra S
 
Run time, frequently, non-frequently reconfigurable system &
Run time, frequently, non-frequently reconfigurable system &Run time, frequently, non-frequently reconfigurable system &
Run time, frequently, non-frequently reconfigurable system &Sudhanshu Janwadkar
 
Embedded system - Introduction to interfacing with peripherals
Embedded system - Introduction to interfacing with peripheralsEmbedded system - Introduction to interfacing with peripherals
Embedded system - Introduction to interfacing with peripheralsVibrant Technologies & Computers
 

Similar to Interrupts (20)

Device drivers and interrupt service mechanism
Device drivers and interrupt service mechanismDevice drivers and interrupt service mechanism
Device drivers and interrupt service mechanism
 
UNIT 2.pptx
UNIT 2.pptxUNIT 2.pptx
UNIT 2.pptx
 
presentation on SCB,DEBUG,RESET of Arm Cortex processor
presentation on SCB,DEBUG,RESET of Arm Cortex processorpresentation on SCB,DEBUG,RESET of Arm Cortex processor
presentation on SCB,DEBUG,RESET of Arm Cortex processor
 
Interrupts.ppt
Interrupts.pptInterrupts.ppt
Interrupts.ppt
 
ESD III UNIT.pptx
ESD III UNIT.pptxESD III UNIT.pptx
ESD III UNIT.pptx
 
AAME ARM Techcon2013 002v02 Advanced Features
AAME ARM Techcon2013 002v02 Advanced FeaturesAAME ARM Techcon2013 002v02 Advanced Features
AAME ARM Techcon2013 002v02 Advanced Features
 
Mca admission in india
Mca admission in indiaMca admission in india
Mca admission in india
 
UNIT 5- UNDERSTANDING THE SYSTEM DESIGN PROCESS.pptx
UNIT 5- UNDERSTANDING THE SYSTEM DESIGN PROCESS.pptxUNIT 5- UNDERSTANDING THE SYSTEM DESIGN PROCESS.pptx
UNIT 5- UNDERSTANDING THE SYSTEM DESIGN PROCESS.pptx
 
Io pro
Io proIo pro
Io pro
 
Assembly programming
Assembly programmingAssembly programming
Assembly programming
 
IO hardware
IO hardwareIO hardware
IO hardware
 
Advanced Embedded System Subject seminar on SCB,DEBUG,RESET
Advanced Embedded System Subject seminar on SCB,DEBUG,RESETAdvanced Embedded System Subject seminar on SCB,DEBUG,RESET
Advanced Embedded System Subject seminar on SCB,DEBUG,RESET
 
Interrupts of 8085
Interrupts of 8085Interrupts of 8085
Interrupts of 8085
 
Unit 1 intro-embedded
Unit 1 intro-embeddedUnit 1 intro-embedded
Unit 1 intro-embedded
 
Run time, frequently, non-frequently reconfigurable system &
Run time, frequently, non-frequently reconfigurable system &Run time, frequently, non-frequently reconfigurable system &
Run time, frequently, non-frequently reconfigurable system &
 
Microcontroller part 4
Microcontroller part 4Microcontroller part 4
Microcontroller part 4
 
Embedded system - Introduction to interfacing with peripherals
Embedded system - Introduction to interfacing with peripheralsEmbedded system - Introduction to interfacing with peripherals
Embedded system - Introduction to interfacing with peripherals
 
unit 5.pptx
unit 5.pptxunit 5.pptx
unit 5.pptx
 
Interrupts
InterruptsInterrupts
Interrupts
 
Interrupts
InterruptsInterrupts
Interrupts
 

More from محمدعبد الحى (16)

Iso26262 component reuse_webinar
Iso26262 component reuse_webinarIso26262 component reuse_webinar
Iso26262 component reuse_webinar
 
Interfacing using ِAtmega16/32
Interfacing using ِAtmega16/32 Interfacing using ِAtmega16/32
Interfacing using ِAtmega16/32
 
Can bus
Can busCan bus
Can bus
 
Lin bus
Lin busLin bus
Lin bus
 
Embedded Systems in Automotive
Embedded Systems in Automotive Embedded Systems in Automotive
Embedded Systems in Automotive
 
MATLAB Programming
MATLAB Programming MATLAB Programming
MATLAB Programming
 
CPU Architecture
CPU ArchitectureCPU Architecture
CPU Architecture
 
8 bit microcontroller
8 bit microcontroller8 bit microcontroller
8 bit microcontroller
 
Matlab workshop
Matlab workshopMatlab workshop
Matlab workshop
 
Timers
TimersTimers
Timers
 
Uart
UartUart
Uart
 
Sw testing
Sw testingSw testing
Sw testing
 
Rtos
RtosRtos
Rtos
 
Dio
DioDio
Dio
 
Micro controller
Micro controllerMicro controller
Micro controller
 
Day1
Day1Day1
Day1
 

Recently uploaded

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 

Recently uploaded (20)

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 

Interrupts

  • 1. Interrupts Eman Aboelatta Copyright © 2012 Embedded Systems Committee
  • 2. Agenda: • • • • • • • • • • Introduction Interrupts Interrupt sequence So how to we define an ISR? Interrupt Vector Table Modifying Interrupt Vector Table of ATmega16 Registers Used Interrupt priorities Interrupt nesting Nested Interrupt Priorities Copyright © 2012 Embedded Systems Committee
  • 3. Introduction: At first we have two methods for receiving data or get status Polling Interrupt Copyright © 2012 Embedded Systems Committee
  • 4. Introduction:con’t Polling : which involves reading the status of the port at fixed intervals to determine whether any data has been received or a change of status has occurred. If so, then we can branch to a routine to service the ports requests. oTakes CPU time even when no requests pending. oOverhead. “Polling is like picking up your phone every few seconds to see if you have a call. …” Other alternative would be to use Interrupts. Copyright © 2012 Embedded Systems Committee
  • 5. Interrupts (IR):  Interrupts can be used to interrupt the sequential execution of the program flow(called asynchronous processing - that is, we are processing the interrupt events outside the regular execution of the main program.)  Interrupt sources can be - external events (e.g. change of signal at PORTB2). - internal events. Hardware interrupt (e.g. timer overflow). Software interrupt (which occur in response to a command issued in software-Exception Handling ) Copyright © 2012 Embedded Systems Committee
  • 6. Interrupts (IR):con’t Non Maskable Interrupts : doesn’t depend on global interrupt enable in processor status word Usually it’s external interrupt(Ex : Reset). Maskable Interrupts: Depends on global interrupt enable in processor status word May be : External interrupt from external pin Internal interrupt from peripheral Copyright © 2012 Embedded Systems Committee
  • 7. Interrupts (IR):Con’t   In the case of an interrupt event the execution of the main routine is interrupted and the interrupt service routine (ISR) of the according event is executed. After executing the ISR the execution proceeds where it has been interrupted. Copyright © 2012 Embedded Systems Committee
  • 8. Interrupt sequence: When the CPU detects The CPU finishes its current instruction. The contents of the program counter and the condition code register(status register or Processor status word) are pushed onto the stack(because the interrupt routine will almost certainly modify the condition code bits). Further interrupts are disabled to avoid an interrupt being interrupted. The CPU deals with the cause of the interrupt by executing a program called an interrupt handler(ISR)(Interrupt service routine). The CPU executes a return from interrupt instruction at the end of the interrupt handler. Executing this instruction pulls the PC and PSW off the stack and execution then continues normally—as if the interrupt had never happened. Copyright © 2012 Embedded Systems Committee
  • 9. Interrupt sequence: con’t o PSR : Processor Status Register ==status register==Condition Code register o PC : Program Counter (contains Address of next instruction to be executed) Copyright © 2012 Embedded Systems Committee
  • 10. So how to we define an ISR? For an ISR to be called, we need three conditions to be true: Firstly, the AVR's global Interrupts Enable bit (I) must be set in the MCU control register SREG. Secondly, the individual interrupt source's enable bit must be set. Each interrupt source has a separate interrupt enable bit in the related peripheral's control registers, which turns on the ISR for that interrupt. Thirdly, The condition for the interrupt must be met - for example, for the USART Receive Complete (USART RX) interrupt, a character must have been received(i.e flag that indicate interrupt raised) Copyright © 2012 Embedded Systems Committee
  • 11. So how to we define an ISR?con’t Enable Global interrupt (I) Execute ISR Enable peripheral interrupt Interrupt occurred (flag raised) Copyright © 2012 Embedded Systems Committee
  • 12. • Constant table in ROM. • Special addresses with respect to CPU. • Each interrupt has specific address in interrupt vector table . • This specific address should be programmed to have the address of ISR of this interrupt. • At interrupt processing PC will contain this address or it will be an instruction to jump to this address Copyright © 2012 Embedded Systems Committee
  • 13. Interrupt Vector Table:cont • From Datasheet ATmega32/16. Copyright © 2012 Embedded Systems Committee
  • 14. Modifying Interrupt Vector Table of ATmega16:  Assembly  .org $000 rjmp Reset . . . . . Reset: //instructions C ISR ({Vector Source}_vect) { // ISR code to execute here } Copyright © 2012 Embedded Systems Committee
  • 15. Registers Used Status Register (SREG):To Enable Global Interrupt • The status register contains: – Six bits status indicators ( Z,C,H,V,N,S ) – One bit for global interrupt enable ( I ) • The status bits reflect the results of CPU operation as it executes instructions Copyright © 2012 Embedded Systems Committee
  • 16. Registers Used with Atmega32/16: To Set/Clear global interrupt enable: • Set global interrupt enable: (Allow) • Clear global interrupt enable: (prevent) The I-bit is cleared by hardware after an interrupt has occurred, and is set by the RETI instruction to enable subsequent interrupts. Copyright © 2012 Embedded Systems Committee
  • 17. Registers Used with Atmega32/16: GICR (General Interrupt Control Register):P.no 47 Copyright © 2012 Embedded Systems Committee
  • 18. Registers Used with Atmega32/16: MCUCR (MCU Control Register) P.66 Copyright © 2012 Embedded Systems Committee
  • 19. Registers Used with Atmega32/16: MCUCSR (MCU Control and Status Register) P67 Copyright © 2012 Embedded Systems Committee
  • 20. Registers Used with Atmega32/16: GIFR (General Interrupt Flag Register) Copyright © 2012 Embedded Systems Committee
  • 21. Defining ISR : • ISR(Interrupt Service Routine) #include <avr/interrupt.h> ISR({Vector Source}_vect) { // ISR code to execute here } Copyright © 2012 Embedded Systems Committee
  • 22. Interrupt priorities: • Each interrupt has default priority by its location in interrupt vector table • Some controllers provide more intelligent interrupt controller which give interrupt priority level for each interrupt • If two interrupts have a same priority level then the rule to return to the default priority Copyright © 2012 Embedded Systems Committee
  • 23. Interrupt nesting: • Interrupt Nesting: ability to leave the current interrupt and serve another interrupt • Usually done if global interrupt is enabled and this interrupt has more priority • Some controllers support the nesting of context switching in hardware and others leave it to be done in software Copyright © 2012 Embedded Systems Committee
  • 24. Nested Interrupt Priorities: Copyright © 2012 Embedded Systems Committee
  • 25. References • ATmega16 Datasheet. • http://www.avrfreaks.net/ Copyright © 2012 Embedded Systems Committee
  • 26. info@escommittee.net Copyright © 2012 Embedded Systems Committee