1 EECS 373 Design of Microprocessor-Based Systems Mark Brehob University of Michigan Lecture 6: Interrupts Sept. 19 th 2013 Slides developed in part by.

Slides:



Advertisements
Similar presentations
Computer Architecture
Advertisements

1/1/ / faculty of Electrical Engineering eindhoven university of technology Architectures of Digital Information Systems Part 1: Interrupts and DMA dr.ir.
A look at interrupts What are interrupts and why are they needed.
CSCI 4717/5717 Computer Architecture
1 EECS 373 Design of Microprocessor-Based Systems Prabal Dutta University of Michigan Lecture 6: AHB-Lite, Interrupts (1) September 18, 2014 Slides developed.
Chapter 6 Limited Direct Execution
EET 2261 Unit 9 Interrupts  Read Almy, Chapters 17 – 19.  Homework #9 and Lab #9 due next week.  Quiz next week.
CSC Timers Since this is a microcontroller it mainly finds itself in embedded devices Quite often embedded devices need to synchronize events The.
COMP3221: Microprocessors and Embedded Systems Lecture 15: Interrupts I Lecturer: Hui Wu Session 1, 2005.
A look at interrupts What are interrupts and why are they needed in an embedded system? Equally as important – how are these ideas handled on the Blackfin.
Figure 2.8 Compiler phases Compiling. Figure 2.9 Object module Linking.
Architectural Support for Operating Systems. Announcements Most office hours are finalized Assignments up every Wednesday, due next week CS 415 section.
OS Spring’03 Introduction Operating Systems Spring 2003.
1 EECS 373 Design of Microprocessor-Based Systems Prabal Dutta University of Michigan Lecture 7: Exceptions and Interrupts September 27, 2011.
A look at interrupts What are interrupts and why are they needed.
Introduction to Interrupts
1 EECS 373 Design of Microprocessor-Based Systems Prabal Dutta University of Michigan Lecture 7: Interrupts (2) January 29, 2015 Some slides prepared by.
1 EECS 373 Design of Microprocessor-Based Systems Prabal Dutta University of Michigan Lecture 7: Interrupts (2) September 23, 2014 Some slides prepared.
OS Spring’04 Introduction Operating Systems Spring 2004.
What are Exception and Interrupts? MIPS terminology Exception: any unexpected change in the internal control flow – Invoking an operating system service.
1 EECS 373 Design of Microprocessor-Based Systems Mark Brehob University of Michigan Lecture 7: Finish interrupts, group talks, start on serial buses Sept.
Exception and Interrupt Handling
Introduction to Embedded Systems
COMP201 Computer Systems Exceptions and Interrupts.
3/11/2002CSE Input/Output Input/Output Control Datapath Memory Processor Input Output Memory Input Output Network Control Datapath Processor.
Interrupts. What Are Interrupts? Interrupts alter a program’s flow of control  Behavior is similar to a procedure call »Some significant differences.
Protection and the Kernel: Mode, Space, and Context.
CORTEX-M0 Structure Discussion 2 – Core Peripherals
Khaled A. Al-Utaibi  Interrupt-Driven I/O  Hardware Interrupts  Responding to Hardware Interrupts  INTR and NMI  Computing the.
1 EECS 373 Design of Microprocessor-Based Systems Mark Brehob University of Michigan Lecture 7: Finish interrupts, group talks, start on serial buses Feb.
Interrupts Stopping program flow to execute a special piece of code that handles an event Definition and classification PowerPC interrupt structure Precise.
1 CS/COE0447 Computer Organization & Assembly Language Chapter 5 part 4 Exceptions.
The Functions of Operating Systems Interrupts. Learning Objectives Explain how interrupts are used to obtain processor time. Explain how processing of.
Tami Meredith, Ph.D. CSCI  Devices need CPU access  E.g., NIC has a full buffer it needs to empty  These device needs are often asynchronous.
1 EECS 373 Design of Microprocessor-Based Systems Mark Brehob University of Michigan Lecture 6: Interrupts January 30 th Slides developed in part by Prof.
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 CSE451 Architectural Supports for Operating Systems Autumn 2002 Gary Kimura Lecture #2 October 2, 2002.
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.
Operating Systems 1 K. Salah Module 1.2: Fundamental Concepts Interrupts System Calls.
Exceptions and Interrputs CS 321 – Introduction to Computer Architecture and Machine-Level Programming Barry Britt, Systems Analyst II Department of Computer.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
EECS 373 Design of Microprocessor-Based Systems Mark Brehob
Embedded Systems Design 1 Lecture Set 8 MCS-51 Interrupts.
Interrupt driven I/O Computer Organization and Assembly Language: Module 12.
9/20/6Lecture 3 - Instruction Set - Al1 Exception Handling.
EECS 373 Design of Microprocessor-Based Systems Mark Brehob University of Michigan Lecture 6 & 7: Interrupts (please bring slides again on Thursday) January.
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.
Chapter 6 Limited Direct Execution Chien-Chung Shen CIS/UD
1 EECS 373 Design of Microprocessor-Based Systems Prabal Dutta University of Michigan Interrupts, Exceptions, Traps, Faults & ARM’s Nested Vectored Interrupt.
Interrupt 마이크로 프로세서 (Micro Processor) 2015년 2학기 충북대학교 전자공학과 박 찬식
A walk through interrupts on the PPC 823
Interrupts and exceptions
Operating Systems CMPSC 473
Exceptional Control Flow
Microprocessor Systems Design I
Timer and Interrupts.
EECS 373 Design of Microprocessor-Based Systems Prabal Dutta
Anton Burtsev February, 2017
Computer Architecture
EECS 373 Design of Microprocessor-Based Systems Prabal Dutta
* * * * * * * 8051 Interrupts Programming.
EECS 373 Design of Microprocessor-Based Systems Mark Brehob
EECS 373 Design of Microprocessor-Based Systems Mark Brehob
CSE 451: Operating Systems Autumn 2003 Lecture 2 Architectural Support for Operating Systems Hank Levy 596 Allen Center 1.
CSE 451: Operating Systems Autumn 2001 Lecture 2 Architectural Support for Operating Systems Brian Bershad 310 Sieg Hall 1.
Computer System Overview
CSE 451: Operating Systems Winter 2003 Lecture 2 Architectural Support for Operating Systems Hank Levy 412 Sieg Hall 1.
COMP3221: Microprocessors and Embedded Systems
Presentation transcript:

1 EECS 373 Design of Microprocessor-Based Systems Mark Brehob University of Michigan Lecture 6: Interrupts Sept. 19 th 2013 Slides developed in part by Prof. Dutta

Announcements Office hours cancelled today. –Sick am I. Problem with lab3 part 4 servo specification. –Not sure on status. Thanks for your corrections/help on lab3 –We did have other beta test. Some corrections didn’t make it into the lab (or they used different parts). 2

3 Outline Interrupts –Background –Our processor (Cortex M3 and the SmartFusion implementation)

Interrupts Merriam-Webster: –“to break the uniformity or continuity of” Informs a program of some external events Breaks execution flow Key questions: Where do interrupts come from? How do we save state for later continuation? How can we ignore interrupts? How can we prioritize interrupts? How can we share interrupts? 4

I/O Data Transfer Two key questions to determine how data is transferred to/from a non-trivial I/O device: 1.How does the CPU know when data is available? a.Polling b.Interrupts 2.How is data transferred into and out of the device? a.Programmed I/O b.Direct Memory Access (DMA)

Interrupts Interrupt (a.k.a. exception or trap): An event that causes the CPU to stop executing the current program and begin executing a special piece of code called an interrupt handler or interrupt service routine (ISR). Typically, the ISR does some work and then resumes the interrupted program. Interrupts are really glorified procedure calls, except that they: can occur between any two instructions are transparent to the running program (usually) are not explicitly requested by the program (typically) call a procedure at an address determined by the type of interrupt, not the program

Two basic types of interrupts (1/2) Those caused by an instruction –Examples: TLB miss Illegal/unimplemented instruction div by 0 Trap instruction –Names: Trap, exception, software interrupt

Two basic types of interrupts (2/2) Those caused by events external to the core. –External device –Reset button –Timer expires –Power failure –System error Names: –interrupt, external interrupt, hardware interrupt

How it works Something tells the processor core there is an interrupt Core transfers control to code that needs to be executed Said code “returns” to old program Much harder then it looks. –Why?

… is in the details How do you figure out where to branch to? How to you ensure that you can get back to where you started? Don’t we have a pipeline? What about partially executed instructions? What if we get an interrupt while we are processing our interrupt? What if we are in a “critical section?”

Where If you know what caused the interrupt then you want to jump to the code that handles that interrupt. –If you number the possible interrupt cases, and an interrupt comes in, you can just branch to a location, using that number as an offset (this is a branch table) –If you don’t have the number, you need to poll all possible sources of the interrupt to see who caused it. Then you branch to the right code

Get back to where you once belonged Need to store the return address somewhere. –Stack might be a scary place. That would involve a load/store and might cause an interrupt (page fault)! –So a dedicated register seems like a good choice But that might cause problems later…

Snazzy architectures Be aware that processors sometimes “cheat” –Execute instructions out-of-order. –Can happen even in a (mostly) “in-order” processor due to variable execution latencies. So when an interrupt occurs, need to get things in order. –Could be a delay.

Nested interrupts If we get one interrupt while handling another what to do? –Just handle it But what about that dedicated register? What if I’m doing something that can’t be stopped? –Ignore it But what if it is important? –Prioritize Take those interrupts you care about. Ignore the rest Still have dedicated register problems.

Critical section We probably need to ignore some interrupts but take others. –Probably should be sure our code can’t cause an exception. –Use same prioritization as before.

16 Outline Interrupts –Background –Our processor (Cortex M3 and the SmartFusion implementation)

17

SmartFusion interrupt sources 18

And the interrupt vectors (in startup_a2fxxxm3.s found in CMSIS, startup_gcc) g_pfnVectors:.word _estack.word Reset_Handler.word NMI_Handler.word HardFault_Handler.word MemManage_Handler.word BusFault_Handler.word UsageFault_Handler.word 0.word SVC_Handler.word DebugMon_Handler.word 0.word PendSV_Handler.word SysTick_Handler.word WdogWakeup_IRQHandler.word BrownOut_1_5V_IRQHandler.word BrownOut_3_3V_IRQHandler (they continue) 19

Interrupt handlers 20

Pending interrupts 21 The normal case. Once Interrupt request is seen, processor puts it in “pending” state even if hardware drops the request. IPS is cleared by the hardware once we jump to the ISR. This figure and those following are from The Definitive Guide to the ARM Cortex-M3, Section 7.4

22 In this case, the processor never took the interrupt because we cleared the IPS by hand (via a memory-mapped I/O register)

23

24

Answer 25

Interrupt pulses before entering ISR 26

Answer 27

28

29

30

31

32

33

34

35

Masking 36

37

Example of Complexity: The Reset Interrupt 1)No power 2)System is held in RESET as long as VCC15 < 0.8V a)In reset: registers forced to default b) RC-Osc begins to oscillate c)MSS_CCC drives RC-Osc/4 into FCLK d)PORESET_N is held low 3)Once VCC15GOOD, PORESET_N goes high a)MSS reads from eNVM address 0x0 and 0x4 38

The xPSR register layout 39