Introduction to Interrupts

Slides:



Advertisements
Similar presentations
Interrupts, Low Power Modes and Timer A (Chapters 6 & 8)
Advertisements

Interrupts Chapter 8 – pp Chapter 10 – pp Appendix A – pp 537 &
External Interrupt Module MTT EXTERNAL INTERRUPT REQUEST MODULE (IRQ)
I/O Unit.
10-1 EE 319K Introduction to Microcontrollers Lecture 10: Interrupts, Output Compare Periodic Interrupts Read Book Sections 9.1, 9.2, 9.4, 9.6.1, 9.6.2,
68HC11 Polling and Interrupts
EET 2261 Unit 9 Interrupts  Read Almy, Chapters 17 – 19.  Homework #9 and Lab #9 due next week.  Quiz next week.
ECE 372 – Microcontroller Design Parallel IO Ports - Interrupts
COMP3221: Microprocessors and Embedded Systems Lecture 15: Interrupts I Lecturer: Hui Wu Session 1, 2005.
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.
Introduction An interrupt is an event which informs the CPU that its service (action) is needed. Sources of interrupts: internal fault (e.g.. divide by.
1 Interrupts INPUT/OUTPUT ORGANIZATION: Interrupts CS 147 JOKO SUTOMO.
Introduction to Interrupts
1 Reset and Interrupts Advanced Programming. 2 Resets and Interrupts See the Reset and Interrupts Section in the 68HC11E Family Technical Data Sheet (pp.79-96)
The 8051 Microcontroller and Embedded Systems
INTERRUPTS PROGRAMMING
Interrupts, Thermistors, Opto-isolators and Phototransistors Fall 2009 Kipp Schoenwald Stephen Hunte Joseph Storey.
Interrupts, Phototransistors, Opto-isolators, Triacs, and Thermistors Alex Buchanan Aaron May Peter Ngo.
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:
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.
Input/Output mechanisms
1 ATD10B8CV2 on MC9SI2C By: Yuchun Huang. 2 ADC ADC Power Supply.
Week #5 General Interfacing Techniques
Chapter 6: Interrupts and Resets
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.
ME 4447/6405 Interrupts and Resets Suzanne Price Scott Gilliliand Greg Graf.
Interrupts and reset operations. Overview  Introduction to interrupts – What are they – How are they used  68HC11 interrupt mechanisms – Types of interrupts.
Interrupt.
I/O Interfacing A lot of handshaking is required between the CPU and most I/O devices. All I/O devices operate asynchronously with respect to the CPU.
Accessing I/O Devices Processor Memory BUS I/O Device 1 I/O Device 2.
13-Nov-15 (1) CSC Computer Organization Lecture 7: Input/Output Organization.
CSNB374: Microprocessor Systems Chapter 5: Procedures and Interrupts.
1 © Unitec New Zealand Interrupt Lecture 6 Date: - 20 Sept, 2011 Embedded Hardware ETEC 6416.
ELE22MIC Lecture 8 ASll Examples –16 Bit Counters –Buffalo Jump Table Interrupt processing (IRQ/RTI) Stack Frame & Base Pointer Wired OR.
George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction.
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.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
System Integration Module MTT Motoola SYSTEM INTEGRATION MODULE (SIM)
Execution Architecture MTT CPU08 Core M CPU08 INTRODUCTION.
MICRO-CONTROLLER MOTOROLA HCS12 Interrupts Mechatronics Department Faculty of Engineering Ain Shams University.
Resets & Interrupts MTT CPU08 Core Motorola CPU08 RESETS & INTERRUPTS.
George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction.
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.
HCS12 Exceptions Maskable Interrupts
ECE 3430 – Intro to Microcomputer Systems
ECE 3430 – Intro to Microcomputer Systems
MICROPROCESSOR BASED SYSTEM DESIGN
68HC11 Interrupts & Resets.
Microprocessor Systems Design I
ECE 3430 – Intro to Microcomputer Systems
Mon. Oct 2 Announcements Quiz Postponed to Wednesday – still only on 2.a + 2.b Video lecture for 2.a posted Lab 6 experiment extension You must come to.
Timer and Interrupts.
Interrupts In 8085 and 8086.
BVM Engineering College Electrical Engineering Department : Microprocessor and Microcontroller Interfacing Interrupts of 8051 Prepared by:
* * * * * * * 8051 Interrupts Programming.
11.1 Interrupt Mechanism, Type, and Priority
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:

Introduction to Interrupts Outline of the lecture: Chandana: 1. Introduction 2. Example 3. Definition 4. Vector table and Maskable/nonmaskable interrupts ________________________________________________ Hao: 5. Stack status 6. HPRIO 7. Example

Polling and Interrupts Polling- Imagine a phone without a bell. You would have to periodically answer the phone to see if anyone is there Interrupt – Phone with a bell. You can do something else and stop and answer the phone when it rings

Polling Pros and Cons Pros Simple Implementation Good for single I/O cases Doesn’t need extra hardware Cons Inefficient for complex systems May not be fast enough for requirements

Interrupts Pros vs. Cons Efficient for complex systems (great multitasking) Can be ignored (masked) Can be prioritized Cons Tradeoff of hardware complexity Can make debugging difficult due to unanticipated random occurrences

Applications Computer Keyboard Stability Control System on Car House security system Pause button on television

Ways Interrupts can be generated Hardware Interrupts Peripherals such as a printer or fax machine Computer Operator via keyboard, mouse or power on reset button Another computer Software Interrupts Timer resets Timer interrupts Traps Request for input or output Arithmetic overflow error

Some Definitions Interrupt Service Routine (interrupt handler): This is a “more important” instruction code that interrupts your main program code. The routine is specific to the type of interrupt called. Interrupt Vector: This is an address in memory where the ISR instruction code is located. It is the starting address of the code. (Like a pointer) Interrupt Vector Table: This is a table indicating the interrupt vector Main Program Blah blah blah ISR Code Blah blah blah RTI $FFF6

Interrupt Flow A B Interrupt condition is met Analyze Priority ISR instruction YES Mask(s) set? Set (I) or (X) to prohibit another Interrupt RTI NO NO YES Complete Current Instruction Clear I or X bit in CCR Standard Interrupt Table Restore Registers w/ org. Values Store all registers on the Stack Load Address in appropriate vector Continue Program A B

Non-Maskable Interrupts Higher Priority than maskable interrupts Can interrupt Maskable Interrupt ISRs X=1 ONLY disables XIRQ interrupt (and all other interrupts are still enabled when X=1) POR of RESET pin Clock monitor reset COP watchdog reset Unimplemented instruction trap Software interrupt (SWI) XIRQ interrupt

XIRQ & IRQ

Non-Maskable Interrupts At Reset or during Non-Maskable interrupt X=1 and I=1 Interrupts cannot be serviced Clear X bit TAP instruction ANDCC #$40 instruction Software cannot set X bit once cleared unless non-maskable interrupt occurs RTI restores X and I bits to pre-interrupt state

Non-Maskable Interrupts XIRQ Externally triggered PE0 pin low = XIRQ interrupt SWI Allows an interrupt without an event MON12 in use: jumps back to DBug12 Unimplemented Instruction Trap CPU is given code with invalid opcode Generates interrupt request to unimplemented instruction trap vector

Maskable Interrupts 27 Maskable Interrupts Global Masking: controls execution of all maskable interrupts (ie. I bit =1, no maskable interrupts occur) Local Masking: controls execution of interrupt on a peripheral device (ie. ATD) IRQ Real-Time Interrupt Standard Timer Channel 0 Standard Timer Channel 1 Standard Timer Channel 2 Standard Timer Channel 3 Standard Timer Channel 4 Standard Timer Channel 5 Standard Timer Channel 6 Standard Timer Channel 7 Standard Timer Overflow Pulse Accumulator A Overflow Pulse Accumulator Input Edge SPI transfer Complete SCI system ATD Port J CRG PLL Lock CRG Self Clock Mode Flash CAN Wakeup CAN Errors CAN Receive CAN Transmit Port P PWM Emergency Shutdown VREG LVI

Maskable Interrupts IRQ Only external maskable interrupt signal IRQE bit on IRQCR Register IRQE=1: High level-Sensitive IRQE=0: Low Level-Sensitive Peripheral Subsystems (all other Maskable Interrupts) Flag bit and interrupt enable bit ATD, Timers, PWM, serial communications, etc.

Interrupt Vector Tables

Interrupt Vector in Mon12 MON12 interrupt vectors are used. ($0F00-$0FFF ) MON12’s calls ISR’s specified by the user in the $0Fxx range The microcontroller calls ISR’s specified in the $FFxx range.

Interrupts: Stack Stack Pointer before Interrupt RTN LO Higher Address Stack Pointer before Interrupt RTN LO First Pushed In Last Pulled Off RTN HI Y LO RTN – address of next instruction in Main Program, upon return from interrupt. X LO and Y LO are the low bytes of X and Y registers. X HI and Y HI are the high bytes of X and Y registers. ACC A and ACC B are the accumulators. CCR is the Code Condition Register Y HI X LO X HI ACC A Last Pushed In First Pulled Off ACC B CCR Stack Pointer after Interrupt Lower Address

Highest Priority Interrupt (HPRIO) Register Address: $001F Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 1 PSEL7 PSEL6 PSEL5 PSEL4 PSEL3 PSEL2 PSEL1 - HPRIO register moves one maskable interrupt to top of priority list Cannot change priority of non-maskable interrupts Procedures to increase priority of maskable interrupt: Set I bit to disable maskable interrupts Write low byte of the starting interrupt vector address to HPRIO Clear I bit to re-enable maskable interrupts

Highest Priority Interrupt Register (HPRIO) Address: $001F Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 1 PSEL7 PSEL6 PSEL5 PSEL4 PSEL3 PSEL2 PSEL1 - PSEL[7:1] – Priority Select Bits Write the low byte of the starting maskable interrupt vector to HPRIO to elevate that maskable interrupt to the highest priority Ex: writing $DE (#%11011110) to HPRIO elevates the Standard Timer Overflow to highest priority (Standard Timer Overflow vector = $FFDE & $FFDF)

ATD Interrupt Example : ISR Polling code from our Lab 2: CHECK LDX #ATDSTAT0 BRCLR $00,X #%1000000 CHECK * Wait until conversion completes Write an Interrupt Service Routine (ISR) to be run to print out the ATD results when conversion is finished Other programs still running during the conversion Continuous conversion

ATD Interrupt Example : ISR *Interrupt Service Routine ORG $2000 LDAA ATDDR0H STAA LSTCONV LDAA #$00 *Load D with LSTCONV LDAB LSTCONV LDX #51 *Load x with #51 IDIV *Divides D by X ->D:X XGDX ADDB #$30 STAB V1 *Stores B to v1 LDAA #10 *Load A with 10 MUL *Multiply A and B (low byte of D) LDX #51 IDIV STAB V2 *Stores B to v2 LDX #STRING1 JSR OUTSTRG LDAA #%00010000 *Scan=0, MULT=0, CC:CA=000 (AN0) STAA ATDCTL5 *Start Conversion by setting ATDCTL5 RTI Define a starting address Read ATD result register Store value to a reserved memory location Convert value and print to screen Writing to ATDCTL5, only convert data from AN0 Ensures that we will get the next interrupt (SCF is cleared) Finally, call RTI to return from the ISR and pull CPU register values back from the stack

ATD Interrupt Example: Setup Set up interrupt vector table for the ATD Interrupt Write the address of the first instruction of the ISR ($2000) to ATD interrupt vector ($0FD2) Enable ATD interrupt Setting ASCIE bit (ATDCTL2) to enable ATD interrupts (local mask) Enable global maskable interrupts Processor is then free to run other code

ATD Interrupt Example: Setup ORG $1000 SEI LDX #$2000 STX $0FD2 LDAA #%10000010 STAA ATDCTL2 LDAA #%00001000 STAA ATDCTL3 LDAA #%10000101 STAA ATDCTL4 LDY #100 L1 DEY BNE L1 CLI LDAA #%00000000 STAA ATDCTL5 Set I bit to make Interrupt Vector Table changes safe Store the address of our ISR ($2000) to the Interrupt Vector for the ATD ($0FD2) Set the ASCIE bit (bit 1 in ATDCTL2) to enable local ATD interrupts Set that only one conversion each sequence Set ATD resolution and prescale Wait for the ATD to fully power up Clear the I-bit to enable all maskable interrupts Starting conversion by setting ATDCTL5, Scan=0, MULT=0, CC:CA=000 (AN0)

ATD Interrupt Example: Full Code ATDCTL2 EQU $0082 ATDCTL3 EQU $0083 ATDCTL4 EQU $0084 ATDCTL5 EQU $0085 ATDSTAT0 EQU $0086 ATDDR0H EQU $0090 LSTCONV EQU $800 OUTSTRG EQU $FF5E ORG $802 STRING1 FCC "The voltage is " V1 RMB 1 FCC " . " V2 RMB 1 FCC " Volts" FCB $0A,$0D,$04 ORG $1000 SEI LDX #$2000 *Start address of ISR STX $0FD2 *ATD Service Routine Vector LDAA #%10000010 *ADPU = 1, ASCIE=1, ASCIF=0 STAA ATDCTL2 LDAA #%00001000 * one conversion each sequence STAA ATDCTL3 LDAA #%10000101 *Resolution and prescale STAA ATDCTL4 LDY #100 *ATD Converter Startup Delay L1 DEY BNE L1 CLI LDAA #%00000000 *Scan=0, MULT=0, CC:CA=000 (AN0) STAA ATDCTL5 *Start Conversion by setting ATDCTL5 ………… *All kinds of programs Loop ******* *Many other calculations may be performed here ****** JMP Loop SWI END *Interrupt Service Routine ORG $2000 LDAA ATDDR0H STAA LSTCONV LDAA #$00 *Load D with LSTCONV LDAB LSTCONV LDX #51 *Load x with #51 IDIV *Divides D by X ->D:X XGDX ADDB #$30 STAB V1 *Stores B to v1 LDAA #10 *Load A with 10 MUL *Multiply A and B (low byte of D) LDX #51 IDIV STAB V2 *Stores B to v2 LDX #STRING1 JSR OUTSTRG LDAA #%00010000 *Scan=0, MULT=0, CC:CA=000 (AN0) STAA ATDCTL5 *Start Conversion by setting ATDCTL5 RTI Define Constants (ex: ATDCTL4) Interrupt Service Routine Define Strings and reserve memory Setup ADC and ADC Interrupt Convert value and print to screen Start next conversion Back to main program Run any other code