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

Device drivers and interrupt service mechanism
Device drivers and interrupt service mechanismDevice drivers and interrupt service mechanism
Device drivers and interrupt service mechanismVijay Kumar
 
Lect 2 ARM processor architecture
Lect 2 ARM processor architectureLect 2 ARM processor architecture
Lect 2 ARM processor architectureDr.YNM
 
Arm cortex-m4 programmer model
Arm cortex-m4 programmer modelArm cortex-m4 programmer model
Arm cortex-m4 programmer modelMohammed Gomaa
 
Typical Embedded System
Typical Embedded SystemTypical Embedded System
Typical Embedded Systemanand hd
 
Micro programmed control
Micro programmed  controlMicro programmed  control
Micro programmed controlShashank Singh
 
Ch 1 introduction to Embedded Systems (AY:2018-2019--> First Semester)
Ch 1 introduction to Embedded Systems (AY:2018-2019--> First Semester)Ch 1 introduction to Embedded Systems (AY:2018-2019--> First Semester)
Ch 1 introduction to Embedded Systems (AY:2018-2019--> First Semester)Moe Moe Myint
 
ARM7-ARCHITECTURE
ARM7-ARCHITECTURE ARM7-ARCHITECTURE
ARM7-ARCHITECTURE Dr.YNM
 
Control Unit Design
Control Unit DesignControl Unit Design
Control Unit DesignVinit Raut
 
Assembly language programming
Assembly language programmingAssembly language programming
Assembly language programminghimhk
 
Real time Operating System
Real time Operating SystemReal time Operating System
Real time Operating SystemTech_MX
 
Computer architecture and organization
Computer architecture and organizationComputer architecture and organization
Computer architecture and organizationTushar B Kute
 
Basic ops concept of comp
Basic ops  concept of compBasic ops  concept of comp
Basic ops concept of compgaurav jain
 

What's hot (20)

Device drivers and interrupt service mechanism
Device drivers and interrupt service mechanismDevice drivers and interrupt service mechanism
Device drivers and interrupt service mechanism
 
Lect 2 ARM processor architecture
Lect 2 ARM processor architectureLect 2 ARM processor architecture
Lect 2 ARM processor architecture
 
Arm cortex-m4 programmer model
Arm cortex-m4 programmer modelArm cortex-m4 programmer model
Arm cortex-m4 programmer model
 
Typical Embedded System
Typical Embedded SystemTypical Embedded System
Typical Embedded System
 
Interrupts
InterruptsInterrupts
Interrupts
 
Micro programmed control
Micro programmed  controlMicro programmed  control
Micro programmed control
 
Ch 1 introduction to Embedded Systems (AY:2018-2019--> First Semester)
Ch 1 introduction to Embedded Systems (AY:2018-2019--> First Semester)Ch 1 introduction to Embedded Systems (AY:2018-2019--> First Semester)
Ch 1 introduction to Embedded Systems (AY:2018-2019--> First Semester)
 
Interrupts
InterruptsInterrupts
Interrupts
 
ARM7-ARCHITECTURE
ARM7-ARCHITECTURE ARM7-ARCHITECTURE
ARM7-ARCHITECTURE
 
Control Unit Design
Control Unit DesignControl Unit Design
Control Unit Design
 
ARM Processor
ARM ProcessorARM Processor
ARM Processor
 
Introduction to stm32-part2
Introduction to stm32-part2Introduction to stm32-part2
Introduction to stm32-part2
 
Arm instruction set
Arm instruction setArm instruction set
Arm instruction set
 
Assembly language programming
Assembly language programmingAssembly language programming
Assembly language programming
 
Real time Operating System
Real time Operating SystemReal time Operating System
Real time Operating System
 
Computer architecture and organization
Computer architecture and organizationComputer architecture and organization
Computer architecture and organization
 
Embedded c
Embedded cEmbedded c
Embedded c
 
STM32 MCU Family
STM32 MCU FamilySTM32 MCU Family
STM32 MCU Family
 
Basic ops concept of comp
Basic ops  concept of compBasic ops  concept of comp
Basic ops concept of comp
 
Interrupt
InterruptInterrupt
Interrupt
 

Similar to Interrupts

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
 
Top schools in delhi ncr
Top schools in delhi ncrTop schools in delhi ncr
Top schools in delhi ncrEdhole.com
 
Chapter7_InputOutputStorageSystems.pptx
Chapter7_InputOutputStorageSystems.pptxChapter7_InputOutputStorageSystems.pptx
Chapter7_InputOutputStorageSystems.pptxJanethMedina31
 

Similar to Interrupts (20)

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
 
Top schools in delhi ncr
Top schools in delhi ncrTop schools in delhi ncr
Top schools in delhi ncr
 
Chapter7_InputOutputStorageSystems.pptx
Chapter7_InputOutputStorageSystems.pptxChapter7_InputOutputStorageSystems.pptx
Chapter7_InputOutputStorageSystems.pptx
 

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

ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusZilliz
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
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
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
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
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...apidays
 

Recently uploaded (20)

ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
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
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
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
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 

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