COMP3221: Microprocessors and Embedded Systems Lecture 15: Interrupts I Lecturer: Hui Wu Session 1, 2005.

Slides:



Advertisements
Similar presentations
Chapter 3 Basic Input/Output
Advertisements

Computer Architecture
1/1/ / faculty of Electrical Engineering eindhoven university of technology Architectures of Digital Information Systems Part 1: Interrupts and DMA dr.ir.
COMP3221: Microprocessors and Embedded Systems Lecture 17: Computer Buses and Parallel Input/Output (I) Lecturer: Hui.
Interrupts Disclaimer: All diagrams and figures in this presentation are scanned from the book “Microprocessors and Programmed Logic” authored by Kenneth.
I/O Unit.
Mehmet Can Vuran, Instructor University of Nebraska-Lincoln Acknowledgement: Overheads adapted from those provided by the authors of the textbook.
CS-334: Computer Architecture
FIU Chapter 7: Input/Output Jerome Crooks Panyawat Chiamprasert
Interfacing. This Week In DIG II  Basic communications terminology  Communications protocols  Microprocessor interfacing: I/O addressing  Port and.
Interrupts What is an interrupt? What does an interrupt do to the “flow of control” Interrupts used to overlap computation & I/O – Examples would be console.
Interrupts (contd..) Multiple I/O devices may be connected to the processor and the memory via a bus. Some or all of these devices may be capable of generating.
Introduction An interrupt is an event which informs the CPU that its service (action) is needed. Sources of interrupts: internal fault (e.g.. divide by.
Basic Input/Output Operations
1 Interrupts INPUT/OUTPUT ORGANIZATION: Interrupts CS 147 JOKO SUTOMO.
INPUT/OUTPUT ORGANIZATION INTERRUPTS CS147 Summer 2001 Professor: Sin-Min Lee Presented by: Jing Chen.
Chapter 11 Interrupt Interface of the 8088 and 8086 Microcomputer
INTERRUPTS PROGRAMMING
Input/Output. Input/Output Problems Wide variety of peripherals —Delivering different amounts of data —At different speeds —In different formats All slower.
Chapter 7 Input/Output Luisa Botero Santiago Del Portillo Ivan Vega.
Interrupts. 2 Definition: An electrical signal sent to the CPU (at any time) to alert it to the occurrence of some event that needs its attention Purpose:
Exception and Interrupt Handling
COMP201 Computer Systems Exceptions and Interrupts.
Interrupts. What Are Interrupts? Interrupts alter a program’s flow of control  Behavior is similar to a procedure call »Some significant differences.
created by :Gaurav Shrivastava
1 Computer System Overview Chapter 1. 2 n An Operating System makes the computing power available to users by controlling the hardware n Let us review.
MICROPROCESSOR INPUT/OUTPUT
Khaled A. Al-Utaibi  Interrupt-Driven I/O  Hardware Interrupts  Responding to Hardware Interrupts  INTR and NMI  Computing the.
The Functions of Operating Systems Interrupts. Learning Objectives Explain how interrupts are used to obtain processor time. Explain how processing of.
Dr Mohamed Menacer College of Computer Science and Engineering Taibah University CE-321: Computer.
Microprocessors 1 MCS-51 Interrupts.
Interrupt Interrupt – to break the flow of speech or action of (someone) by saying or doing something (Longman dictionary)
Accessing I/O Devices Processor Memory BUS I/O Device 1 I/O Device 2.
13-Nov-15 (1) CSC Computer Organization Lecture 7: Input/Output Organization.
CSNB374: Microprocessor Systems Chapter 5: Procedures and Interrupts.
1 © Unitec New Zealand Interrupt Lecture 6 Date: - 20 Sept, 2011 Embedded Hardware ETEC 6416.
Chapter 3 Basic Input/Output. Chapter Outline Basic I/O capabilities of computers I/O device interfaces Memory-mapped I/O registers Program-controlled.
Fall 2000M.B. Ibáñez Lecture 25 I/O Systems. Fall 2000M.B. Ibáñez Categories of I/O Devices Human readable –used to communicate with the user –video display.
Interrupt driven I/O. MIPS RISC Exception Mechanism The processor operates in The processor operates in user mode user mode kernel mode kernel mode Access.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
Input/Output Problems Wide variety of peripherals —Delivering different amounts of data —At different speeds —In different formats All slower than CPU.
Embedded Systems Design 1 Lecture Set 8 MCS-51 Interrupts.
Interrupt driven I/O Computer Organization and Assembly Language: Module 12.
Input Output Techniques Programmed Interrupt driven Direct Memory Access (DMA)
بسم الله الرحمن الرحيم MEMORY AND I/O.
9/20/6Lecture 3 - Instruction Set - Al1 Exception Handling.
 The Programmable Interrupt Controller (PlC) functions as an overall manager in an Interrupt-Driven system. It accepts requests from the peripheral equipment,
1 Device Controller I/O units typically consist of A mechanical component: the device itself An electronic component: the device controller or adapter.
Interrupts and Exception Handling. Execution We are quite aware of the Fetch, Execute process of the control unit of the CPU –Fetch and instruction as.
Introduction to Exceptions 1 Introduction to Exceptions ARM Advanced RISC Machines.
INSTITUTE: INSTITUTE:PARUL INSTITUTE OF TECHNOLOGY BRANCH : BRANCH :B.E. E.C.5 TH SEM. SUBJECT:MICROCONTROLLER & INTERFACING TOPIC:AVR INTTRUPT TOPIC:AVR.
68HC11 Interrupts & Resets.
Microprocessor Systems Design I
Computer Architecture
Interrupts In 8085 and 8086.
COMP2121: Microprocessors and Interfacing
Chapter 8 Input/Output I/O basics Keyboard input Monitor output
8259 Chip The Intel 8259 is a family of Programmable Interrupt Controllers (PIC) designed and developed for use with the Intel 8085 and Intel 8086 microprocessors.
Computer System Overview
Interrupts Interrupt is a process where an external device can get the attention of the microprocessor. The process starts from the I/O device The process.
Processor Fundamentals
11.1 Interrupt Mechanism, Type, and Priority
COMPUTER PERIPHERALS AND INTERFACES
Interrupts.
Interrupt handling Explain how interrupts are used to obtain processor time and how processing of interrupted jobs may later be resumed, (typical.
COMP3221: Microprocessors and Embedded Systems
Presentation transcript:

COMP3221: Microprocessors and Embedded Systems Lecture 15: Interrupts I Lecturer: Hui Wu Session 1, 2005

COMP3221/9221: Microprocessors and Embedded Systems 2 Overview Interrupt System Specifications Multiple Sources of Interrupts Interrupt Priorities Polling

COMP3221/9221: Microprocessors and Embedded Systems 3 Processor (active) Computer Control (“brain”) Datapath (“brawn”) Memory (passive) (where programs, data live when running) Devices Input Output Keyboard, Mouse Display, Printer Disk (where programs, data live when not running) Five Components of any Computer

4 How CPU Interacts with I/O? Two Choices: Interrupts.  I/O devices generate signals to request services from CPU.  Need special hardware to implement interrupts.  Efficient.  A signal is generated only if the I/O device needs services from CPU. Polling  Software queries I/O devices.  No hardware needed.  Not efficient.  CPU may waste processor cycles to query a device even if it does not need any service.

5 Interrupt System Specifications (Cont.) 1.Allow for synchronous events to occur and be recognized. 2.Wait for the current instruction to finish before taking care of any interrupt. 3.Branch to the correct interrupt service routine (interrupt handler) to servicing interrupting device. 4.Return to the interrupted program at the point it was interrupted. 5.Allow for a variety of interrupting signals, including levels and edges. 6.Signal the interrupting device with an acknowledge signal when the interrupt has been recognized.

6 Interrupt System Specifications (Cont.) 7.Allow programmers to selectively enable and disable all interrupts. 8.Allow programmers to enable and disable selected interrupts. 9.Disable further interrupts while the first is being serviced 10.Deal with multiple sources of interrupts. 11.Deal with multiple, simultaneous interrupts.

7 Interrupt Recognition and Ack Interrupt signal to sequence controller Interrupt ack from sequence controller SEQUENCE CONTROLLER Disable interrupt instruction Enable interrupt instruction Return from interrupt instruction INTERR- UPTING DEVICE Signal conditioning Set IRQ-FF Reset Set INTE-FF Reset IRQ Interrupt Enable CPU Pending Interrupt

8 Interrupt Recognition and Ack An Interrupt Request (IRQ) may occur at any time.  It may have rising or falling edges or high or low levels.  Frequently it is a active-low signal and multiple devices are wire- ORed together. Signal Conditioning Circuit detects these different types of signals. Interrupt Request Flip-Flop (IRQ-FF) remembers that an interrupt request has been generated until it is acknowledged.  When IRQ-FF is set, it generates a pending interrupt signal that goes towards the Sequence Controller.  IRQ-FF is reset when CPU acknowledges the interrupt with INTA signal.

9 Interrupt Recognition and Ack (Cont.) The programmer has control over interrupting process by enabling and disabling interrupts with explicit instructions  The hardware that allows this is Interrupt Enable Flip-Flop (INTE- FF).  When the INTE-FF is set, all interrupts are enabled and the pending interrupt interrupt is allowed through the AND gate to the sequence controller.  The INTE-FF is reset in the following cases.  CPU acknowledges the interrupt.  CPU is reset.  Disable interrupt instruction is executed.

10 Interrupt Recognition and Ack (Cont.) An interrupt acknowledge signal is generated by the CPU when the current instruction has finished execution and CPU has detected the IRQ.  This resets the IRQ-FF and INTE-FF and signals the interrupting device that CPU is ready to execute the interrupting device routine. At the end of the interrupt service routine, CPU executes a return-from-interrupt instruction.  Part of this instruction’s job is to set the INTE-FF to reenable interrupts.  If the IRQ-FF is set during an interrupt service routine a pending interrupt, there is one, will be recognized by the sequence controller immediately after the INTE-FF is set. This allows nested interrupts i.e. interrupts interrupting interrupts.

11 Multiple Sources of Interrupts Determine which of the multiple devices has generated the IRQ to be able to execute its interrupt service routine.  Two approaches: Polled interrupts and vectored interrupts. Resolve simultaneous requests from interrupts with a prioritization scheme. CPUDevice 1Device 2Device n INTA IRQ

12 Polled Interrupts Software, instead of hardware, is responsible for determining the interrupting device.  The device must have logic to generate the IRQ signal and to set an “I did it” bit a status register that is read by CPU.  The bit is reset after the register has been read. IRQ signals the sequence controller to start executing an interrupt service routine that first polls the device then branches to the correct service routine.

13 Polled Interrupt Logic Logic to generate IRQ Logic to reset IRQ when status register is read Logic to read status register and reset “I did it” bit Logic to set “I did it” bit Status register Data Address Control IRQ

14 Vectored Interrupts (I) CPU’s response to IRQ is to assert INTA. The interrupting device uses INTA to place information that identifies itself, called vector, onto the data bus for CPU to read.  An vector is the address of an interrupt service routine. CPU uses the vector to execute the interrupt service routine.

15 Vectored Interrupting Device Hardware (I) Logic to generate IRQ Logic to reset IRQ Vector Information Three-State Driver Data Address Control INTA IRQ

16 Vector Interrupts (II) CPU has multiple IRQ input pins. CPU designers reserve specific memory locations for a vector associated with each IRQ line. Individual disable/enable bit is assigned to each interrupting source. CPU IRQ 0 IRQ 1 IRQ 2 IRQ n

17 Interrupt Priorities When multiple interrupts occurs at the same time, which one will be serviced first? Two resolution approaches:  Software resolution.  Polling software determines which interrupting source is serviced first.  Hardware resolution.  Daisy chain.  Separate IRQ lines.  Hierarchical prioritization.  Nonmaskable interrupts.

18 Daisy Chain Priority Resolution CPU asserts INTA that is passed down the chain from device to device. The higher-priority device is closer to CPU. When the INTA reaches the device that generated the IRQ, that device puts its vector on the data bus and not passing along the INTA. So lower-priority devices do NOT receive the INTA.

19 Daisy Chain Priority Resolution (Cont.) CPUDevice 1Device 2Device n IRQ INTA Data Address Control

COMP3221/9221: Microprocessors and Embedded Systems 20 Hardware Priority Resolution Separate IRQ Lines.  Each IRQ line is assigned a fixed priority. For example, IRQ0 has higher priority than IRQ1 and IRQ1 has higher priority than IRQ2 and so on. Hierarchical Prioritization.  Higher priory interrupts are allowed while lower ones are masked. Nonmaskable Interrupts.  Cannot be disabled.  Used for important events such as power failure.

21 Transferring Control to Interrupt Service Routine Hardware needs to save the return address.  Most processors save the return on the stack.  ARM uses a special register, link register, to store the return address. Hardware may also save some registers such as program status register.  AVR does not save any register. It is programmer’s responsibility to save program status register and conflict registers. The delay from the time the IRQ is generated by the interrupting device to the time the Interrupt Service Routine (ISR) starts to execute is called interrupt latency.

22 Interrupt Service Routine A sequence of code to be executed when the corresponding interrupt is responded by CPU. Consists of three parts: Prologue, Body and Epilogue. Prologue:  Code for saving conflict registers on the stack. Body:  Code for doing the required task. Epilogue:  Code for restoring all saved registers from the stack.  The last instruction is the return-from-interrupt instruction.  iret in AVR.

23 Software Interrupt Software interrupt is the interrupt generated by software without a hardware-generated-IRQ. Software interrupt is typically used to implement system calls in OS. Most processors provide a special machine instruction to generate software interrupt.  SWI in ARM. AVR does NOT provide a software interrupt instruction.  Programmers can use External Interrupts to implement software interrupts.

24 Exceptions Abnormalities that occur during the normal operation of the processor.  Examples are internal bus error, memory access error and attempts to execute illegal instructions. Some processors handle exceptions in the same way as interrupts.  AVR does not handle exceptions.

25 Reset Reset is a type of of interrupt in most processors (including AVR). It is a signal asserted on a separate pin. Nonmaskable. It does not do other interrupt processes, such as saving conflict registers. It initialize the system to some initial state.

COMP3221/9221: Microprocessors and Embedded Systems 26 Reading 1.Chapter 8. Microcontrollers and Microcomputers. 2.Interrupts. Mega64 Data Sheet.