COMP3221: Microprocessors and Embedded Systems

Slides:



Advertisements
Similar presentations
Chapter 3 Basic Input/Output
Advertisements

Computer Architecture
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.
FIU Chapter 7: Input/Output Jerome Crooks Panyawat Chiamprasert
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.
COMP3221: Microprocessors and Embedded Systems Lecture 15: Interrupts I Lecturer: Hui Wu Session 1, 2005.
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
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:
Interrupts. What Are Interrupts? Interrupts alter a program’s flow of control  Behavior is similar to a procedure call »Some significant differences.
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.
Microprocessors 1 MCS-51 Interrupts.
13-Nov-15 (1) CSC Computer Organization Lecture 7: Input/Output Organization.
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.
بسم الله الرحمن الرحيم MEMORY AND I/O.
9/20/6Lecture 3 - Instruction Set - Al1 Exception Handling.
Introduction to Exceptions 1 Introduction to Exceptions ARM Advanced RISC Machines.
Chapter 10 Interrupts. Basic Concepts in Interrupts  An interrupt is a communication process set up in a microprocessor or microcontroller in which:
Input / Output Chapter 9.
Unit Microprocessor.
Architectures of Digital Information Systems Part 1: Interrupts and DMA dr.ir. A.C. Verschueren Eindhoven University of Technology Section of Digital.
COURSE OUTCOMES OF Microprocessor and programming
Interrupts and exceptions
MICROPROCESSOR BASED SYSTEM DESIGN
68HC11 Interrupts & Resets.
Microprocessor Systems Design I
Mon. Oct 2 Announcements Quiz Postponed to Wednesday – still only on 2.a + 2.b Video lecture for 2.a posted Lab 6 experiment extension You must come to.
The process starts from the I/O device
Lesson Objectives Aims Key Words Interrupt, Buffer, Priority, Stack
Timer and Interrupts.
UNIT – Microcontroller.
The deadline establish a priority among interrupt requests.
Computer Architecture
CPU Sequencing 6/30/2018.
Interrupts In 8085 and 8086.
BVM Engineering College Electrical Engineering Department : Microprocessor and Microcontroller Interfacing Interrupts of 8051 Prepared by:
Computer System Overview
COMP2121: Microprocessors and Interfacing
Programmable Interrupt Controller 8259
Interrupt.
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.
Interrupt Driven I/O References Text: Tanenbaum ch.1.4.3, ch Receiver Interrupt Program Example:
Subject Name: Microprocessors Subject Code:10EC46 Department: Electronics and Communication Date: /20/2018.
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.
Md. Mojahidul Islam Lecturer Dept. of Computer Science & Engineering
Md. Mojahidul Islam Lecturer Dept. of Computer Science & Engineering
Interrupts 1/18/2019.
Interrupt handling Explain how interrupts are used to obtain processor time and how processing of interrupted jobs may later be resumed, (typical.
Computer System Overview
Computer System Overview
Programmable Interrupt Controller (PIC)
Chapter 13: I/O Systems.
CPU Sequencing 7/20/2019.
I/O subsystem Overview Peripheral Devices and IO Modules
Chapter 13: I/O Systems “The two main jobs of a computer are I/O and [CPU] processing. In many cases, the main job is I/O, and the [CPU] processing is.
Presentation transcript:

COMP3221: Microprocessors and Embedded Systems Lecture 15: Interrupts I http://www.cse.unsw.edu.au/~cs3221 Lecturer: Hui Wu Session 2, 2004

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

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

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.

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

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

Interrupt Recognition and Ack Pending Interrupt 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 Set IRQ-FF Reset IRQ Signal conditioning Set INTE-FF Reset Interrupt Enable CPU

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.

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.

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.

Multiple Sources of Interrupts IRQ INTA CPU Device 1 Device 2 • • • Device n 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.

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.

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

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.

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

Vector Interrupts (II) IRQ 0 IRQ 1 IRQ 2 CPU ••• IRQ n 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.

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.

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.

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

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. COMP3221/9221: Microprocessors and Embedded Systems

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.

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.

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.

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.

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 Reading Chapter 8. Microcontrollers and Microcomputers. Interrupts. Mega64 Data Sheet. COMP3221/9221: Microprocessors and Embedded Systems