Dr. Kimberly E. Newman Hybrid Embedded wk3 Fall 2009.

Slides:



Advertisements
Similar presentations
Computer Architecture
Advertisements

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.
I/O Unit.
68HC11 Polling and Interrupts
ECE 372 – Microcontroller Design Parallel IO Ports - Interrupts
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.
CSS 372 Lecture 1 Course Overview: CSS 372 Web page Syllabus Lab Ettiquette Lab Report Format Review of CSS 371: Simple Computer Architecture Traps Interrupts.
6-1 I/O Methods I/O – Transfer of data between memory of the system and the I/O device Most devices operate asynchronously from the CPU Most methods involve.
Architectural Support for Operating Systems. Announcements Most office hours are finalized Assignments up every Wednesday, due next week CS 415 section.
1 Computer System Overview OS-1 Course AA
OS Spring’03 Introduction Operating Systems Spring 2003.
Midterm Tuesday October 23 Covers Chapters 3 through 6 - Buses, Clocks, Timing, Edge Triggering, Level Triggering - Cache Memory Systems - Internal Memory.
Hardware Support for Operating Systems Sunny Gleason Vivek Uppal COM S 414
Hardware/software Interfacing. Page 2 Interrupt handling and using internal timer Two way for processor to accept external input: Waiting for input: Processor.
1 Interrupts INPUT/OUTPUT ORGANIZATION: Interrupts CS 147 JOKO SUTOMO.
Programming I/O for Embedded System. Page 2 Overview Basis: A DE2 Computer Architecture Parallel I/O 7-Segment Display Basic Manipulating 7-Segment Display.
Mehmet Can Vuran, Instructor University of Nebraska-Lincoln Acknowledgement: Overheads adapted from those provided by the authors of the textbook.
INTERRUPTS PROGRAMMING
I/O Tanenbaum, ch. 5 p. 329 – 427 Silberschatz, ch. 13 p
1 CSC 2405: Computer Systems II Spring 2012 Dr. Tom Way.
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:
Embedded Systems 7763B Mt Druitt College of TAFE
Introduction to Embedded Systems
System Calls 1.
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.
Chapter 10 The Stack Stack: An Abstract Data Type An important abstraction that you will encounter in many applications. We will describe two uses:
MICROPROCESSOR INPUT/OUTPUT
CHAPTER 3 TOP LEVEL VIEW OF COMPUTER FUNCTION AND INTERCONNECTION
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Overview of Hardware.
Khaled A. Al-Utaibi  Interrupt-Driven I/O  Hardware Interrupts  Responding to Hardware Interrupts  INTR and NMI  Computing the.
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.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
13-Nov-15 (1) CSC Computer Organization Lecture 7: Input/Output Organization.
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.
1 Computer Systems II Introduction to Processes. 2 First Two Major Computer System Evolution Steps Led to the idea of multiprogramming (multiple concurrent.
6-1 Infineon 167 Interrupts The C167CS provides 56 separate interrupt sources that may be assigned to 16 priority levels. The C167CS uses a vectored interrupt.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
Interrupt driven I/O Computer Organization and Assembly Language: Module 12.
بسم الله الرحمن الرحيم MEMORY AND I/O.
BIOS and DOS Interrupts Basic Input /Outpu System Disk Operating System.
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.
Introduction to Operating Systems Concepts
Interrupts and exceptions
Interrupts and signals
68HC11 Interrupts & Resets.
Microprocessor Systems Design I
CS 6560: Operating Systems Design
Timer and Interrupts.
Computer Architecture
Interrupts In 8085 and 8086.
CS 3305 System Calls Lecture 7.
Chapter 10 And, Finally... The Stack
Chapter 10 The Stack.
Computer System Overview
Processor Fundamentals
Chapter 10 And, Finally... The Stack
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.
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
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:

Dr. Kimberly E. Newman Hybrid Embedded wk3 Fall 2009

Necessary Stuff Lecture Notes are now on the course website Homework #1 due date extended to Thursday. Zip and the files to me while we work out the kinks in the CULEARN Lab #3 – Interrupts and intro to debug

Polling vs. Interrupt Driven Interfacing

Expanding the I/O System Interrupt system: Allow devices to get processor’s attention Processor Memory - I/O Bus Main Memory I/O Controller Disk I/O Controller I/O Controller Graphics Network interrupts

Push Buttons

Interrupt Terms Hardware interrupt – an exception caused by a signal from hardware (request for action) IRQ- “Interrupt ReQuest” ISR- Interrupt Service Routine Code executed on the main processor in service of the device Interrupt vector - commonly referred to term for memory location holding the address of the interrupt service routine (ISR) Interrupt mask – used to block interrupts exception—Any condition or signal that interrupts normal program execution. Software: divide by 0, illegal opcode, etc.

Difference between Interrupts and Software Exceptions Interrupt is a hardware- based event Software exceptions originate from the program currently running on processor Handled in a similar way to interrupts: each designed cause will change the program to an “exception handler” routine.

NIOS II Interrupt Many devices Interrupt controller is generated by SOPC builder Controlled by IRQ number assignment 32 interrupt request lines Priority encoded IRQ[0] is highest priority

NIOS II Interrupt Controller

NIOS II Interrupt Controller 2

Exception Handling in Nios II When an interrupt occurs saves the status register disables hardware interrupts preserves the program counter or effective address register on the stack transfers control to the handler

Hardware Abstraction Layer (HAL) Lightweight runtime environment provides simple device driver interface allows access to devices with common C library functions

HAL Services Integration with C standard library Device drivers HAL API System initialization Device initialization

Interfacing with HAL Application developers using HAL API or C standard library do not consider the underlying hardware Device driver developers making drivers for low-level hardware interface newly written drivers with HAL

Generic Devices in HAL Character-mode devices Timer devices File subsystems Ethernet devices DMA devices Flash memory devices

Exception Handling in HAL Top level exception handler creates private stack stores register values onto the stack determines the type of exception and invoke the right SW or HW handler Software exception handler Hardware interrupt handler ISRs for peripherals

NIOS II Interrupt or Exception Control Diagram 1. Save the status registers 2. Disable interrupts 3. Save the EA (effective address register)…where the program was executing before interrupt Transfer control to the interrupt vector EA is also known as PC (Program Counter)

Exception Handling in HAL Check estatus to see if hardware interrupt is enabled if yes, check to see if the interrupt is hardware by checking ipending if yes, corresponding ISR is called if no, call the software exception handler Hardware interrupts have higher priority than software exceptions

Exception Handling in HAL Upon returning from exceptions, the top-level handler restores the stack pointer restores the registers from the stack exits by issuing an eret instruction

Exception Handling in HAL HW Handlers 32 hardware interrupts (0 to 31, with 0 as highest priority) priority is HAL specific and not NIOS II

Exception Handling in HAL SW handlers used for unimplemented instructions e.g. running multiplication on NIOS II with no multipliers traps

Interrupt Diagram Steps Advantage: User program progress is only halted during actual transfer Disadvantage, special hardware is needed to: Cause an interrupt (I/O device) Detect an interrupt (processor) Save the proper states to resume after the interrupt (processor) add sub and or nop read store... rti memory user program (1) I/O interrupt (2) save EA (3) Get interrupt service addr and change NIOS EA to that address interrupt service routine (4) CPU IOC device Memory :

Get Interrupt Service Address (3) Get interrupt service addr and change NIOS EA to that address For each IRQ #, there is a memory address story in an interrupt vector table (also in memory). Upon that hardware selecting which IRQ, a LOAD to the corresponding vector table entry is performed. The result of that loaded value (4 bytes) is placed in the EA (effective address) of the NIOS Processor Thus the next instruction executed is the code for the Interrupt Service Routine (ISR)

PIO Core Types: Output, Input w/ Interrupt, Bi-directional

PIO Device Map Base address assigned from SOPC But device is 4 register locations (4 bytes each location) Registers are: DATA, Direction, InterruptMask, Edgecapture

PIO CORE Data

PIO CORE Edgecapture

PIO CORE Interrupt (IRQ) Generation

PIO CORE Configurations

Expanded PIO Device Map

Hardware Abstraction Layer (HAL). –System software that allows programmer to control the hardware devices using a series of function calls –Control how or whether interrupts should be handled –i.e. turn off interrupts when code executing on NIOS II CPU is critical (time constraint), don’t allow serial input cable to get processor’s attention

HAL Interface

NIOS II Interrupt Setup Declare variable for holding information that will be passed from device to ISR Enable the device Set the control registers on the device Register the ISR with the HAL system Done in main() Develop code for ISR

Enable Device and Register ISR Register the ISR with the HAL interface: assign address of the ISR to the Interrupt vector table. Set the controls on the PIO device to capture and cause interrupts Declare variable to hold state of device that will be passed to ISR

Enable Device and Register ISR This is decided at SOPC builder time, user can define which IRQ # [0 up to 31] Memory- mapped device address assigned at SOPC builder time

NIOS II Interrupt Example ISR #include “system.h” #include “altera_avalon_pio_regs.h” #include “alt_types.h” static void handle_button_interrupts(void* context, alt_u32 id) { // cast the context pointer to an integer pointer. volatile int* edge_capture_ptr = (volatile int*) context; //Read the edge capture register on the button PIO & Store value. *edge_capture_ptr= IORD_ALTERA_AVALON_PIO_EDGE_CAP(BUTTONS_BASE); //Write to the edge capture register to reset it. IOWR_ALTERA_AVALON_PIO_EDGE_CAP(BUTTONS_BASE, 0); // reset interrupt capability for the Button PIO. IOWR_ALTERA_AVALON_PIO_IRQ_MASK(BUTTONS_BASE, 0xf); }

NIOS II Interrupt Example ISR-Expanded static void handle_button_interrupts(void* context, alt_u32 id) { // cast the context pointer to an integer pointer. volatile int* edge_capture_ptr = (volatile int*) context; //Read the edge capture register on the button PIO & Store value. *edge_capture_ptr= IORD_ALTERA_AVALON_PIO_EDGE_CAP(BUTTONS_BASE); //Write to the edge capture register to reset it. IOWR_ALTERA_AVALON_PIO_EDGE_CAP(BUTTONS_BASE, 0); // reset interrupt capability for the Button PIO. IOWR_ALTERA_AVALON_PIO_IRQ_MASK(BUTTONS_BASE, 0xf); if ( *edge_capture_ptr == 1) // Check if the first button was pressed LCDwrite("hello world\n"); if ( *edge_capture_ptr == 4) // Check if the 4 th button was pressed { IOWR(LEDS_BASE,0, (1 & 0xF)); // Write 1 to the LEDs usleep( ); IOWR(LEDS_BASE,0, (0 & 0xF)); // Write 0 to the LEDs }

NIOS II Interrupt Handling Performance