SlideShare une entreprise Scribd logo
1  sur  38
Télécharger pour lire hors ligne
DEVICE DRIVERS AND INTERRUPTS
        SERVICE MECHANISM
Lesson-2: Interrupt and Interrupt Service
            Routine Concept



           Chapter-4 L02: "Embedded Systems - " , Raj Kamal,
2008                                                           1
                     Publs.: McGraw-Hill Education
Interrupt Concept
•      Interrupt means event, which invites
       attention of the processor on occurrence of
       some action at hardware or software
       interrupt instruction event.




               Chapter-4 L02: "Embedded Systems - " , Raj Kamal,
2008                                                               2
                         Publs.: McGraw-Hill Education
Action on Interrupt

   In response to the interrupt, the routine or
   program, which is running presently
   interrupts and an interrupt service routine
   (ISR) executes.




              Chapter-4 L02: "Embedded Systems - " , Raj Kamal,
2008                                                              3
                        Publs.: McGraw-Hill Education
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




             Chapter-4 L02: "Embedded Systems - " , Raj Kamal,
2008                                                             4
                       Publs.: McGraw-Hill Education
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
                Chapter-4 L02: "Embedded Systems - " , Raj Kamal,
2008                                                                5
                          Publs.: McGraw-Hill Education
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 call to an ISR

             Chapter-4 L02: "Embedded Systems - " , Raj Kamal,
2008                                                             6
                       Publs.: McGraw-Hill Education
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 .

              Chapter-4 L02: "Embedded Systems - " , Raj Kamal,
2008                                                              7
                        Publs.: McGraw-Hill Education
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) is executed─ called
   software interrupt to execute the required
   device driver function for open or read or
   write or close operations.



             Chapter-4 L02: "Embedded Systems - " , Raj Kamal,
2008                                                             8
                       Publs.: McGraw-Hill Education
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.]
               Chapter-4 L02: "Embedded Systems - " , Raj Kamal,
2008                                                               9
                         Publs.: McGraw-Hill Education
Interrupt Driven Actions


                   On Interrupt                   Interrupt Service
Running                                           Routine (ISR)
Program               Return




       No continuous checks of device status


               Chapter-4 L02: "Embedded Systems - " , Raj Kamal,
2008                                                               10
                         Publs.: McGraw-Hill Education
How does call to ISR differ from a function
                (routine) call?




            Chapter-4 L02: "Embedded Systems - " , Raj Kamal,
2008                                                            11
                      Publs.: McGraw-Hill Education
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




              Chapter-4 L02: "Embedded Systems - " , Raj Kamal,
2008                                                              12
                        Publs.: McGraw-Hill Education
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
                Chapter-4 L02: "Embedded Systems - " , Raj Kamal,
2008                                                                13
                          Publs.: McGraw-Hill Education
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
             Chapter-4 L02: "Embedded Systems - " , Raj Kamal,
2008                                                             14
                       Publs.: McGraw-Hill Education
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

           Chapter-4 L02: "Embedded Systems - " , Raj Kamal,
2008                                                           15
                     Publs.: McGraw-Hill Education
Interrupt driven IO and device accesses
                    feature
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.


            Chapter-4 L02: "Embedded Systems - " , Raj Kamal,
2008                                                            16
                      Publs.: McGraw-Hill Education
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

             Chapter-4 L02: "Embedded Systems - " , Raj Kamal,
2008                                                             17
                       Publs.: McGraw-Hill Education
Ports A and B with interrupt generation and
    interrupt service (handling) mechanism

   Port A be at in a PC, 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.


             Chapter-4 L02: "Embedded Systems - " , Raj Kamal,
2008                                                             18
                       Publs.: McGraw-Hill Education
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.
              Chapter-4 L02: "Embedded Systems - " , Raj Kamal,
2008                                                              19
                        Publs.: McGraw-Hill Education
ISR_ PortA _Character

                    Current program


       On interrupt call ISR_ PortA _Character
                          Step f
        Save PC, status word and registers (current
        program context) on stack
         Execute function vi codes (read character,
         reset port status bit, character save in
         memory buffer)
         ReturnChapter-4 L02: "Embedded Systems - " , Raj Kamal,
                (retrieve the saved context)
2008                                                               20
                           Publs.: McGraw-Hill Education
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.
             Chapter-4 L02: "Embedded Systems - " , Raj Kamal,
2008                                                             21
                       Publs.: McGraw-Hill Education
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

                 Chapter-4 L02: "Embedded Systems - " , Raj Kamal,
  2008                                                               22
                           Publs.: McGraw-Hill Education
Application of Interrupt based IOs and device
                  functions

   In case of multiple processes and device
   functions with no device status polling or
   wait




             Chapter-4 L02: "Embedded Systems - " , Raj Kamal,
2008                                                             23
                       Publs.: McGraw-Hill Education
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.




                Chapter-4 L02: "Embedded Systems - " , Raj Kamal,
2008                                                                24
                          Publs.: McGraw-Hill Education
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.



                Chapter-4 L02: "Embedded Systems - " , Raj Kamal,
2008                                                                25
                          Publs.: McGraw-Hill Education
Use of ISR in the ACVM example
                1                     2     ISR_CoinRead
                         Coin
   Coin event            event     Call     Read port P0-
Event: Coin              input              P3 bits
insertion,               processor          Reset       port
sorting and PA0-         at a      Data bus
                                            status
coin amount PA3          device             Save amount at
(1 or 2 or 5                                a       memory
or 10) sent                        Return   buffer
to an input                             4   Signal a task
port PA)                                                      3
                                                              Signal AVCM
                                                              System ISRs and
                                                              Tasks
                Chapter-4 L02: "Embedded Systems - " , Raj Kamal,
2008                                                                      26
                          Publs.: McGraw-Hill Education
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

              Chapter-4 L02: "Embedded Systems - " , Raj Kamal,
2008                                                              27
                        Publs.: McGraw-Hill Education
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

               Chapter-4 L02: "Embedded Systems - " , Raj Kamal,
2008                                                               28
                         Publs.: McGraw-Hill Education
Use of ISR in the digital camera example
              Interrupt
   Shoot start 1          Keyed        2     ISR_FrameRead
                                             Start ADC scan
   event                  events    Call     Signal task read
Event: Key                input              frame status and
pressed to                processor          data of all pixels
take a        PA0-        at camera Data bus of image frame at
picture and PA3                         6
                                             CCD co-processor
                                             Signal task for
pressed key                                               saving pixels data
code sent at                              Return
                                                          at a frame memory
port                                                      buffer
                                                          Signal a CCD co-
                                      4
                                                          processor task for
                                                    3     subtracting offsets
            To CCD pixels ADC scan
                                                                4  5
                                             Signals camera System Tasks
                 Chapter-4 L02: "Embedded Systems - " , Raj Kamal,
2008                                                                            29
                          Publs.: McGraw-Hill Education
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.


             Chapter-4 L02: "Embedded Systems - " , Raj Kamal,
2008                                                             30
                       Publs.: McGraw-Hill Education
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).
               Chapter-4 L02: "Embedded Systems - " , Raj Kamal,
2008                                                               31
                         Publs.: McGraw-Hill Education
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.


                 Chapter-4 L02: "Embedded Systems - " , Raj Kamal,
2008                                                                 32
                           Publs.: McGraw-Hill Education
Use of ISR in the mobile phone reset key interrupt example
              Interrupt
    Reset event 1       Mobile       2     ISR_ResetKey
                                           Read key state at
                        Keypad Call        Port bits P0-P7
 Event:                 events             Reset key state
 Reset Key              input              status bit
 pressed to P0-P7       processor Data bus Sent message for
                        at mobile          tasks
 reset the                            5    Signal timer start
 mobile                                    for enabling display
                                  Return
                                                             off after 15 s (preset
                                                             time)
                                        4


                                                       4        3
                                       Signal timer Tasks Sent message
                                                          for Tasks
                  Chapter-4 L02: "Embedded Systems - " , Raj Kamal,
 2008                                                                             33
                            Publs.: McGraw-Hill Education
Summary




       Chapter-4 L02: "Embedded Systems - " , Raj Kamal,
2008                                                       34
                 Publs.: McGraw-Hill Education
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.

               Chapter-4 L02: "Embedded Systems - " , Raj Kamal,
2008                                                               35
                         Publs.: McGraw-Hill Education
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.
            Chapter-4 L02: "Embedded Systems - " , Raj Kamal,
2008                                                            36
                      Publs.: McGraw-Hill Education
We learnt

 Interrupts and interrupt-service routines
 (device-drivers) play the major role in using
 the embedded system hardware and devices.
 Interrupt examples of UART IO, ACVM,
 Camera and mobile phone




             Chapter-4 L02: "Embedded Systems - " , Raj Kamal,
 2008                                                            37
                       Publs.: McGraw-Hill Education
End of Lesson 2 of Chapter 4




             Chapter-4 L02: "Embedded Systems - " , Raj Kamal,
2008                                                             38
                       Publs.: McGraw-Hill Education

Contenu connexe

Tendances

Limitation of conventional tubes
Limitation of conventional tubesLimitation of conventional tubes
Limitation of conventional tubesDiLip ChauDhary
 
Device drivers and interrupt service mechanism
Device drivers and interrupt service mechanismDevice drivers and interrupt service mechanism
Device drivers and interrupt service mechanismVijay Kumar
 
Branching instructions in 8086 microprocessor
Branching instructions in 8086 microprocessorBranching instructions in 8086 microprocessor
Branching instructions in 8086 microprocessorRabin BK
 
Fourier Transform ,LAPLACE TRANSFORM,ROC and its Properties
Fourier Transform ,LAPLACE TRANSFORM,ROC and its Properties Fourier Transform ,LAPLACE TRANSFORM,ROC and its Properties
Fourier Transform ,LAPLACE TRANSFORM,ROC and its Properties Dr.SHANTHI K.G
 
Interrupt in real time system
Interrupt in real time system Interrupt in real time system
Interrupt in real time system ali jawad
 
Peephole optimization techniques in compiler design
Peephole optimization techniques in compiler designPeephole optimization techniques in compiler design
Peephole optimization techniques in compiler designAnul Chaudhary
 
Broadside array vs end fire array
Broadside array vs end fire arrayBroadside array vs end fire array
Broadside array vs end fire arrayAJAL A J
 
8086 microprocessor-architecture
8086 microprocessor-architecture8086 microprocessor-architecture
8086 microprocessor-architectureprasadpawaskar
 
Corba introduction and simple example
Corba introduction and simple example Corba introduction and simple example
Corba introduction and simple example Alexia Wang
 
8051 Microcontroller I/O ports
8051 Microcontroller I/O ports8051 Microcontroller I/O ports
8051 Microcontroller I/O portsanishgoel
 
Reference model of real time system
Reference model of real time systemReference model of real time system
Reference model of real time systemKamal Acharya
 
ARM7-ARCHITECTURE
ARM7-ARCHITECTURE ARM7-ARCHITECTURE
ARM7-ARCHITECTURE Dr.YNM
 
Embedded Firmware Design and Development, and EDLC
Embedded Firmware Design and Development, and EDLCEmbedded Firmware Design and Development, and EDLC
Embedded Firmware Design and Development, and EDLCJuliaAndrews11
 
M ary psk and m ary qam ppt
M ary psk and m ary qam pptM ary psk and m ary qam ppt
M ary psk and m ary qam pptDANISHAMIN950
 

Tendances (20)

Limitation of conventional tubes
Limitation of conventional tubesLimitation of conventional tubes
Limitation of conventional tubes
 
Device drivers and interrupt service mechanism
Device drivers and interrupt service mechanismDevice drivers and interrupt service mechanism
Device drivers and interrupt service mechanism
 
Magic tee
Magic tee  Magic tee
Magic tee
 
Branching instructions in 8086 microprocessor
Branching instructions in 8086 microprocessorBranching instructions in 8086 microprocessor
Branching instructions in 8086 microprocessor
 
Fourier Transform ,LAPLACE TRANSFORM,ROC and its Properties
Fourier Transform ,LAPLACE TRANSFORM,ROC and its Properties Fourier Transform ,LAPLACE TRANSFORM,ROC and its Properties
Fourier Transform ,LAPLACE TRANSFORM,ROC and its Properties
 
Interrupt in real time system
Interrupt in real time system Interrupt in real time system
Interrupt in real time system
 
Peephole optimization techniques in compiler design
Peephole optimization techniques in compiler designPeephole optimization techniques in compiler design
Peephole optimization techniques in compiler design
 
Chapter4
Chapter4Chapter4
Chapter4
 
Broadside array vs end fire array
Broadside array vs end fire arrayBroadside array vs end fire array
Broadside array vs end fire array
 
Direct linking loaders
Direct linking loadersDirect linking loaders
Direct linking loaders
 
8086 microprocessor-architecture
8086 microprocessor-architecture8086 microprocessor-architecture
8086 microprocessor-architecture
 
boolean 8051
boolean 8051boolean 8051
boolean 8051
 
Corba introduction and simple example
Corba introduction and simple example Corba introduction and simple example
Corba introduction and simple example
 
8051 Microcontroller I/O ports
8051 Microcontroller I/O ports8051 Microcontroller I/O ports
8051 Microcontroller I/O ports
 
Reference model of real time system
Reference model of real time systemReference model of real time system
Reference model of real time system
 
Interrupts
InterruptsInterrupts
Interrupts
 
Architecture of 8085
Architecture of  8085Architecture of  8085
Architecture of 8085
 
ARM7-ARCHITECTURE
ARM7-ARCHITECTURE ARM7-ARCHITECTURE
ARM7-ARCHITECTURE
 
Embedded Firmware Design and Development, and EDLC
Embedded Firmware Design and Development, and EDLCEmbedded Firmware Design and Development, and EDLC
Embedded Firmware Design and Development, and EDLC
 
M ary psk and m ary qam ppt
M ary psk and m ary qam pptM ary psk and m ary qam ppt
M ary psk and m ary qam ppt
 

En vedette

Presentation819
Presentation819Presentation819
Presentation819kaedwards2
 
Tugas 7 ku– 0316 1311511529
Tugas 7   ku– 0316 1311511529Tugas 7   ku– 0316 1311511529
Tugas 7 ku– 0316 1311511529Iich-oNe Hidayat
 
Swadeshi apnavo presentation(Gujarati) by sanjay gurjar [compatibility mode]
Swadeshi apnavo presentation(Gujarati) by sanjay gurjar  [compatibility mode]Swadeshi apnavo presentation(Gujarati) by sanjay gurjar  [compatibility mode]
Swadeshi apnavo presentation(Gujarati) by sanjay gurjar [compatibility mode]Sanjay Gurjar
 
Launch the distribution for spice mobiles in bangladesh
Launch the distribution for spice mobiles in bangladeshLaunch the distribution for spice mobiles in bangladesh
Launch the distribution for spice mobiles in bangladeshriteshrajamba
 
Managerial skill ss ppt
Managerial skill ss pptManagerial skill ss ppt
Managerial skill ss pptSachin Mukati
 
手持互動學習系統功能及流程
手持互動學習系統功能及流程手持互動學習系統功能及流程
手持互動學習系統功能及流程正中 邵
 
8051microcontroller
8051microcontroller 8051microcontroller
8051microcontroller manish080
 
Powerpoint kombis 1
Powerpoint kombis 1Powerpoint kombis 1
Powerpoint kombis 1Rio Ozoners
 
Prerna sharma
Prerna sharmaPrerna sharma
Prerna sharmaRCET
 
LinkedIn SlideShare: Knowledge, Well-Presented
LinkedIn SlideShare: Knowledge, Well-PresentedLinkedIn SlideShare: Knowledge, Well-Presented
LinkedIn SlideShare: Knowledge, Well-PresentedSlideShare
 

En vedette (15)

Presentation819
Presentation819Presentation819
Presentation819
 
Tugas 7 ku– 0316 1311511529
Tugas 7   ku– 0316 1311511529Tugas 7   ku– 0316 1311511529
Tugas 7 ku– 0316 1311511529
 
Tugas 2 – 0316
Tugas 2 – 0316Tugas 2 – 0316
Tugas 2 – 0316
 
Swadeshi apnavo presentation(Gujarati) by sanjay gurjar [compatibility mode]
Swadeshi apnavo presentation(Gujarati) by sanjay gurjar  [compatibility mode]Swadeshi apnavo presentation(Gujarati) by sanjay gurjar  [compatibility mode]
Swadeshi apnavo presentation(Gujarati) by sanjay gurjar [compatibility mode]
 
Launch the distribution for spice mobiles in bangladesh
Launch the distribution for spice mobiles in bangladeshLaunch the distribution for spice mobiles in bangladesh
Launch the distribution for spice mobiles in bangladesh
 
Managerial skill ss ppt
Managerial skill ss pptManagerial skill ss ppt
Managerial skill ss ppt
 
手持互動學習系統功能及流程
手持互動學習系統功能及流程手持互動學習系統功能及流程
手持互動學習系統功能及流程
 
Tugas 5 ku– 0316
Tugas 5   ku– 0316Tugas 5   ku– 0316
Tugas 5 ku– 0316
 
Rohan ppt
Rohan pptRohan ppt
Rohan ppt
 
8051microcontroller
8051microcontroller 8051microcontroller
8051microcontroller
 
Serial buses
Serial busesSerial buses
Serial buses
 
Powerpoint kombis 1
Powerpoint kombis 1Powerpoint kombis 1
Powerpoint kombis 1
 
Prerna sharma
Prerna sharmaPrerna sharma
Prerna sharma
 
Embedded system
Embedded systemEmbedded system
Embedded system
 
LinkedIn SlideShare: Knowledge, Well-Presented
LinkedIn SlideShare: Knowledge, Well-PresentedLinkedIn SlideShare: Knowledge, Well-Presented
LinkedIn SlideShare: Knowledge, Well-Presented
 

Similaire à Chap 4 lesson02emsysnewinterruptbasedi_os

Chap_6Lesson02Emsys3EInterruptBasedIOs.pdf
Chap_6Lesson02Emsys3EInterruptBasedIOs.pdfChap_6Lesson02Emsys3EInterruptBasedIOs.pdf
Chap_6Lesson02Emsys3EInterruptBasedIOs.pdfMAHESHV559910
 
A jade implemented mobile agent based host platform security
A jade implemented mobile agent based host platform securityA jade implemented mobile agent based host platform security
A jade implemented mobile agent based host platform securityAlexander Decker
 
DEALING WITH FREQUENT TERMINATES IN SYNCHRONIZED DEPENDENCY RECOVERY LINE COM...
DEALING WITH FREQUENT TERMINATES IN SYNCHRONIZED DEPENDENCY RECOVERY LINE COM...DEALING WITH FREQUENT TERMINATES IN SYNCHRONIZED DEPENDENCY RECOVERY LINE COM...
DEALING WITH FREQUENT TERMINATES IN SYNCHRONIZED DEPENDENCY RECOVERY LINE COM...IAEME Publication
 
Jpl coding standard for the c programming language
Jpl coding standard for the c programming languageJpl coding standard for the c programming language
Jpl coding standard for the c programming languageKwanghee Choi
 
Chap 01 lesson_2emsys
Chap 01 lesson_2emsysChap 01 lesson_2emsys
Chap 01 lesson_2emsysarunsaras08
 
Linux Assignment 3
Linux Assignment 3Linux Assignment 3
Linux Assignment 3Diane Allen
 
Summerinternship
SummerinternshipSummerinternship
SummerinternshipKiran Kumar
 
TechnoScripts- Free Interview Preparation Q & A Set.pdf
TechnoScripts- Free Interview Preparation Q & A Set.pdfTechnoScripts- Free Interview Preparation Q & A Set.pdf
TechnoScripts- Free Interview Preparation Q & A Set.pdfTechnoscriptsPunesNo
 
GJIMT BCA P4UGCA1932U3L6.pptx
GJIMT BCA P4UGCA1932U3L6.pptxGJIMT BCA P4UGCA1932U3L6.pptx
GJIMT BCA P4UGCA1932U3L6.pptxParamjit24
 
International Journal of Computational Engineering Research(IJCER)
International Journal of Computational Engineering Research(IJCER)International Journal of Computational Engineering Research(IJCER)
International Journal of Computational Engineering Research(IJCER)ijceronline
 
Introduction to llvm
Introduction to llvmIntroduction to llvm
Introduction to llvmTao He
 
Device Drivers
Device DriversDevice Drivers
Device DriversSuhas S R
 
Open Programmable Architecture for Java-enabled Network Devices
Open Programmable Architecture for Java-enabled Network DevicesOpen Programmable Architecture for Java-enabled Network Devices
Open Programmable Architecture for Java-enabled Network DevicesTal Lavian Ph.D.
 
RTOS implementation
RTOS implementationRTOS implementation
RTOS implementationRajan Kumar
 
CS304PC:Computer Organization and Architecture Session 15 program control.pptx
CS304PC:Computer Organization and Architecture Session 15 program control.pptxCS304PC:Computer Organization and Architecture Session 15 program control.pptx
CS304PC:Computer Organization and Architecture Session 15 program control.pptxAsst.prof M.Gokilavani
 
Chap 6 lesson5emsysnewstatemachinefsm
Chap 6 lesson5emsysnewstatemachinefsmChap 6 lesson5emsysnewstatemachinefsm
Chap 6 lesson5emsysnewstatemachinefsmchandrika
 

Similaire à Chap 4 lesson02emsysnewinterruptbasedi_os (20)

Chap_6Lesson02Emsys3EInterruptBasedIOs.pdf
Chap_6Lesson02Emsys3EInterruptBasedIOs.pdfChap_6Lesson02Emsys3EInterruptBasedIOs.pdf
Chap_6Lesson02Emsys3EInterruptBasedIOs.pdf
 
SA UNIT III STORM.pdf
SA UNIT III STORM.pdfSA UNIT III STORM.pdf
SA UNIT III STORM.pdf
 
A jade implemented mobile agent based host platform security
A jade implemented mobile agent based host platform securityA jade implemented mobile agent based host platform security
A jade implemented mobile agent based host platform security
 
DEALING WITH FREQUENT TERMINATES IN SYNCHRONIZED DEPENDENCY RECOVERY LINE COM...
DEALING WITH FREQUENT TERMINATES IN SYNCHRONIZED DEPENDENCY RECOVERY LINE COM...DEALING WITH FREQUENT TERMINATES IN SYNCHRONIZED DEPENDENCY RECOVERY LINE COM...
DEALING WITH FREQUENT TERMINATES IN SYNCHRONIZED DEPENDENCY RECOVERY LINE COM...
 
Jpl coding standard for the c programming language
Jpl coding standard for the c programming languageJpl coding standard for the c programming language
Jpl coding standard for the c programming language
 
Chap 01 lesson_2emsys
Chap 01 lesson_2emsysChap 01 lesson_2emsys
Chap 01 lesson_2emsys
 
Unit 2
Unit 2Unit 2
Unit 2
 
Remote core locking (rcl)
Remote core locking (rcl)Remote core locking (rcl)
Remote core locking (rcl)
 
Lab6 rtos
Lab6 rtosLab6 rtos
Lab6 rtos
 
Linux Assignment 3
Linux Assignment 3Linux Assignment 3
Linux Assignment 3
 
Summerinternship
SummerinternshipSummerinternship
Summerinternship
 
TechnoScripts- Free Interview Preparation Q & A Set.pdf
TechnoScripts- Free Interview Preparation Q & A Set.pdfTechnoScripts- Free Interview Preparation Q & A Set.pdf
TechnoScripts- Free Interview Preparation Q & A Set.pdf
 
GJIMT BCA P4UGCA1932U3L6.pptx
GJIMT BCA P4UGCA1932U3L6.pptxGJIMT BCA P4UGCA1932U3L6.pptx
GJIMT BCA P4UGCA1932U3L6.pptx
 
International Journal of Computational Engineering Research(IJCER)
International Journal of Computational Engineering Research(IJCER)International Journal of Computational Engineering Research(IJCER)
International Journal of Computational Engineering Research(IJCER)
 
Introduction to llvm
Introduction to llvmIntroduction to llvm
Introduction to llvm
 
Device Drivers
Device DriversDevice Drivers
Device Drivers
 
Open Programmable Architecture for Java-enabled Network Devices
Open Programmable Architecture for Java-enabled Network DevicesOpen Programmable Architecture for Java-enabled Network Devices
Open Programmable Architecture for Java-enabled Network Devices
 
RTOS implementation
RTOS implementationRTOS implementation
RTOS implementation
 
CS304PC:Computer Organization and Architecture Session 15 program control.pptx
CS304PC:Computer Organization and Architecture Session 15 program control.pptxCS304PC:Computer Organization and Architecture Session 15 program control.pptx
CS304PC:Computer Organization and Architecture Session 15 program control.pptx
 
Chap 6 lesson5emsysnewstatemachinefsm
Chap 6 lesson5emsysnewstatemachinefsmChap 6 lesson5emsysnewstatemachinefsm
Chap 6 lesson5emsysnewstatemachinefsm
 

Chap 4 lesson02emsysnewinterruptbasedi_os

  • 1. DEVICE DRIVERS AND INTERRUPTS SERVICE MECHANISM Lesson-2: Interrupt and Interrupt Service Routine Concept Chapter-4 L02: "Embedded Systems - " , Raj Kamal, 2008 1 Publs.: McGraw-Hill Education
  • 2. Interrupt Concept • Interrupt means event, which invites attention of the processor on occurrence of some action at hardware or software interrupt instruction event. Chapter-4 L02: "Embedded Systems - " , Raj Kamal, 2008 2 Publs.: McGraw-Hill Education
  • 3. Action on Interrupt In response to the interrupt, the routine or program, which is running presently interrupts and an interrupt service routine (ISR) executes. Chapter-4 L02: "Embedded Systems - " , Raj Kamal, 2008 3 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 Chapter-4 L02: "Embedded Systems - " , Raj Kamal, 2008 4 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 Chapter-4 L02: "Embedded Systems - " , Raj Kamal, 2008 5 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 call to an ISR Chapter-4 L02: "Embedded Systems - " , Raj Kamal, 2008 6 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 . Chapter-4 L02: "Embedded Systems - " , Raj Kamal, 2008 7 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) is executed─ called software interrupt to execute the required device driver function for open or read or write or close operations. Chapter-4 L02: "Embedded Systems - " , Raj Kamal, 2008 8 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.] Chapter-4 L02: "Embedded Systems - " , Raj Kamal, 2008 9 Publs.: McGraw-Hill Education
  • 10. Interrupt Driven Actions On Interrupt Interrupt Service Running Routine (ISR) Program Return No continuous checks of device status Chapter-4 L02: "Embedded Systems - " , Raj Kamal, 2008 10 Publs.: McGraw-Hill Education
  • 11. How does call to ISR differ from a function (routine) call? Chapter-4 L02: "Embedded Systems - " , Raj Kamal, 2008 11 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 Chapter-4 L02: "Embedded Systems - " , Raj Kamal, 2008 12 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 Chapter-4 L02: "Embedded Systems - " , Raj Kamal, 2008 13 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 Chapter-4 L02: "Embedded Systems - " , Raj Kamal, 2008 14 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 Chapter-4 L02: "Embedded Systems - " , Raj Kamal, 2008 15 Publs.: McGraw-Hill Education
  • 16. Interrupt driven IO and device accesses feature 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. Chapter-4 L02: "Embedded Systems - " , Raj Kamal, 2008 16 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 Chapter-4 L02: "Embedded Systems - " , Raj Kamal, 2008 17 Publs.: McGraw-Hill Education
  • 18. Ports A and B with interrupt generation and interrupt service (handling) mechanism Port A be at in a PC, 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. Chapter-4 L02: "Embedded Systems - " , Raj Kamal, 2008 18 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. Chapter-4 L02: "Embedded Systems - " , Raj Kamal, 2008 19 Publs.: McGraw-Hill Education
  • 20. ISR_ PortA _Character Current program On interrupt call ISR_ PortA _Character Step f Save PC, status word and registers (current program context) on stack Execute function vi codes (read character, reset port status bit, character save in memory buffer) ReturnChapter-4 L02: "Embedded Systems - " , Raj Kamal, (retrieve the saved context) 2008 20 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. Chapter-4 L02: "Embedded Systems - " , Raj Kamal, 2008 21 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 Chapter-4 L02: "Embedded Systems - " , Raj Kamal, 2008 22 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 Chapter-4 L02: "Embedded Systems - " , Raj Kamal, 2008 23 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. Chapter-4 L02: "Embedded Systems - " , Raj Kamal, 2008 24 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. Chapter-4 L02: "Embedded Systems - " , Raj Kamal, 2008 25 Publs.: McGraw-Hill Education
  • 26. Use of ISR in the ACVM example 1 2 ISR_CoinRead Coin Coin event event Call Read port P0- Event: Coin input P3 bits insertion, processor Reset port sorting and PA0- at a Data bus status coin amount PA3 device Save amount at (1 or 2 or 5 a memory or 10) sent Return buffer to an input 4 Signal a task port PA) 3 Signal AVCM System ISRs and Tasks Chapter-4 L02: "Embedded Systems - " , Raj Kamal, 2008 26 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 Chapter-4 L02: "Embedded Systems - " , Raj Kamal, 2008 27 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 Chapter-4 L02: "Embedded Systems - " , Raj Kamal, 2008 28 Publs.: McGraw-Hill Education
  • 29. Use of ISR in the digital camera example Interrupt Shoot start 1 Keyed 2 ISR_FrameRead Start ADC scan event events Call Signal task read Event: Key input frame status and pressed to processor data of all pixels take a PA0- at camera Data bus of image frame at picture and PA3 6 CCD co-processor Signal task for pressed key saving pixels data code sent at Return at a frame memory port buffer Signal a CCD co- 4 processor task for 3 subtracting offsets To CCD pixels ADC scan 4 5 Signals camera System Tasks Chapter-4 L02: "Embedded Systems - " , Raj Kamal, 2008 29 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. Chapter-4 L02: "Embedded Systems - " , Raj Kamal, 2008 30 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). Chapter-4 L02: "Embedded Systems - " , Raj Kamal, 2008 31 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. Chapter-4 L02: "Embedded Systems - " , Raj Kamal, 2008 32 Publs.: McGraw-Hill Education
  • 33. Use of ISR in the mobile phone reset key interrupt example Interrupt Reset event 1 Mobile 2 ISR_ResetKey Read key state at Keypad Call Port bits P0-P7 Event: events Reset key state Reset Key input status bit pressed to P0-P7 processor Data bus Sent message for at mobile tasks reset the 5 Signal timer start mobile for enabling display Return off after 15 s (preset time) 4 4 3 Signal timer Tasks Sent message for Tasks Chapter-4 L02: "Embedded Systems - " , Raj Kamal, 2008 33 Publs.: McGraw-Hill Education
  • 34. Summary Chapter-4 L02: "Embedded Systems - " , Raj Kamal, 2008 34 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. Chapter-4 L02: "Embedded Systems - " , Raj Kamal, 2008 35 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. Chapter-4 L02: "Embedded Systems - " , Raj Kamal, 2008 36 Publs.: McGraw-Hill Education
  • 37. We learnt Interrupts and interrupt-service routines (device-drivers) play the major role in using the embedded system hardware and devices. Interrupt examples of UART IO, ACVM, Camera and mobile phone Chapter-4 L02: "Embedded Systems - " , Raj Kamal, 2008 37 Publs.: McGraw-Hill Education
  • 38. End of Lesson 2 of Chapter 4 Chapter-4 L02: "Embedded Systems - " , Raj Kamal, 2008 38 Publs.: McGraw-Hill Education