AT91 Interrupt Handling. 2 Stops the execution of main software Redirects the program flow, based on an event, to execute a different software subroutine.

Slides:



Advertisements
Similar presentations
CPU Structure and Function
Advertisements

More on Processes Chapter 3. Process image _the physical representation of a process in the OS _an address space consisting of code, data and stack segments.
ECE 353 Introduction to Microprocessor Systems
Lab III Real-Time Embedded Operating System for a SoC System.
Exceptions. Exception Types Exception Handling Vectoring Interrupts Interrupt Handlers Interrupt Priorities Interrupt applications 6-2.
Interrupts Chapter 8 – pp Chapter 10 – pp Appendix A – pp 537 &
Computertechniek Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology 1.
1/1/ / faculty of Electrical Engineering eindhoven university of technology Architectures of Digital Information Systems Part 1: Interrupts and DMA dr.ir.
I/O Unit.
ECE 372 – Microcontroller Design Parallel IO Ports - Interrupts
Chapter 12: Software interrupts (SWI) and exceptions
COMP3221: Microprocessors and Embedded Systems Lecture 15: Interrupts I Lecturer: Hui Wu Session 1, 2005.
Architectural Support for OS March 29, 2000 Instructor: Gary Kimura Slides courtesy of Hank Levy.
Exception Processing ECE511: Digital System & Microprocessor.
Chapter 7 Interupts DMA Channels Context Switching.
Midterm Tuesday October 23 Covers Chapters 3 through 6 - Buses, Clocks, Timing, Edge Triggering, Level Triggering - Cache Memory Systems - Internal Memory.
1 Interrupts INPUT/OUTPUT ORGANIZATION: Interrupts CS 147 JOKO SUTOMO.
ARM 7 Datapath. Has “BIGEND” input bit, which defines whether the memory is big or little endian Modes: ARM7 supports six modes of operation: (1) User.
COMP3221 lec28-exception-II.1 Saeid Nooshabadi COMP 3221 Microprocessors and Embedded Systems Lectures 28: Exceptions & Interrupts - II
COMP3221 lec27-exception-I.1 Saeid Nooshabadi COMP 3221 Microprocessors and Embedded Systems Lectures 27: Exceptions & Interrupts - I
INPUT/OUTPUT ORGANIZATION INTERRUPTS CS147 Summer 2001 Professor: Sin-Min Lee Presented by: Jing Chen.
COMP3221 lec40-exception-review.1 Saeid Nooshabadi COMP 3221 Microprocessors and Embedded Systems Lecture 40: Review of Exception
Midterm Wednesday 11/19 Overview: 25% First Midterm material - Number/character representation and conversion, number arithmetic - DeMorgan’s Law, Combinational.
Synthesis of OR 1200 Peripherals Elena Weinberg ECE 6502.
What are Exception and Interrupts? MIPS terminology Exception: any unexpected change in the internal control flow – Invoking an operating system service.
Exception and Interrupt Handling
Embedded Systems 7763B Mt Druitt College of TAFE
Introduction to Embedded Systems
Exceptions and Interrupts 2
Interrupts. What Are Interrupts? Interrupts alter a program’s flow of control  Behavior is similar to a procedure call »Some significant differences.
Lecture 23: LM3S9B96 Microcontroller - Interrupts.
CORTEX-M0 Structure Discussion 2 – Core Peripherals
MSP430 Mixed Signal Microcontroller – Parte 2 Afonso Ferreira Miguel Source: slau056d – Texas instruments.
MICROPROCESSOR INPUT/OUTPUT
Introduction to Embedded Systems Rabie A. Ramadan 6.
PIC16F877 ISR Points to note Interrupt Triggers –Individual interrupt flag bits are set, regardless of the status of their corresponding mask bit, PEIE.
1 CS/COE0447 Computer Organization & Assembly Language Chapter 5 part 4 Exceptions.
© 2008, Renesas Technology America, Inc., All Rights Reserved 1 Course Introduction Purpose  This training course provides an overview of the CPU architecture.
The Stack This is a special data structure: –The first item to be placed into the stack will be the last item taken out. Two basic operations: –Push: Places.
1 CSE451 Architectural Supports for Operating Systems Autumn 2002 Gary Kimura Lecture #2 October 2, 2002.
Operating Systems 1 K. Salah Module 1.2: Fundamental Concepts Interrupts System Calls.
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.
AT91 C-startup. 2 For reasons of modularity and portability most application code for an embedded application is written in C The application entry point.
Embedded Systems Design 1 Lecture Set 8 MCS-51 Interrupts.
Resets & Interrupts MTT CPU08 Core Motorola CPU08 RESETS & INTERRUPTS.
بسم الله الرحمن الرحيم MEMORY AND I/O.
Introduction to ARM processor. Intro.. ARM founded in November 1990 Advanced RISC Machines Company headquarters in Cambridge, UK Processor design centers.
ARM7 TDMI INTRODUCTION.
Introduction to Exceptions 1 Introduction to Exceptions ARM Advanced RISC Machines.
Cortex-M3 Exceptions RTLAB. Hyeonggon Jo.  Exceptions Exception types & priority Abort model SVC and PendSV  Interrupt operation Pre-emption & Exit.
Chapter 12: Software interrupts (SWI) and exceptions
Architectures of Digital Information Systems Part 1: Interrupts and DMA dr.ir. A.C. Verschueren Eindhoven University of Technology Section of Digital.
Microprocessor Systems Design I
Chapter 9 Exception & Interruption
Timer and Interrupts.
Computer Architecture
Interrupts In 8085 and 8086.
Programmable Interrupt Controller 8259
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.
* * * * * * * 8051 Interrupts Programming.
Subject Name: Microprocessors Subject Code:10EC46 Department: Electronics and Communication Date: /20/2018.
8259 Programmable Interrupt Controller
Chapter 12: Software interrupts (SWI) and exceptions
Architectural Support for OS
Interrupts.
Interrupt handling Explain how interrupts are used to obtain processor time and how processing of interrupted jobs may later be resumed, (typical.
ARM Introduction.
Architectural Support for OS
COMP3221: Microprocessors and Embedded Systems
Presentation transcript:

AT91 Interrupt Handling

2 Stops the execution of main software Redirects the program flow, based on an event, to execute a different software subroutine Interrupt behaviour : What are interrupts ? Main loop : Instruction 1 Instruction 2 Instruction 3 Instruction 4 Instruction 5 Interrupt routine : Instruction A Instruction B Instruction C Return from interrupt

3 Interrupt sources (1/2) External Interrupts –Allows an external event to stop program execution –Can alert the core by an edge transition or a level –Signal can originate from external peripherals or systems –Example: external switch closure Interrupts AT91

4 Interrupt sources (2/2) Internal Interrupts –Originate from on-chip peripherals –Notifies core that peripheral needs servicing –Typically can occur at any time –Can originate from software Timer/Counter ADC USART End of conversion Counter overflow End of transmission

5 ARM7TDMI Interrupt Sources Two physically independent sources Fast interrupt : FIQ –Used for fast interrupt handling –Private registers –Enable/disable with F bit in CPSR –Last vector in the exception vector table Interrupt : IRQ –Standard interrupt request –Enable/disable with I bit in CPSR ARM7TDMI Processor IRQ FIQ

6 Advanced Interrupt Controller (1/3) Features –8-level Priority –Up to 32 Interrupt sources –Individually maskable –Hardware interrupt vectoring –Internal Interrupt sources Level sensitive or edge triggered –External Interrupt sources Low/High level sensitive or positive/negative edge triggered

7 Advanced Interrupt Controller (2/3) Block Diagram

8 Advanced Interrupt Controller (3/3)

9 For multi-task systems, it is sometimes useful to share peripherals –Interrupt Mask update is interruptible –Mask Register may be lost Atomic Interrupt Control (1/2) Read IMR Modify Write IMR Read IMR Modify Write IMR OS Scheduler Task 1 Task 2 Task 1Task 2 Peripheral

10 Basic solution is to mask interrupt at core level before modifying IMR ARM7TDMI limitations: –The CPSR is accessible only in ARM state and can be updated only from Privileged Mode –Usual solution is to switch in Supervisor Mode with a SWI AT91 microcontrollers solution: –Enabling or disabling an interrupt request in only one instruction STR rx,[ry,#IER] STR rx,[ry,#IDR] Atomic Interrupt Control (2/2)

11 Each interrupt source is associated with a Source Vector Register (AIC_SVR0-AIC_SVR31) which contains the address of the interrupt handler When the Interrupt Vector Register (AIC_IVR) is read, it automatically returns the contents of the source vector register corresponding to the active interrupt Interrupt Vectors SWI ABORT (Fetch) UNDEF RESET FIQ IRQ ABORT (Data) 0xFFFFF100 0xFFFFF104 0x C 0x xFFFFF080 0xFFFFF0FC AIC_FVR AIC_IVR AIC Source vectors AIC_SVR31 AIC Interrupt vectorsARM Exception vectors ldrpc,[pc,#-&F20] Index = Interrupt Id. AIC_SVR30 AIC_SVR0 AIC_SVR1 AIC_ISR

12 The NIRQ line is controlled by an 8-level priority encoder –Each source has a programmable priority level of 7 to 0. Level 7 is the highest priority. The AIC manages the prioritization by using an internal stack on which the current interrupt level is automatically pushed when AIC_IVR is read, and popped when AIC_EOICR is written –Between these two events, the software can manage the state and the mode of the core in order to re-enable the IRQ line and to allow an interrupt with a higher priority. Interrupt Prioritization (1/4)

13 When an interrupt is managed by the processor, R14_irq and SPSR_irq are automatically overwritten without being saved –It is mandatory to save these registers before re-enabling the IRQ line and to restore them before exiting the interrupt routine If the interrupt treatment performs function calls (Branch with link), R14_irq is used. In this case, IRQ can not be re- enabled while the processor is in IRQ mode –It is mandatory to first change the processor mode to SYSTEM mode in order to keep all exceptions available Interrupt Prioritization (2/4)

14 The standard sequence of an interrupt handler is: –Validate the nested interrupts Save R14_irq and SPSR_irq in the IRQ stack Set the mode bits in CPSR with the SYSTEM Mode value Re-enable IRQ by clearing bit I in CPSR –Perfom interrupt treatment call C handler –Disable the nested interrupts Disable IRQ by clearing bit I in CPSR Set the mode bits in CPSR with the IRQ Mode value Restore R14_irq and SPSR_irq from the IRQ stack This sequence is automatically preceded by a read of AIC_IVR and must be followed by a write in AIC_EOICR before exiting from the interrupt Interrupt Prioritization (3/4)

15 Interrupt Prioritization (4/4)

16 A Spurious Interrupt occurs when the ARM7TDMI processor is interrupted and the source of interrupt has disappeared when IVR is read : –With any sources programmed to be level sensitive, if the interrupt signal of the AIC input is de-asserted at the same time as it is taken into account by the ARM7TDMI. –If an interrupt is asserted at the same time as the software is disabling the corresponding source through AIC_IDCR. Spurious Interrupt (1/2) FetchDecodeExecuteLinkretAdjust FetchDecode Fetch STR [xxx_IDR] (0x018) Branch to routine xxx Operation FetchDecodeExecute xxx NIRQ

17 The AIC is able to detect these Spurious Interrupts and returns the Spurious Vector when the IVR is read –The Spurious Vector can be programmed by the user when the vector table is initialized. It is mandatory for the Spurious Interrupt Service Routine to acknowledge the “Spurious” behavior by writing to the AIC_EOICR (End of Interrupt) before returning to the interrupted software. Spurious Interrupt Service Routine Sequence: –Adjust and save lr_irq in stack –Write the End of Interrupt Command Register –Run a trace function if necessary –Returns by restoring LR directly in PC Spurious Interrupt (2/2)

18 Atomic Interrupt Enable/Disable –Interrupt Controller Level –Peripheral Level –Resolve the problem of RISC No Read/Modify/Write Instruction Limit the Spurious Exceptions Fully Secured –Spurious Interrupt Protection Spurious Vector Register –Debugger Protection Protect Mode avoids the debugger to start an interrupt Automatic Vectoring –Speeds up the interrupt handler branching AT91 Interrupt Control Strengths (1/2)

19 Highly Programmable Sources –External Sources Edge/Level Selection –Internal Sources Edge/Level Selection Built In Test Support –Force any Interrupt Assertion High Level Operating System Compatible –Source Status Register gives the current source number –Pending Interrupt Register –NIRQ, NFIQ Signals Mirror AT91 Interrupt Control Strengths (2/2)