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,

Slides:



Advertisements
Similar presentations
Interrupts Chapter 8 – pp Chapter 10 – pp Appendix A – pp 537 &
Advertisements

Mehmet Can Vuran, Instructor University of Nebraska-Lincoln Acknowledgement: Overheads adapted from those provided by the authors of the textbook.
CSCI 4717/5717 Computer Architecture
1/1/ / faculty of Electrical Engineering eindhoven university of technology Introduction Part 3: Input/output and co-processors dr.ir. A.C. Verschueren.
EET 2261 Unit 10 Enhanced Capture Timer  Read Almy, Chapter 20.  Homework #10 and Lab #10 due next week.  Quiz next week.
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
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.
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.
Computer System Structures memory memory controller disk controller disk controller printer controller printer controller tape-drive controller tape-drive.
Introduction to Interrupts
13-1 EE 319K Introduction to Microcontrollers Lecture 13: Serial Communications Interface (SCI), Producer-Consumer problems, FIFO Queues, Lab9 Read Book.
INTERRUPTS PROGRAMMING
1 Timing System Timing System Applications. 2 Timing System components Counting mechanisms Input capture mechanisms Output capture mechanisms.
Introduction to Embedded Systems
ENG3640 Microcomputer Interfacing Week #6 Timing Generation and Measurement.
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.
Ch. 9 Interrupt Programming and Real-Time Sysstems From Valvano’s Introduction to Embedded Systems.
ECE 371- Unit 11 Timers and Counters (“Stop Watches and Alarm Clocks”)
Interrupts Signal that causes the CPU to alter its normal flow on instruction execution ◦ frees CPU from waiting for events ◦ provides control for external.
Week #5 General Interfacing Techniques
1 Computer System Overview Chapter 1. 2 n An Operating System makes the computing power available to users by controlling the hardware n Let us review.
Revised: Aug 1, ECE 263 Embedded System Design Lessons 23, 24 - Exceptions - Resets and Interrupts.
CHAPTER 3 TOP LEVEL VIEW OF COMPUTER FUNCTION AND INTERCONNECTION
Khaled A. Al-Utaibi  Interrupt-Driven I/O  Hardware Interrupts  Responding to Hardware Interrupts  INTR and NMI  Computing the.
Interrupt.
ELE22MIC Lecture 15 Applications of Parallel Input Output (I/O)
George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction.
Timer Timer is a device, which counts the input at regular interval (δT) using clock pulses at its input. The counts increment on each pulse and store.
Lecture 14 Today’s topics MARIE Architecture Registers Buses
13-Nov-15 (1) CSC Computer Organization Lecture 7: Input/Output Organization.
EE 319K Introduction to Microcontrollers
CSNB374: Microprocessor Systems Chapter 5: Procedures and Interrupts.
1 68HC11 Timer Chapter HC11 Timer Subsystem Several timing functions: Basic timing Basic timing Real time interrupts Real time interrupts Output.
1 © Unitec New Zealand Interrupt Lecture 6 Date: - 20 Sept, 2011 Embedded Hardware ETEC 6416.
3-1 EE 319K Introduction to Microcontrollers Lecture 3: Addressing modes, Memory Operations, Subroutines, I/O, Logical/Shift Operations.
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.
8-1 EE 319K Introduction to Microcontrollers Lecture 8:Fixed Point Numbers, Local Variables, Binding, Allocation, Access, Deallocation.
1 68HC11 Timer HC11 or HC12: Chapter HC11 Timer Subsystem  Several timing functions: Basic timing Basic timing Real time interrupts Real time.
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.
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.
1 68HC11 Timer. 2 68HC11 Timer Subsystem Several timing functions: Basic timing Basic timing Real time interrupts Real time interrupts Output compare.
The 8051 Microcontroller Chapter 6 INTERRUPTS. 2/29 Interrupt is the occurrence of a condition an event that causes a temporary suspension of a program.
George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction.
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.
ELE22MIC Lecture 17 Writing 68HC11 software 68HC11 Main Timer System –Output Compare –What is different about TOC1?
EET 2261 Unit 13 Enhanced Capture Timer
Why are Timer Functions Important?
ECE 3430 – Intro to Microcomputer Systems
ECE 3430 – Intro to Microcomputer Systems
Microprocessor and Assembly Language
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.
Computer Architecture
Interrupts In 8085 and 8086.
Introduction to Micro Controllers & Embedded System Design Interrupt
Interrupt Source: under
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
Presentation transcript:

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, 9.10

10-2 Ramesh Yerraballi Interrupts and Threads Interrupt  An interrupt is the automatic transfer of software execution in response to a hardware event (trigger) that is asynchronous with current software execution.  H/w event:  An external I/O device (like a keyboard or printer) requesting service,  An Internal event (like an op code fault, or a periodic timer) occurs  When the hardware needs service it performs a busy to done state transition (sets a flag) Thread  A thread is defined as the path of action of software as it executes.  ISR is a background thread  A new background thread is created for each interrupt request.  Local variables and registers used in the interrupt service routine are unique  Threads share globals

10-3 Ramesh Yerraballi Interrupts  Each potential interrupt source has a separate arm bit. E.g., C0I  Set arm bits for those devices from which it wishes to accept interrupts,  Deactivate arm bits in those devices from which interrupts are not allowed  Each potential interrupt source has a separate flag bit. E.g., C0F  hardware sets the flag when it wishes to request an interrupt  software clears the flag in ISR to signify it is processing the request  Interrupt enable bit, I, which is in the condition code register.  enable all armed interrupts by setting I=0, or cli  disable all interrupts by setting I=1, or sei I=1 does not dismiss the interrupt requests, rather it postpones

10-4 Ramesh Yerraballi Trigger-Arm-Enable Three conditions must be true simultaneously for an interrupt to occur: 1.Initialization software will set the arm bit. e.g., C0I individual control bit for each possible flag that can interrupt 2.When it is convenient, the software will enable, I=0 allow all interrupts now 3.Hardware action (trigger) sets a flag to indicate service request e.g., C0F  new input data ready,  output device idle,  periodic,  alarm

10-5 Ramesh Yerraballi Interrupt Processing What happens when an interrupt is processed? 1.The execution of the main program is suspended  The current instruction is finished,  pushes registers on the stack  sets the I bit (disallow interrupts while processing interrupt)  gets the vector address from high memory (The ISR previously was registered at this vector address) 2.the interrupt service routine (ISR), or background thread is executed,  clears the flag that requested the interrupt  performs necessary operations  communicates using global variables 3.the main program is resumed when ISR executes rti.  pulls the registers from the stack

10-6 Ramesh Yerraballi Interrupt Processing

10-7 Ramesh Yerraballi Interrupt Solution Scenarios Busy-waitInterruptsDMA PredicableVariable arrival timesLow Latency Simple I/OComplex I/O, different speedsHigh Bandwidth Fixed loadVariable load Dedicated, single threadOther functions to do Single ProcessMultithread or multiprocess Nothing else to doInfrequent but important alarms Program errors Overflow, invalid op code Illegal stack or memory access Machine errors Power failure, memory fault Breakpoints for debugging Real time clocks Data acquisition and control

10-8 Ramesh Yerraballi 9S12 Interrupts (Partial) 0xFFD4interrupt 21 SCI1 0xFFD6interrupt 20 SCI0 0xFFDEinterrupt 16 timer overflow 0xFFE0interrupt 15 timer channel 7 0xFFE2interrupt 14 timer channel 6 0xFFE4interrupt 13 timer channel 5 0xFFE6interrupt 12 timer channel 4 0xFFE8interrupt 11 timer channel 3 0xFFEAinterrupt 10 timer channel 2 0xFFECinterrupt 9 timer channel 1 0xFFEEinterrupt 8 timer channel 0 0xFFF0interrupt 7 RTI real time interrupt 0xFFF6interrupt 4 SWI software interrupt 0xFFF8interrupt 3 trap software interrupt 0xFFFEinterrupt 0 reset Interrupt Number is used by Metrowerks C Compiler

10-9 Ramesh Yerraballi Periodic Interrupts using Output Compare The rate is dependent on PLL, TSCR2 and 1000 in ISR

10-10 Ramesh Yerraballi Example: OC3.rtf OC3.rtf is different from OC.rtf in TExaS

10-11 Ramesh Yerraballi OC3.rtf DDRP equ $025A ; Port P Data Direction Register PTP equ $0258 ; Port P I/O Register TC0 equ $0050 ; Timer Input Capture/Output Compare Register 0 TCNT equ $0044 ; Timer Count Register TFLG1 equ $004E ; Main Timer Interrupt Flag 1 TIE equ $004C ; Timer Interrupt Enable Register TIOS equ $0040 ; Timer Input Capture/Output Compare Select TSCR1 equ $0046 ; Timer System Control Register1 TSCR2 equ $004D ; Timer System Control Register 2 org $4000 Main lds #$4000 movb #$80,TSCR1 ;enable TCNT bset TIOS,#$01 ;activate output compare 0 (IOS0=1) bset TIE,#$01 ;arm (COI = 1) movb #$03,TSCR2 ;1us TCNT ldd TCNT addd #25 std TC0 ;Schedule C0F to be set in 25 us: First Interrupt bset DDRP,#$C0 cli ;enable loop ldaa PTP eora #$40 staa PTP bra loop

10-12 Ramesh Yerraballi …OC3.rtf ;interrupts every 1000 TCNT cycles ;every 1ms, assuming TCNT at 1us TC0handler movb #$01,TFLG1 ;acknowledge, clear C0F ldd TC0 addd #1000 std TC0 ;setup the time for next interrupt ; this stuff (here toggle PP7)gets executed every 1 ms ldaa PTP eora #$80 staa PTP rti org $FFEE ; output compare 0 interrupt vector fdb TC0handler ; Register ISR (Handler to run when OC0 ; interrupt occurs) org $FFFE fdb Main reset vector

10-13 Ramesh Yerraballi ISR Dos Things you must do in an OC interrupt service routine Acknowledge (make C0F become one) Set the timer to specify when to interrupt next Things you must do in every interrupt service routine Acknowledge (clear flag that requested the interrupt)

10-14 Ramesh Yerraballi Ritual Things you must do in every ritual  Arm (specify a flag may interrupt)  Enable (allow all interrupts on the 9S12) Things you must do in an OC ritual  Turn on TCNT (TEN=1)  Set channel to output compare (TIOS)  Specify TCNT rate (TSCR2, PACTL, PLL)  Arm (C0I=1)  When to generate first interrupt  Enable (I=0)