SlideShare a Scribd company logo
1 of 38
Download to read offline
2015
Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design",
Raj Kamal, Publs.: McGraw-Hill Education
1
DEVICE DRIVERS AND INTERRUPTS
SERVICE MECHANISM
Lesson-2: Interrupt and Interrupt Service
Routine Concept
2015
Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design",
Raj Kamal, Publs.: McGraw-Hill Education
2
• Interrupt means event, which invites
attention of the processor on occurrence of
some action at hardware or software
interrupt instruction event.
Interrupt Concept
2015
Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design",
Raj Kamal, Publs.: McGraw-Hill Education
3
Action on Interrupt
 In response to the interrupt, a routine or
program (called foreground program),
which is running presently interrupts and an
interrupt service routine (ISR) executes.
2015
Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design",
Raj Kamal, Publs.: McGraw-Hill Education
4
Interrupt Service Routine
 ISR is also called device driver in case of
the devices and called exception or signal
or trap handler in case of software
interrupts
2015
Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design",
Raj Kamal, Publs.: McGraw-Hill Education
5
Interrupt approach for the port or device
functions
 Processor executes the program, called
interrupt service routine or signal
handler or trap handler or exception
handler or device driver, related to input
or output from the port or device or related
to a device function on an interrupt and
does not wait and look for the input ready
or output completion or device-status
ready or set
2015
Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design",
Raj Kamal, Publs.: McGraw-Hill Education
6
Hardware interrupt
 Examples─ When a device or port is ready,
a device or port generates an interrupt, or
when it completes the assigned action or
when a timer overflows or when a time at
the timer equals a preset time in a compare
register or on setting a status flag (for
example, on timer overflow or compare or
capture of time) or on click of mice in a
computer
 Hardware interrupt generates a call to an
ISR
2015
Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design",
Raj Kamal, Publs.: McGraw-Hill Education
7
Software Interrupt
Examples
 When software run-time exception condition (for
examples, division by 0 or overflow or illegal
opcode detected) the processor-hardware
generates an interrupt, called trap, which calls an
ISR
 When software run-time exception condition
defined in a program occurs, then a software
instruction (SWI) is executed─ called software
interrupt or exception or signal, which calls an
ISR .
2015
Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design",
Raj Kamal, Publs.: McGraw-Hill Education
8
Software Interrupt
 When a device function is to be invoked, for
example, open (initialize/configure) or read
or write or close , then a software
instruction (SWI) executes─ called software
interrupt to execute the required device
driver function for opening or reading or
writing or closing operations.
2015
Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design",
Raj Kamal, Publs.: McGraw-Hill Education
9
Interrupt
 Software can execute the software instruction
(SWI) or Interrupt n (INT n) to signal execution of
ISR (interrupt service routine). The n is as per the
handler address.
 Signal interrupt [The signal differs from the
function in the sense that execution of signal
handler (ISR) can be masked and till mask is reset,
the handler will not execute on interrupt. Function
on the other hand always executes on the call after
a call-instruction.]
2015
Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design",
Raj Kamal, Publs.: McGraw-Hill Education
10
Interrupt Driven Actions
On Interrupt Interrupt Service
Routine (ISR)
Running
Program Return
No continuous checks of device status
2015
Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design",
Raj Kamal, Publs.: McGraw-Hill Education
11
How does call to ISR differ from a function
(routine) call?
2015
Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design",
Raj Kamal, Publs.: McGraw-Hill Education
12
Routine (function) and ISR call features
 On a function call, the instructions are
executed from a new address
 Execute like in as function in the ‘C’ or in a
method in Java.
 ISR also the instructions are executed from
a new address like in as function in the ‘C’
or in a method in Java
2015
Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design",
Raj Kamal, Publs.: McGraw-Hill Education
13
Routine (function) call and ISR call features
 A function call is after executing present
instruction in any program and is a planned (user
programmed) diversion from the present
instruction in sequence of instructions to another
sequence of instructions; this sequence of
instructions executes till the return from that.
 An ISR call is after executing present instruction
in any program and is interrupt related diversion
from the current sequence of instructions to
another sequence of instructions; this sequence of
instructions executes till the return from that or till
another interrupt of higher priority
2015
Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design",
Raj Kamal, Publs.: McGraw-Hill Education
14
Nesting of function calls and ISRs
 Nesting the function-calls ─ When a
function 1 calls another function 2 and
that call another function 3, on return
from 3, the return is to function 2 and
return from 2 is to function. Functions
are said to be nested
 The ISR calls in case of multiple interrupt
occurrences can be nested or can be as per
priority of the interrupts
2015
Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design",
Raj Kamal, Publs.: McGraw-Hill Education
15
Using the Interrupt(s) and ISR(s) for
each device function (for example, read,
write)
- Use of ISRs (Interrupt Service
Routine) by SWIs is the main
mechanism used for the device
accesses and actions
2015
Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design",
Raj Kamal, Publs.: McGraw-Hill Education
16
1. There is no continuous monitoring of the
status bits or polling for status by the
application.
2. Between two interrupt calls the program
task(s) continue. There are many device-
functions, and each of which executes on
a device interrupt.
Interrupt driven IO and device accesses
feature
2015
Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design",
Raj Kamal, Publs.: McGraw-Hill Education
17
Example─ A 64-kbps UART Input
 When a UART transmits in format of 11-bit
per character format, the network transmits
at most 64 kbps  11 = 5818 characters per
second, which means every 171.9 s a
character is expected.
 Before 171.9 s, the receiver port is not
checked. Only on interrupt from the port the
character is read
 There is no in-between time-gap for polling
2015
Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design",
Raj Kamal, Publs.: McGraw-Hill Education
18
Ports A and B with interrupt generation and
interrupt service (handling) mechanism
 Port A be at in a System, and port B be its
modem input which puts the characters on
the telephone line.
 Let ISR_ PortA_Character be a routine that
receives an input character from Port A on
interrupt and Out_B routine re-transmits an
output character to Port B.
2015
Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design",
Raj Kamal, Publs.: McGraw-Hill Education
19
ISR_ PortA _Character
 Step f function (vi): Read Port A character.
Reset the status bit so that modem is ready
for next character input (generally resetting
of status bit is automatic without need of
specific instruction for it). Put it in memory
buffer. Memory buffer is a set of memory
addresses where the bytes (characters) are
queued for processing later.
 Return from the interrupt service routine.
2015
Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design",
Raj Kamal, Publs.: McGraw-Hill Education
20
ISR_ PortA _Character
On interrupt call ISR_ PortA _Character
Save System, status word and registers
(current program context) on stack
Step f
Execute function vi codes (read character,
reset port status bit, character save in
memory buffer)
Return (retrieve the saved context)
Current program
2015
Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design",
Raj Kamal, Publs.: McGraw-Hill Education
21
Out_B routine
• Step g: Call function (vii) to decrypt the
message characters at the memory buffer and
return for next instruction step h.
• Step h: Call function (viii) to encode the
message character and return for next
instruction step k
• Step k: Call function (ix) to transmit the
encoded character to Port B
• Return from the function.
2015
Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design",
Raj Kamal, Publs.: McGraw-Hill Education
22
Out_B Routine
Out_B Routine
Step g
Step h
Step k
Each step has three parts, save context, execute
codes, and retrieve the context for return
2015
Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design",
Raj Kamal, Publs.: McGraw-Hill Education
23
Application of Interrupt based IOs and device
functions
 In case of multiple processes and device
functions with no device status polling or
wait
2015
Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design",
Raj Kamal, Publs.: McGraw-Hill Education
24
An automatic chocolate vending machine
(ACVM)
 Without interrupt mechanism, one way is the
‘programmed I/O- transfer in which that the
device waits for the coin continuously, activates
on sensing the coin and runs the service routine
 In the event driven way is that the device should
also awakens and activates on each interrupt after
sensing each coin-inserting event.
2015
Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design",
Raj Kamal, Publs.: McGraw-Hill Education
25
Interrupt-service routine (ISR) or device
driver function
 The system awakens and activates on an
interrupt through a hardware or software
signal. The system on port interrupt collects
the coin by running a service routine. This
routine is called interrupt handler routine for
the coin-port read.
2015
Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design",
Raj Kamal, Publs.: McGraw-Hill Education
26
Use of ISR in the ACVM example
Coin
event
input
processor
at a
device
Event: Coin
insertion,
sorting and
coin amount
(1 or 2 or 5
or 10) sent
to an input
port PA)
ISR_CoinRead
Read port P0-
P3 bits
Reset port
status
Save amount at
a memory
buffer
Signal a task
PA0-
PA3
Coin event
Signal AVCM
System ISRs and
Tasks
Call
Return
1 2
3
Data bus
4
2015
Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design",
Raj Kamal, Publs.: McGraw-Hill Education
27
Digital camera system
 Has an image input device.
 The system awakens and activates on interrupt
from a switch.
 When the system wakes up and activates, the
device should grab an image frame data.
 The interrupt is through a hardware signal from
the device switch. On the interrupt, an ISR (can
also be considered as camera’s imaging device-
driver function) for the read starts execution, it
passes a message (signal) to a function or program
thread or task
2015
Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design",
Raj Kamal, Publs.: McGraw-Hill Education
28
Image sense and device frame-buffer
 The thread senses the image and then the
function reads the device frame-buffer
(called frame grabbing),
 then the function passes a signal to another
function or program thread or task to
process and compress the image data and
save the image frame data compressed file
in a flash memory
2015
Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design",
Raj Kamal, Publs.: McGraw-Hill Education
29
Use of ISR in the digital camera example
Keyed
events
input
processor
at camera
Event: Key
pressed to
take a
picture and
pressed key
code sent at
port
ISR_FrameRead
Start ADC scan
Signal task read
frame status and
data of all pixels
of image frame at
CCD co-processor
Signal task for
saving pixels data
at a frame memory
buffer
Signal a CCD co-
processor task for
subtracting offsets
PA0-
PA3
Shoot start
event
Signals camera System Tasks
Call
Return
1 2
4
4
Data bus
6
Interrupt
5
3
To CCD pixels ADC scan
2015
Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design",
Raj Kamal, Publs.: McGraw-Hill Education
30
Interrupt through a hardware signal from a
print-switch at device
 Camera system again awakens and activates
on.
 System on interrupt then runs another ISR.
 The ISR Routine is the device-driver write-
function for the outputs to printer through
the USB bus connected to the printer.
2015
Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design",
Raj Kamal, Publs.: McGraw-Hill Education
31
Mobile phone system
 Has a system reset key, which when pressed resets
the system to an initial state.
 When the reset key is pressed the system
awakens and activates a reset interrupt through a
hardware signal from the reset key.
 On the interrupt, an ISR (can also be considered as
reset-key device-driver function) suspends all
activity of the system, sends signal to display
function or program thread or task for displaying
the initial reset state menu and graphics on the
LCD screen, and also activates LCD display-off
timer device for 15 s timeout (for example).
2015
Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design",
Raj Kamal, Publs.: McGraw-Hill Education
32
After the timeout
 The system again awakens and activates on
interrupt through internal hardware signal
from the timer device and runs another ISR
to send a control bit to the LCD device.
 The ISR Routine is the device-driver LCD
off-function for the LCD device. The
devices switches off by reset of a control bit
in it.
2015
Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design",
Raj Kamal, Publs.: McGraw-Hill Education
33
Use of ISR in the mobile phone reset key interrupt example
Mobile
Keypad
events
input
processor
at mobile
Event:
Reset Key
pressed to
reset the
mobile
ISR_ResetKey
Read key state at
Port bits P0-P7
Reset key state
status bit
Sent message for
tasks
Signal timer start for
enabling display off
after 15 s (preset
time)
P0-P7
Reset event
Signal timer Tasks
Call
Return
1 2
4
4
Data bus
5
Interrupt
3
Sent message
for Tasks
2015
Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design",
Raj Kamal, Publs.: McGraw-Hill Education
34
Summary
2015
Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design",
Raj Kamal, Publs.: McGraw-Hill Education
35
We learnt
 Interrupt means event, which invites attention of
the processor for some action on hardware or
software interrupt instruction (SWI) event.
 When software run-time exception condition is
detected, either processor hardware or an SWI
generates an interrupt─ called software interrupt
or trap or exception.
 An embedded system executes many
actions or functions or tasks on the
interrupts from hardware or software.
2015
Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design",
Raj Kamal, Publs.: McGraw-Hill Education
36
We learnt
 An ISR call due to interrupt executes an
event. Event can occur at any moment and
event occurrences are asynchronous.
 Event can be a device or port event or
software computational exceptional
condition detected by hardware or
detected by a program, which throws the
exception. An event can be signaled by
soft interrupt instruction in routine.
 An interrupt service mechanism exists in a
system to call the ISRs from multiple
sources.
2015
Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design",
Raj Kamal, Publs.: McGraw-Hill Education
37
We learnt
 Interrupts and interrupt-service routines and
device-drivers play the major role in using the
embedded system hardware and devices.
 Interrupt examples of UART IO, ACVM,
Camera and mobile phone
2015
Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design",
Raj Kamal, Publs.: McGraw-Hill Education
38
End of Lesson 2 of Chapter 4
on
Interrupt and Interrupt Service Routine
Concept

More Related Content

Similar to Chap_6Lesson02Emsys3EInterruptBasedIOs.pdf

HKG15-300: Art's Quick Compiler: An unofficial overview
HKG15-300: Art's Quick Compiler: An unofficial overviewHKG15-300: Art's Quick Compiler: An unofficial overview
HKG15-300: Art's Quick Compiler: An unofficial overviewLinaro
 
How to Configure the CA Workload Automation System Agent agentparm.txt File
How to Configure the CA Workload Automation System Agent agentparm.txt FileHow to Configure the CA Workload Automation System Agent agentparm.txt File
How to Configure the CA Workload Automation System Agent agentparm.txt FileCA Technologies
 
Design the implementation of CDEx Robust DC Motor.
Design the implementation of CDEx Robust DC Motor.Design the implementation of CDEx Robust DC Motor.
Design the implementation of CDEx Robust DC Motor.Ankita Tiwari
 
Resume_Appaji
Resume_AppajiResume_Appaji
Resume_AppajiAppaji K
 
Lecture 07 virtual machine i
Lecture 07 virtual machine iLecture 07 virtual machine i
Lecture 07 virtual machine i鍾誠 陳鍾誠
 
Stream Processing with CompletableFuture and Flow in Java 9
Stream Processing with CompletableFuture and Flow in Java 9Stream Processing with CompletableFuture and Flow in Java 9
Stream Processing with CompletableFuture and Flow in Java 9Trayan Iliev
 
Arun Prasad-R.DOCX
Arun Prasad-R.DOCXArun Prasad-R.DOCX
Arun Prasad-R.DOCXArun R
 
NFF-GO (YANFF) - Yet Another Network Function Framework
NFF-GO (YANFF) - Yet Another Network Function FrameworkNFF-GO (YANFF) - Yet Another Network Function Framework
NFF-GO (YANFF) - Yet Another Network Function FrameworkMichelle Holley
 
A SURVEY OF VIRTUAL PROTOTYPING TECHNIQUES FOR SYSTEM DEVELOPMENT AND VALIDATION
A SURVEY OF VIRTUAL PROTOTYPING TECHNIQUES FOR SYSTEM DEVELOPMENT AND VALIDATIONA SURVEY OF VIRTUAL PROTOTYPING TECHNIQUES FOR SYSTEM DEVELOPMENT AND VALIDATION
A SURVEY OF VIRTUAL PROTOTYPING TECHNIQUES FOR SYSTEM DEVELOPMENT AND VALIDATIONIJCSES Journal
 
超級全能危樓改造王 - 增建、改建、打掉重建你的軟體架構?
超級全能危樓改造王 - 增建、改建、打掉重建你的軟體架構?超級全能危樓改造王 - 增建、改建、打掉重建你的軟體架構?
超級全能危樓改造王 - 增建、改建、打掉重建你的軟體架構?Pin-Ying Tu
 
Java Performance & Profiling
Java Performance & ProfilingJava Performance & Profiling
Java Performance & ProfilingIsuru Perera
 
Pitfalls of machine learning in production
Pitfalls of machine learning in productionPitfalls of machine learning in production
Pitfalls of machine learning in productionAntoine Sauray
 
Fine line between performance and security
Fine line between performance and securityFine line between performance and security
Fine line between performance and securityAlmudena Vivanco
 
Continuous (Non)-Functional Testing of Microservices on k8s
Continuous (Non)-Functional Testing of Microservices on k8s Continuous (Non)-Functional Testing of Microservices on k8s
Continuous (Non)-Functional Testing of Microservices on k8s QAware GmbH
 

Similar to Chap_6Lesson02Emsys3EInterruptBasedIOs.pdf (20)

HKG15-300: Art's Quick Compiler: An unofficial overview
HKG15-300: Art's Quick Compiler: An unofficial overviewHKG15-300: Art's Quick Compiler: An unofficial overview
HKG15-300: Art's Quick Compiler: An unofficial overview
 
RamachandraParlapalli_RESUME
RamachandraParlapalli_RESUMERamachandraParlapalli_RESUME
RamachandraParlapalli_RESUME
 
How to Configure the CA Workload Automation System Agent agentparm.txt File
How to Configure the CA Workload Automation System Agent agentparm.txt FileHow to Configure the CA Workload Automation System Agent agentparm.txt File
How to Configure the CA Workload Automation System Agent agentparm.txt File
 
Design the implementation of CDEx Robust DC Motor.
Design the implementation of CDEx Robust DC Motor.Design the implementation of CDEx Robust DC Motor.
Design the implementation of CDEx Robust DC Motor.
 
Intro-Soft-Engg-2.pptx
Intro-Soft-Engg-2.pptxIntro-Soft-Engg-2.pptx
Intro-Soft-Engg-2.pptx
 
Resume_Appaji
Resume_AppajiResume_Appaji
Resume_Appaji
 
Lecture 07 virtual machine i
Lecture 07 virtual machine iLecture 07 virtual machine i
Lecture 07 virtual machine i
 
Stream Processing with CompletableFuture and Flow in Java 9
Stream Processing with CompletableFuture and Flow in Java 9Stream Processing with CompletableFuture and Flow in Java 9
Stream Processing with CompletableFuture and Flow in Java 9
 
Arun Prasad-R.DOCX
Arun Prasad-R.DOCXArun Prasad-R.DOCX
Arun Prasad-R.DOCX
 
NFF-GO (YANFF) - Yet Another Network Function Framework
NFF-GO (YANFF) - Yet Another Network Function FrameworkNFF-GO (YANFF) - Yet Another Network Function Framework
NFF-GO (YANFF) - Yet Another Network Function Framework
 
A SURVEY OF VIRTUAL PROTOTYPING TECHNIQUES FOR SYSTEM DEVELOPMENT AND VALIDATION
A SURVEY OF VIRTUAL PROTOTYPING TECHNIQUES FOR SYSTEM DEVELOPMENT AND VALIDATIONA SURVEY OF VIRTUAL PROTOTYPING TECHNIQUES FOR SYSTEM DEVELOPMENT AND VALIDATION
A SURVEY OF VIRTUAL PROTOTYPING TECHNIQUES FOR SYSTEM DEVELOPMENT AND VALIDATION
 
超級全能危樓改造王 - 增建、改建、打掉重建你的軟體架構?
超級全能危樓改造王 - 增建、改建、打掉重建你的軟體架構?超級全能危樓改造王 - 增建、改建、打掉重建你的軟體架構?
超級全能危樓改造王 - 增建、改建、打掉重建你的軟體架構?
 
Cisco project ideas
Cisco   project ideasCisco   project ideas
Cisco project ideas
 
Java Performance & Profiling
Java Performance & ProfilingJava Performance & Profiling
Java Performance & Profiling
 
microprocessor
   microprocessor   microprocessor
microprocessor
 
ESL report
ESL reportESL report
ESL report
 
Pitfalls of machine learning in production
Pitfalls of machine learning in productionPitfalls of machine learning in production
Pitfalls of machine learning in production
 
Sarvesh_kumar
Sarvesh_kumarSarvesh_kumar
Sarvesh_kumar
 
Fine line between performance and security
Fine line between performance and securityFine line between performance and security
Fine line between performance and security
 
Continuous (Non)-Functional Testing of Microservices on k8s
Continuous (Non)-Functional Testing of Microservices on k8s Continuous (Non)-Functional Testing of Microservices on k8s
Continuous (Non)-Functional Testing of Microservices on k8s
 

Recently uploaded

Organizational Structure Running A Successful Business
Organizational Structure Running A Successful BusinessOrganizational Structure Running A Successful Business
Organizational Structure Running A Successful BusinessSeta Wicaksana
 
Vip Female Escorts Noida 9711199171 Greater Noida Escorts Service
Vip Female Escorts Noida 9711199171 Greater Noida Escorts ServiceVip Female Escorts Noida 9711199171 Greater Noida Escorts Service
Vip Female Escorts Noida 9711199171 Greater Noida Escorts Serviceankitnayak356677
 
NewBase 19 April 2024 Energy News issue - 1717 by Khaled Al Awadi.pdf
NewBase  19 April  2024  Energy News issue - 1717 by Khaled Al Awadi.pdfNewBase  19 April  2024  Energy News issue - 1717 by Khaled Al Awadi.pdf
NewBase 19 April 2024 Energy News issue - 1717 by Khaled Al Awadi.pdfKhaled Al Awadi
 
RE Capital's Visionary Leadership under Newman Leech
RE Capital's Visionary Leadership under Newman LeechRE Capital's Visionary Leadership under Newman Leech
RE Capital's Visionary Leadership under Newman LeechNewman George Leech
 
India Consumer 2024 Redacted Sample Report
India Consumer 2024 Redacted Sample ReportIndia Consumer 2024 Redacted Sample Report
India Consumer 2024 Redacted Sample ReportMintel Group
 
Digital Transformation in the PLM domain - distrib.pdf
Digital Transformation in the PLM domain - distrib.pdfDigital Transformation in the PLM domain - distrib.pdf
Digital Transformation in the PLM domain - distrib.pdfJos Voskuil
 
Global Scenario On Sustainable and Resilient Coconut Industry by Dr. Jelfina...
Global Scenario On Sustainable  and Resilient Coconut Industry by Dr. Jelfina...Global Scenario On Sustainable  and Resilient Coconut Industry by Dr. Jelfina...
Global Scenario On Sustainable and Resilient Coconut Industry by Dr. Jelfina...ictsugar
 
Marketing Management Business Plan_My Sweet Creations
Marketing Management Business Plan_My Sweet CreationsMarketing Management Business Plan_My Sweet Creations
Marketing Management Business Plan_My Sweet Creationsnakalysalcedo61
 
Lean: From Theory to Practice — One City’s (and Library’s) Lean Story… Abridged
Lean: From Theory to Practice — One City’s (and Library’s) Lean Story… AbridgedLean: From Theory to Practice — One City’s (and Library’s) Lean Story… Abridged
Lean: From Theory to Practice — One City’s (and Library’s) Lean Story… AbridgedKaiNexus
 
Cash Payment 9602870969 Escort Service in Udaipur Call Girls
Cash Payment 9602870969 Escort Service in Udaipur Call GirlsCash Payment 9602870969 Escort Service in Udaipur Call Girls
Cash Payment 9602870969 Escort Service in Udaipur Call GirlsApsara Of India
 
8447779800, Low rate Call girls in Saket Delhi NCR
8447779800, Low rate Call girls in Saket Delhi NCR8447779800, Low rate Call girls in Saket Delhi NCR
8447779800, Low rate Call girls in Saket Delhi NCRashishs7044
 
Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...
Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...
Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...lizamodels9
 
Intro to BCG's Carbon Emissions Benchmark_vF.pdf
Intro to BCG's Carbon Emissions Benchmark_vF.pdfIntro to BCG's Carbon Emissions Benchmark_vF.pdf
Intro to BCG's Carbon Emissions Benchmark_vF.pdfpollardmorgan
 
Keppel Ltd. 1Q 2024 Business Update Presentation Slides
Keppel Ltd. 1Q 2024 Business Update  Presentation SlidesKeppel Ltd. 1Q 2024 Business Update  Presentation Slides
Keppel Ltd. 1Q 2024 Business Update Presentation SlidesKeppelCorporation
 
Tech Startup Growth Hacking 101 - Basics on Growth Marketing
Tech Startup Growth Hacking 101  - Basics on Growth MarketingTech Startup Growth Hacking 101  - Basics on Growth Marketing
Tech Startup Growth Hacking 101 - Basics on Growth MarketingShawn Pang
 
Flow Your Strategy at Flight Levels Day 2024
Flow Your Strategy at Flight Levels Day 2024Flow Your Strategy at Flight Levels Day 2024
Flow Your Strategy at Flight Levels Day 2024Kirill Klimov
 
Call Girls Miyapur 7001305949 all area service COD available Any Time
Call Girls Miyapur 7001305949 all area service COD available Any TimeCall Girls Miyapur 7001305949 all area service COD available Any Time
Call Girls Miyapur 7001305949 all area service COD available Any Timedelhimodelshub1
 
(Best) ENJOY Call Girls in Faridabad Ex | 8377087607
(Best) ENJOY Call Girls in Faridabad Ex | 8377087607(Best) ENJOY Call Girls in Faridabad Ex | 8377087607
(Best) ENJOY Call Girls in Faridabad Ex | 8377087607dollysharma2066
 
Kenya’s Coconut Value Chain by Gatsby Africa
Kenya’s Coconut Value Chain by Gatsby AfricaKenya’s Coconut Value Chain by Gatsby Africa
Kenya’s Coconut Value Chain by Gatsby Africaictsugar
 
Pitch Deck Teardown: NOQX's $200k Pre-seed deck
Pitch Deck Teardown: NOQX's $200k Pre-seed deckPitch Deck Teardown: NOQX's $200k Pre-seed deck
Pitch Deck Teardown: NOQX's $200k Pre-seed deckHajeJanKamps
 

Recently uploaded (20)

Organizational Structure Running A Successful Business
Organizational Structure Running A Successful BusinessOrganizational Structure Running A Successful Business
Organizational Structure Running A Successful Business
 
Vip Female Escorts Noida 9711199171 Greater Noida Escorts Service
Vip Female Escorts Noida 9711199171 Greater Noida Escorts ServiceVip Female Escorts Noida 9711199171 Greater Noida Escorts Service
Vip Female Escorts Noida 9711199171 Greater Noida Escorts Service
 
NewBase 19 April 2024 Energy News issue - 1717 by Khaled Al Awadi.pdf
NewBase  19 April  2024  Energy News issue - 1717 by Khaled Al Awadi.pdfNewBase  19 April  2024  Energy News issue - 1717 by Khaled Al Awadi.pdf
NewBase 19 April 2024 Energy News issue - 1717 by Khaled Al Awadi.pdf
 
RE Capital's Visionary Leadership under Newman Leech
RE Capital's Visionary Leadership under Newman LeechRE Capital's Visionary Leadership under Newman Leech
RE Capital's Visionary Leadership under Newman Leech
 
India Consumer 2024 Redacted Sample Report
India Consumer 2024 Redacted Sample ReportIndia Consumer 2024 Redacted Sample Report
India Consumer 2024 Redacted Sample Report
 
Digital Transformation in the PLM domain - distrib.pdf
Digital Transformation in the PLM domain - distrib.pdfDigital Transformation in the PLM domain - distrib.pdf
Digital Transformation in the PLM domain - distrib.pdf
 
Global Scenario On Sustainable and Resilient Coconut Industry by Dr. Jelfina...
Global Scenario On Sustainable  and Resilient Coconut Industry by Dr. Jelfina...Global Scenario On Sustainable  and Resilient Coconut Industry by Dr. Jelfina...
Global Scenario On Sustainable and Resilient Coconut Industry by Dr. Jelfina...
 
Marketing Management Business Plan_My Sweet Creations
Marketing Management Business Plan_My Sweet CreationsMarketing Management Business Plan_My Sweet Creations
Marketing Management Business Plan_My Sweet Creations
 
Lean: From Theory to Practice — One City’s (and Library’s) Lean Story… Abridged
Lean: From Theory to Practice — One City’s (and Library’s) Lean Story… AbridgedLean: From Theory to Practice — One City’s (and Library’s) Lean Story… Abridged
Lean: From Theory to Practice — One City’s (and Library’s) Lean Story… Abridged
 
Cash Payment 9602870969 Escort Service in Udaipur Call Girls
Cash Payment 9602870969 Escort Service in Udaipur Call GirlsCash Payment 9602870969 Escort Service in Udaipur Call Girls
Cash Payment 9602870969 Escort Service in Udaipur Call Girls
 
8447779800, Low rate Call girls in Saket Delhi NCR
8447779800, Low rate Call girls in Saket Delhi NCR8447779800, Low rate Call girls in Saket Delhi NCR
8447779800, Low rate Call girls in Saket Delhi NCR
 
Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...
Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...
Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...
 
Intro to BCG's Carbon Emissions Benchmark_vF.pdf
Intro to BCG's Carbon Emissions Benchmark_vF.pdfIntro to BCG's Carbon Emissions Benchmark_vF.pdf
Intro to BCG's Carbon Emissions Benchmark_vF.pdf
 
Keppel Ltd. 1Q 2024 Business Update Presentation Slides
Keppel Ltd. 1Q 2024 Business Update  Presentation SlidesKeppel Ltd. 1Q 2024 Business Update  Presentation Slides
Keppel Ltd. 1Q 2024 Business Update Presentation Slides
 
Tech Startup Growth Hacking 101 - Basics on Growth Marketing
Tech Startup Growth Hacking 101  - Basics on Growth MarketingTech Startup Growth Hacking 101  - Basics on Growth Marketing
Tech Startup Growth Hacking 101 - Basics on Growth Marketing
 
Flow Your Strategy at Flight Levels Day 2024
Flow Your Strategy at Flight Levels Day 2024Flow Your Strategy at Flight Levels Day 2024
Flow Your Strategy at Flight Levels Day 2024
 
Call Girls Miyapur 7001305949 all area service COD available Any Time
Call Girls Miyapur 7001305949 all area service COD available Any TimeCall Girls Miyapur 7001305949 all area service COD available Any Time
Call Girls Miyapur 7001305949 all area service COD available Any Time
 
(Best) ENJOY Call Girls in Faridabad Ex | 8377087607
(Best) ENJOY Call Girls in Faridabad Ex | 8377087607(Best) ENJOY Call Girls in Faridabad Ex | 8377087607
(Best) ENJOY Call Girls in Faridabad Ex | 8377087607
 
Kenya’s Coconut Value Chain by Gatsby Africa
Kenya’s Coconut Value Chain by Gatsby AfricaKenya’s Coconut Value Chain by Gatsby Africa
Kenya’s Coconut Value Chain by Gatsby Africa
 
Pitch Deck Teardown: NOQX's $200k Pre-seed deck
Pitch Deck Teardown: NOQX's $200k Pre-seed deckPitch Deck Teardown: NOQX's $200k Pre-seed deck
Pitch Deck Teardown: NOQX's $200k Pre-seed deck
 

Chap_6Lesson02Emsys3EInterruptBasedIOs.pdf

  • 1. 2015 Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 1 DEVICE DRIVERS AND INTERRUPTS SERVICE MECHANISM Lesson-2: Interrupt and Interrupt Service Routine Concept
  • 2. 2015 Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 2 • Interrupt means event, which invites attention of the processor on occurrence of some action at hardware or software interrupt instruction event. Interrupt Concept
  • 3. 2015 Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 3 Action on Interrupt  In response to the interrupt, a routine or program (called foreground program), which is running presently interrupts and an interrupt service routine (ISR) executes.
  • 4. 2015 Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 4 Interrupt Service Routine  ISR is also called device driver in case of the devices and called exception or signal or trap handler in case of software interrupts
  • 5. 2015 Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 5 Interrupt approach for the port or device functions  Processor executes the program, called interrupt service routine or signal handler or trap handler or exception handler or device driver, related to input or output from the port or device or related to a device function on an interrupt and does not wait and look for the input ready or output completion or device-status ready or set
  • 6. 2015 Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 6 Hardware interrupt  Examples─ When a device or port is ready, a device or port generates an interrupt, or when it completes the assigned action or when a timer overflows or when a time at the timer equals a preset time in a compare register or on setting a status flag (for example, on timer overflow or compare or capture of time) or on click of mice in a computer  Hardware interrupt generates a call to an ISR
  • 7. 2015 Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 7 Software Interrupt Examples  When software run-time exception condition (for examples, division by 0 or overflow or illegal opcode detected) the processor-hardware generates an interrupt, called trap, which calls an ISR  When software run-time exception condition defined in a program occurs, then a software instruction (SWI) is executed─ called software interrupt or exception or signal, which calls an ISR .
  • 8. 2015 Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 8 Software Interrupt  When a device function is to be invoked, for example, open (initialize/configure) or read or write or close , then a software instruction (SWI) executes─ called software interrupt to execute the required device driver function for opening or reading or writing or closing operations.
  • 9. 2015 Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 9 Interrupt  Software can execute the software instruction (SWI) or Interrupt n (INT n) to signal execution of ISR (interrupt service routine). The n is as per the handler address.  Signal interrupt [The signal differs from the function in the sense that execution of signal handler (ISR) can be masked and till mask is reset, the handler will not execute on interrupt. Function on the other hand always executes on the call after a call-instruction.]
  • 10. 2015 Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 10 Interrupt Driven Actions On Interrupt Interrupt Service Routine (ISR) Running Program Return No continuous checks of device status
  • 11. 2015 Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 11 How does call to ISR differ from a function (routine) call?
  • 12. 2015 Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 12 Routine (function) and ISR call features  On a function call, the instructions are executed from a new address  Execute like in as function in the ‘C’ or in a method in Java.  ISR also the instructions are executed from a new address like in as function in the ‘C’ or in a method in Java
  • 13. 2015 Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 13 Routine (function) call and ISR call features  A function call is after executing present instruction in any program and is a planned (user programmed) diversion from the present instruction in sequence of instructions to another sequence of instructions; this sequence of instructions executes till the return from that.  An ISR call is after executing present instruction in any program and is interrupt related diversion from the current sequence of instructions to another sequence of instructions; this sequence of instructions executes till the return from that or till another interrupt of higher priority
  • 14. 2015 Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 14 Nesting of function calls and ISRs  Nesting the function-calls ─ When a function 1 calls another function 2 and that call another function 3, on return from 3, the return is to function 2 and return from 2 is to function. Functions are said to be nested  The ISR calls in case of multiple interrupt occurrences can be nested or can be as per priority of the interrupts
  • 15. 2015 Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 15 Using the Interrupt(s) and ISR(s) for each device function (for example, read, write) - Use of ISRs (Interrupt Service Routine) by SWIs is the main mechanism used for the device accesses and actions
  • 16. 2015 Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 16 1. There is no continuous monitoring of the status bits or polling for status by the application. 2. Between two interrupt calls the program task(s) continue. There are many device- functions, and each of which executes on a device interrupt. Interrupt driven IO and device accesses feature
  • 17. 2015 Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 17 Example─ A 64-kbps UART Input  When a UART transmits in format of 11-bit per character format, the network transmits at most 64 kbps  11 = 5818 characters per second, which means every 171.9 s a character is expected.  Before 171.9 s, the receiver port is not checked. Only on interrupt from the port the character is read  There is no in-between time-gap for polling
  • 18. 2015 Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 18 Ports A and B with interrupt generation and interrupt service (handling) mechanism  Port A be at in a System, and port B be its modem input which puts the characters on the telephone line.  Let ISR_ PortA_Character be a routine that receives an input character from Port A on interrupt and Out_B routine re-transmits an output character to Port B.
  • 19. 2015 Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 19 ISR_ PortA _Character  Step f function (vi): Read Port A character. Reset the status bit so that modem is ready for next character input (generally resetting of status bit is automatic without need of specific instruction for it). Put it in memory buffer. Memory buffer is a set of memory addresses where the bytes (characters) are queued for processing later.  Return from the interrupt service routine.
  • 20. 2015 Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 20 ISR_ PortA _Character On interrupt call ISR_ PortA _Character Save System, status word and registers (current program context) on stack Step f Execute function vi codes (read character, reset port status bit, character save in memory buffer) Return (retrieve the saved context) Current program
  • 21. 2015 Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 21 Out_B routine • Step g: Call function (vii) to decrypt the message characters at the memory buffer and return for next instruction step h. • Step h: Call function (viii) to encode the message character and return for next instruction step k • Step k: Call function (ix) to transmit the encoded character to Port B • Return from the function.
  • 22. 2015 Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 22 Out_B Routine Out_B Routine Step g Step h Step k Each step has three parts, save context, execute codes, and retrieve the context for return
  • 23. 2015 Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 23 Application of Interrupt based IOs and device functions  In case of multiple processes and device functions with no device status polling or wait
  • 24. 2015 Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 24 An automatic chocolate vending machine (ACVM)  Without interrupt mechanism, one way is the ‘programmed I/O- transfer in which that the device waits for the coin continuously, activates on sensing the coin and runs the service routine  In the event driven way is that the device should also awakens and activates on each interrupt after sensing each coin-inserting event.
  • 25. 2015 Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 25 Interrupt-service routine (ISR) or device driver function  The system awakens and activates on an interrupt through a hardware or software signal. The system on port interrupt collects the coin by running a service routine. This routine is called interrupt handler routine for the coin-port read.
  • 26. 2015 Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 26 Use of ISR in the ACVM example Coin event input processor at a device Event: Coin insertion, sorting and coin amount (1 or 2 or 5 or 10) sent to an input port PA) ISR_CoinRead Read port P0- P3 bits Reset port status Save amount at a memory buffer Signal a task PA0- PA3 Coin event Signal AVCM System ISRs and Tasks Call Return 1 2 3 Data bus 4
  • 27. 2015 Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 27 Digital camera system  Has an image input device.  The system awakens and activates on interrupt from a switch.  When the system wakes up and activates, the device should grab an image frame data.  The interrupt is through a hardware signal from the device switch. On the interrupt, an ISR (can also be considered as camera’s imaging device- driver function) for the read starts execution, it passes a message (signal) to a function or program thread or task
  • 28. 2015 Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 28 Image sense and device frame-buffer  The thread senses the image and then the function reads the device frame-buffer (called frame grabbing),  then the function passes a signal to another function or program thread or task to process and compress the image data and save the image frame data compressed file in a flash memory
  • 29. 2015 Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 29 Use of ISR in the digital camera example Keyed events input processor at camera Event: Key pressed to take a picture and pressed key code sent at port ISR_FrameRead Start ADC scan Signal task read frame status and data of all pixels of image frame at CCD co-processor Signal task for saving pixels data at a frame memory buffer Signal a CCD co- processor task for subtracting offsets PA0- PA3 Shoot start event Signals camera System Tasks Call Return 1 2 4 4 Data bus 6 Interrupt 5 3 To CCD pixels ADC scan
  • 30. 2015 Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 30 Interrupt through a hardware signal from a print-switch at device  Camera system again awakens and activates on.  System on interrupt then runs another ISR.  The ISR Routine is the device-driver write- function for the outputs to printer through the USB bus connected to the printer.
  • 31. 2015 Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 31 Mobile phone system  Has a system reset key, which when pressed resets the system to an initial state.  When the reset key is pressed the system awakens and activates a reset interrupt through a hardware signal from the reset key.  On the interrupt, an ISR (can also be considered as reset-key device-driver function) suspends all activity of the system, sends signal to display function or program thread or task for displaying the initial reset state menu and graphics on the LCD screen, and also activates LCD display-off timer device for 15 s timeout (for example).
  • 32. 2015 Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 32 After the timeout  The system again awakens and activates on interrupt through internal hardware signal from the timer device and runs another ISR to send a control bit to the LCD device.  The ISR Routine is the device-driver LCD off-function for the LCD device. The devices switches off by reset of a control bit in it.
  • 33. 2015 Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 33 Use of ISR in the mobile phone reset key interrupt example Mobile Keypad events input processor at mobile Event: Reset Key pressed to reset the mobile ISR_ResetKey Read key state at Port bits P0-P7 Reset key state status bit Sent message for tasks Signal timer start for enabling display off after 15 s (preset time) P0-P7 Reset event Signal timer Tasks Call Return 1 2 4 4 Data bus 5 Interrupt 3 Sent message for Tasks
  • 34. 2015 Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 34 Summary
  • 35. 2015 Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 35 We learnt  Interrupt means event, which invites attention of the processor for some action on hardware or software interrupt instruction (SWI) event.  When software run-time exception condition is detected, either processor hardware or an SWI generates an interrupt─ called software interrupt or trap or exception.  An embedded system executes many actions or functions or tasks on the interrupts from hardware or software.
  • 36. 2015 Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 36 We learnt  An ISR call due to interrupt executes an event. Event can occur at any moment and event occurrences are asynchronous.  Event can be a device or port event or software computational exceptional condition detected by hardware or detected by a program, which throws the exception. An event can be signaled by soft interrupt instruction in routine.  An interrupt service mechanism exists in a system to call the ISRs from multiple sources.
  • 37. 2015 Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 37 We learnt  Interrupts and interrupt-service routines and device-drivers play the major role in using the embedded system hardware and devices.  Interrupt examples of UART IO, ACVM, Camera and mobile phone
  • 38. 2015 Chapter 6 L2: "Embedded Systems- Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 38 End of Lesson 2 of Chapter 4 on Interrupt and Interrupt Service Routine Concept