EET 2261 Unit 9 Interrupts  Read Almy, Chapters 17 – 19.  Homework #9 and Lab #9 due next week.  Quiz next week.

Slides:



Advertisements
Similar presentations
Chapter 3 Basic Input/Output
Advertisements

Computer Architecture
Computer System Organization Computer-system operation – One or more CPUs, device controllers connect through common bus providing access to shared memory.
Interrupts, Low Power Modes and Timer A (Chapters 6 & 8)
Interrupts Chapter 8 – pp Chapter 10 – pp Appendix A – pp 537 &
1/1/ / faculty of Electrical Engineering eindhoven university of technology Architectures of Digital Information Systems Part 1: Interrupts and DMA dr.ir.
Microprocessor and Microcontroller
I/O Unit.
Mehmet Can Vuran, Instructor University of Nebraska-Lincoln Acknowledgement: Overheads adapted from those provided by the authors of the textbook.
CSCI 4717/5717 Computer Architecture
1/1/ / faculty of Electrical Engineering eindhoven university of technology Introduction Part 3: Input/output and co-processors dr.ir. A.C. Verschueren.
EET 2261 Unit 10 Enhanced Capture Timer  Read Almy, Chapter 20.  Homework #10 and Lab #10 due next week.  Quiz next week.
68HC11 Polling and Interrupts
ECE 372 – Microcontroller Design Parallel IO Ports - Interrupts
COMP3221: Microprocessors and Embedded Systems Lecture 15: Interrupts I Lecturer: Hui Wu Session 1, 2005.
Basic Input/Output Operations
1 Interrupts INPUT/OUTPUT ORGANIZATION: Interrupts CS 147 JOKO SUTOMO.
EET 2261 Unit 2 HCS12 Architecture
INPUT/OUTPUT ORGANIZATION INTERRUPTS CS147 Summer 2001 Professor: Sin-Min Lee Presented by: Jing Chen.
The 8051 Microcontroller and Embedded Systems
INTERRUPTS PROGRAMMING
ECE 265 – LECTURE 12 The Hardware Interface 8/22/ ECE265.
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:
Introduction to Embedded Systems
Interrupts. What Are Interrupts? Interrupts alter a program’s flow of control  Behavior is similar to a procedure call »Some significant differences.
UNIT 8 Keypad Interface Contact Closure Counter Exceptions (Interrupts and Reset)
Ch. 9 Interrupt Programming and Real-Time Sysstems From Valvano’s Introduction to Embedded Systems.
Revised: Aug 1, ECE 263 Embedded System Design Lessons 23, 24 - Exceptions - Resets and Interrupts.
MICROPROCESSOR INPUT/OUTPUT
Nurudeen Olayiwola Thomas Gutierrez
Khaled A. Al-Utaibi  Interrupt-Driven I/O  Hardware Interrupts  Responding to Hardware Interrupts  INTR and NMI  Computing the.
Chapter 8 I/O. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 8-2 I/O: Connecting to Outside World So far,
The Functions of Operating Systems Interrupts. Learning Objectives Explain how interrupts are used to obtain processor time. Explain how processing of.
Interrupts and reset operations. Overview  Introduction to interrupts – What are they – How are they used  68HC11 interrupt mechanisms – Types of interrupts.
Interrupt.
Microprocessors 1 MCS-51 Interrupts.
13-Nov-15 (1) CSC Computer Organization Lecture 7: Input/Output Organization.
1 © Unitec New Zealand Interrupt Lecture 6 Date: - 20 Sept, 2011 Embedded Hardware ETEC 6416.
George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction.
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.
1 Interrupts, Resets Today: First Hour: Interrupts –Section 5.2 of Huang’s Textbook –In-class Activity #1 Second Hour: More Interrupts Section 5.2 of Huang’s.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
Interrupts  An interrupt is any service request that causes the CPU to stop its current execution stream and to execute an instruction stream that services.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
Embedded Systems Design 1 Lecture Set 8 MCS-51 Interrupts.
Interrupt driven I/O Computer Organization and Assembly Language: Module 12.
MICRO-CONTROLLER MOTOROLA HCS12 Interrupts Mechatronics Department Faculty of Engineering Ain Shams University.
بسم الله الرحمن الرحيم MEMORY AND I/O.
CS-280 Dr. Mark L. Hornick 1 Sequential Execution Normally, CPU sequentially executes instructions in a program Subroutine calls are synchronous to the.
George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction.
Introduction to Exceptions 1 Introduction to Exceptions ARM Advanced RISC Machines.
EET 2261 Unit 13 Enhanced Capture Timer
Architectures of Digital Information Systems Part 1: Interrupts and DMA dr.ir. A.C. Verschueren Eindhoven University of Technology Section of Digital.
An Interrupt is either a Hardware generated CALL (externally derived from a hardware signal) OR A Software-generated CALL (internally derived from.
Interrupts and signals
ECE 3430 – Intro to Microcomputer Systems
68HC11 Interrupts & Resets.
Microprocessor Systems Design I
Lesson Objectives Aims Key Words Interrupt, Buffer, Priority, Stack
Computer Architecture
Interrupts In 8085 and 8086.
Chapter 10 The Stack.
Processor Fundamentals
EET 2261 Unit 9 Interrupts Read Almy, Chapters 17 – 19.
COMPUTER PERIPHERALS AND INTERFACES
Interrupt handling Explain how interrupts are used to obtain processor time and how processing of interrupted jobs may later be resumed, (typical.
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
COMP3221: Microprocessors and Embedded Systems
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
Presentation transcript:

EET 2261 Unit 9 Interrupts  Read Almy, Chapters 17 – 19.  Homework #9 and Lab #9 due next week.  Quiz next week.

An interrupt is a mechanism for causing a program to temporarily suspend what it’s doing, and do something else instead. Interrupts are commonly used with I/O devices (keyboards, etc.). By using interrupt-driven I/O, a program can efficiently service the I/O devices only when they need attention. The alternative is polled I/O, in which the program periodically stops what it’s doing and checks to see whether any I/O device needs service. Interrupts

Suppose you’re at home working on a demanding task (writing a paper), and at the same time you’re waiting for FedEx to deliver an important package. Two possible approaches: 1.Get up from your desk every 30 seconds to look out the window for the FedEx truck. 2.Focus on writing your paper, and let the FedEx driver ring the doorbell to announce her arrival. An Analogy

On this analogy: Your paper-writing task is like the processor’s main program. The FedEx delivery is like an I/O device. The first approach (getting up from your desk every 30 seconds) is like polled I/O. Not a good way to work, is it? The second approach (relying on the doorbell) is like interrupt-driven I/O. Makes better use of your time! An Analogy (Continued)

In real life, there may be many different events that could interrupt you from your primary task:  Doorbell  Telephone  Tornado siren  Dog scratching at the door to be let out Similarly, the HCS12 has many (about 50) different kinds of interrupts that may require the CPU to temporarily set aside its main task. Some of these interrupts come from outside the HCS12 chip, and some come from circuits on the HCS12 chip itself. An Analogy (Continued)

For complete list, see pages of the Device User Guide (or the similar list on page 157 of the book). Device User Guide The list orders interrupts from highest priority to lowest. (Priority comes into play if two interrupts occur at the same time.) List of Interrupts

Of the 50-plus kinds of “interrupts,” the three highest-priority ones are more correctly called resets: Reset Clock Monitor Fail Reset Computer Operating Properly (COP) Reset The next two highest-priority ones are more correctly called traps: Unimplemented Instruction Trap Software Interrupt (SWI) Trap The rest are just called interrupts. These are the ones we’ll focus on. Resets, Traps, and Interrupts

The programmer can choose whether to allow or block interrupts. (But resets and traps cannot be blocked.) If an interrupt is blocked, it will be ignored by the CPU. We’ll see later that many special function registers hold bits that let the user allow or block specific kinds of interrupts. Two bits in the Condition Code Register (CCR) also play a key role in allowing or blocking interrupts…. Allowing or Blocking Interrupts

Review: Condition Code Register The CCR is an 8-bit register that contains: 5 flag bits (H, N, Z, V, C) 2 interrupt mask bits (X and I) STOP instruction control bit (S)

CCR Bits X and I The X bit blocks (if X=1) or allows (if X=0) interrupts from the chip’s XIRQ pin. See page 25 of CPU Reference Manual.CPU Reference Manual The I bit blocks (if I=1) or allows (if I=0) all other interrupts, including interrupts from the chip’s IRQ pin. See pages of CPU Reference Manual.CPU Reference Manual

Assuming that interrupts are allowed, when the CPU receives an interrupt signal, it sets aside whatever it is doing and runs code called an interrupt service routine (ISR) or interrupt handler for that specific interrupt. The programmer must write these ISRs and place them in memory. An ISR is basically a subroutine that gets called automatically when a interrupt occurs. Interrupt Service Routine

For each type of interrupt, there is a fixed location in memory into which the programmer must load the starting address of the interrupt service routine (ISR). The group of memory locations set aside to hold the starting addresses of the ISRs is called the interrupt vector table. Interrupt Vector Table

Memory locations $FF00 through $FFFF are reserved for the interrupt vector table. Figure from page 26 of Device User Guide. Device User Guide Location of Interrupt Vector Table

See Table 5-1 on pages of the Device User Guide.Device User Guide For each type of interrupt, this table tells us: Information in Table 5-1 The source (name) of the interrupt.The locations in memory where the programmer must store the starting address of the interrupt’s service routine. Whether the interrupt can be masked (blocked) by a bit in the Condition Code Register (CCR). Whether the interrupt can be allowed/blocked somewhere other than the CCR. Whether the interrupt can be elevated to a higher priority.

When the HCS12 receives an interrupt, it follows these steps: It finishes executing the current instruction. It pushes the contents of PC, Y, X, A, B, and CCR onto the stack, thus saving a snapshot of exactly what the CPU was doing before it was interrupted. It fetches the address of the appropriate interrupt service routine (ISR) from the interrupt vector table and places this address in the Program Counter (PC). Continues on next slide…. Steps in Executing an Interrupt

…It sets the I bit in CCR high to ensure that no other interrupt can interrupt the CPU while it’s serving the current one. It fetches and executes instructions belonging to the interrupt service routine. The last instruction of the interrupt service routine must be an RTI (Return from Interrupt). RTI causes the CPU to pull the original PC, Y, X, A, B, and CCR values from the stack, thus restoring the CPU to the state it was in before it serviced the interrupt. It then continues to run the code from where it left off before the interrupt. Steps in Executing an Interrupt (Continued)

Many of the bits in the chip’s special function registers are devoted to configuring and controlling interrupts. Most of the bits in these registers are either enable bits, which we set or reset to decide whether we’re allowing interrupts or flag bits, which the hardware sets to indicate that an interrupt has occurred. Your interrupt service routine should reset these flags to “clear” the interrupt. Interrupts and Special Function Registers

Your program named Lab07SwitchesToLEDs sat in a loop, reading the switches and sending the switch values to the LEDs: Back: LDAA PTH STAA PORTB BRA Back A better way is to use an interrupt to tell us when the switch settings have changed, instead of repeatedly polling the switches. Polling Versus Interrupts for Port H

Port H has its own interrupt, which can be caused by any of the bits in Port H: Enabled or disabled by the bits in PIEH: Flag bits are in PIFH: Port H Interrupts

Programming an interrupt involves several steps on the programmer’s part: 1.Enable the interrupt (usually by clearing the I bit in the CCR and setting one or more local enable bits). 2.Write the interrupt service routine (ISR), which is much like a subroutine except it must end with RTI, not RTS. 3.Place the ISR’s starting address in the appropriate location within the interrupt vector table. Programming an Interrupt

Example: Programming an Interrupt Skeleton of code for using Port H interrupt: Note that this example enables interrupts on only one of the bits of Port H. You might instead need to enable interrupts for several of the Port H bits, or for all of them.

As part of your interrupt service routine (ISR), be sure to clear the flag bit that caused the interrupt. Otherwise, when the HCS12 exits your ISR, the flag bit will still be set and will immediately cause another interrupt. Strangely, to clear an interrupt flag bit you must write a 1 to it after having read it while it was a 1. (You don’t write a 0, which is what you might expect). Next slide extends the previous example to include this step. Clearing the Interrupt Flag Bit

Previous Example With Additional Line to Clear the Interrupt Flag Skeleton of code for using Port H interrupt:

We’ve been looking at the Port H interrupt. Ports J and P have similar interrupts. These Port H, J, and P interrupts provide one way to interrupt the HCS12 when an external event occurs. The textbook refers to these interrupts as “key wakeups.” None of the other I/O ports (A, B, E, K, M, S, T) can generate interrupts. But two of the HCS12’s other pins, named XIRQ and IRQ, can also generate interrupts. (IRQ stands for Interrupt Request.) Other External Interrupts

Review: CCR Bits X and I Recall from above that IRQ interrupts, like almost all other interrupts, are blocked if the Condition Code Register’s I bit is equal to 1. And XIRQ interrupts are blocked if the Condition Code Register’s X bit is equal to 1.

The XIRQ and IRQ pins are active-low. They’re normally held high, and they generate an interrupt (assuming they’re not masked by the X or I bits in the CCR) when they are pulled low. XIRQ and IRQ Pins Are Active-Low

Pins Are Shared with Port E So if you want to use XIRQ and IRQ interrupts, you can’t also use bits 0 and 1 of Port E for general-purpose I/O.

We’ve ben looking at ways in which external events can interrupt the HCS12. As we’ll see in the weeks ahead, many of the functional blocks within the HCS12 chip itself can also generate interrupts. This lets these blocks force the CPU to temporarily suspend execution of its current program and service their needs. Internal Interrupts