EEE527 Embedded Systems Lecture 8: Practical Interrupts Ian McCrumRoom 5B18, Tel: 90 366364 voice mail on 6 th ring Web site:

Slides:



Advertisements
Similar presentations
1 Exceptions, Interrupts & Traps Operating System Hebrew University Spring 2007.
Advertisements

Exceptions. Exception Types Exception Handling Vectoring Interrupts Interrupt Handlers Interrupt Priorities Interrupt applications 6-2.
A look at interrupts What are interrupts and why are they needed.
8051 Core Specification.
EET 2261 Unit 9 Interrupts  Read Almy, Chapters 17 – 19.  Homework #9 and Lab #9 due next week.  Quiz next week.
Lab. 2 – More details – Tasks 4 to 6 1. What concepts are you expected to understand after the Lab. 2 is finished? 2. How do you demonstrate that you have.
CSC Timers Since this is a microcontroller it mainly finds itself in embedded devices Quite often embedded devices need to synchronize events The.
Interfacing. This Week In DIG II  Basic communications terminology  Communications protocols  Microprocessor interfacing: I/O addressing  Port and.
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.
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.
A look at interrupts What are interrupts and why are they needed.
Threads CS 416: Operating Systems Design, Spring 2001 Department of Computer Science Rutgers University
Dr. Kimberly E. Newman Hybrid Embedded wk3 Fall 2009.
Computer System Laboratory
What are Exception and Interrupts? MIPS terminology Exception: any unexpected change in the internal control flow – Invoking an operating system service.
ECE 265 – LECTURE 12 The Hardware Interface 8/22/ ECE265.
CSE 451: Operating Systems Autumn 2013 Module 6 Review of Processes, Kernel Threads, User-Level Threads Ed Lazowska 570 Allen.
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:
1 CS503: Operating Systems Part 1: OS Interface Dongyan Xu Department of Computer Science Purdue University.
Embedded Systems 7763B Mt Druitt College of TAFE
Introduction to Embedded Systems
COMP201 Computer Systems Exceptions and Interrupts.
Interrupts. What Are Interrupts? Interrupts alter a program’s flow of control  Behavior is similar to a procedure call »Some significant differences.
DAT2343 Accessing Services Through Interrupts © Alan T. Pinck / Algonquin College; 2003.
MCU: Interrupts and Timers Ganesh Pitchiah. What’s an MCU ?
1-1 Embedded Network Interface (ENI) API Concepts Shared RAM vs. FIFO modes ENI API’s.
1 CS/COE0447 Computer Organization & Assembly Language Chapter 5 part 4 Exceptions.
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.
Interrupt.
Operating Systems Lecture 7 OS Potpourri Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard. Zhiqing Liu School of Software.
Microprocessors 1 MCS-51 Interrupts.
EEE527 Embedded Systems Lecture 10B:Chapter 11 Analogue to Digital Convertors (ADCs) (version 2: 25/11/13, see after slide 20 Ian McCrumRoom 5B18, Tel:
Chapter 2 Introducing the PIC Mid-Range Family and the 16F84A The aims of this chapter are to introduce: The PIC mid-range family, in overview The overall.
Lab 13 Department of Computer Science and Information Engineering National Taiwan University Lab13 – Interrupt + Timer 2014/12/23 1 /16.
Timers and Interrupts Anurag Dwivedi. Let Us Revise.
1 © Unitec New Zealand Interrupt Lecture 6 Date: - 20 Sept, 2011 Embedded Hardware ETEC 6416.
EEE237 Introduction to Microprocessors Week x. SFRs.
1 ARM University Program Copyright © ARM Ltd 2013 Using Direct Memory Access to Improve Performance.
EEE527 Embedded Systems Lecture 12: Mini-Project Ian McCrumRoom 5B18, Tel: voice mail on 6 th ring Web site:
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.
7. IRQ and PIC ENGI 3655 Lab Sessions. Richard Khoury2 Textbook Readings  Interrupts ◦ Section
Embedded Systems Design 1 Lecture Set 8 MCS-51 Interrupts.
EE/CS-352: Embedded Microcontroller Systems Part V The 8051 Assembly Language Interrupts.
Time Management.  Time management is concerned with OS facilities and services which measure real time.  These services include:  Keeping track of.
Lecture 3 CSE 341 – Microprocessors Lecture 3 Md. Omar Faruqe UB 1228
Embedded Programming and Robotics Lesson 11 Arduino Interrupts 1.
Networked Embedded Systems Pengyu Zhang & Sachin Katti EE107 Spring 2016 Lecture 4 Timers and Interrupts.
Chapter 6 Limited Direct Execution Chien-Chung Shen CIS/UD
Chapter 10 Interrupts. Basic Concepts in Interrupts  An interrupt is a communication process set up in a microprocessor or microcontroller in which:
An Introduction to Embedded Systems, and the PIC Microcontroller Lecture 8: Interrupts The aims of this session are to explore the structure and application.
A walk through interrupts on the PPC 823
Interrupts and signals
Microprocessor Systems Design I
CS 6560: Operating Systems Design
Timer and Interrupts.
Anton Burtsev February, 2017
Interrupts In 8085 and 8086.
EECS 373 Design of Microprocessor-Based Systems Prabal Dutta
Computer System Laboratory
CSE 451: Operating Systems Spring 2012 Module 6 Review of Processes, Kernel Threads, User-Level Threads Ed Lazowska 570 Allen.
Interrupt Source: under
Accessing Services Through Interrupts
Interrupt Source: under
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.
Embedded System Development Lecture 7 2/21/2007
An Embedded Software Primer
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:

EEE527 Embedded Systems Lecture 8: Practical Interrupts Ian McCrumRoom 5B18, Tel: voice mail on 6 th ring Web site: "Adapted from the url “ tutorials/pic32-tutorials/pic32mx220-tutorials/interrupts” tutorials/pic32-tutorials/pic32mx220-tutorials/interrupts

What’s An Interrupt? It’s Halloween and you’re reading Lewis Carroll’s “Alice’s Adventures In Wonderland”. Every time someone knocks at the door you save your location and put down the book, go to the door and give some ghoulies candy, and then resume reading about Alice. And so it goes with embedded interrupts. With an interrupt in the embedded world, some event triggers the processor to very quickly jump to a special section of code called an interrupt service routine, do one thing or another, and then return to the previous location in code and continue with whatever was happening before. Note that this is unlike a standard function which is called by the code itself. An interrupt is generally triggered by some hardware related event and does not care what the non-interrupt code was doing when this event occurred.

Order Of Events 1. An Interrupt Request Happens An Interrupt Request or IRQ is what happens in the processor based on some trigger. This trigger can be a peripheral (SPI, UART, timers, comparators, etc.), the software, or a fault in the system. We’ll be dealing with interrupts configured by the programmer only even though most microcontroller’s startup code will also configure some interrupts such as exception handlers. In the example code below, the interrupt event is that a timer reaches it’s period value and restarts counting from The Processor Saves Its Context After the IRQ happens, the processor saves its context. The context includes location in code (the program counter) and certain processor registers. Note that the processor registers referred to here are not the special function registers or SFRs we deal with so often with PICs. 3. The Processor Finds The Appropriate Callback Function An interrupt vector table contains the locations of every possible function that can be called from an interrupt event. Based on the IRQ that happened, there will be a specific function or interrupt service routine that corresponds to that IRQ. The vector is just the pointer to that function. 4. The Interrupt Service Routine Runs The interrupt service routine or ISR is the callback function pointed to by the appropriate vector. The programmer will deal with the event in the ISR whether it’s toggling an LED or loading a buffer with audio data. Since the ISR is disrupting the normal flow of code, please keep it as short as possible and try to avoid modifying any variables that may disruptively affect non-interrupt code! If you must call a function in an ISR, don’t call a function which can’t be called a second time while that function is already running. It can happen and it can cause a system crash. 5. Return To Normal Execution Restore the programs context.

Plib.h – portable code – 314 page pdf

Look at the video “Using mplab_x_and_plib_interruptcalls_and_timer1” and the C code Five functions to setup interrupts; INTEnable(INT_T1, INT_ENABLED); INTSetVectorPriority(INT_TIMER_1_VECTOR, INT_PRIORITY_LEVEL_2); INTSetVectorSubPriority(INT_TIMER_1_VECTOR, INT_SUB_PRIORITY_LEVEL_0); INTConfigureSystem(INT_SYSTEM_CONFIG_MULT_VECTOR); INTEnableInterrupts(); and INTClearFlag(INT_T1); // inside the ISR interrupt Service Routine The 314 page pdf of the peripheral libraries has some misprints/old versions documented, use the actual header files as shown in the video. (for example the pdf documents the INTSetPriority function note the INTSetVectorPriority function.

The code in the video has

Look at the data sheet and reference manual This is on page 86 of DS_PIC32MX1xx-2xx__61168E.pdf

tutorials/pic32mx220-tutorials/interrupts Note. For ports you can write to the PORT, or write to the PORTSET or PORTCLR or PORTTOGGLE registers – very handy! Line above only clears bit 9, rest are unaltered

As an exercise, rewrite this weeks code by replacing the INT functions with the SFR bit manipulations given here – adjusted for timer 1 of course You should still call SYSTEMConfigPerformance() and INTConfigureSystem(INT_SYSTEM_CONFIG_MULT_VECTOR );