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)

Slides:



Advertisements
Similar presentations
8085 Interrupts LAKSHMI.B.E.1. Interrupts  Interrupt is a process where an external device can get the attention of the microprocessor. ◦ The process.
Advertisements

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,
ECE 447 Fall 2009 Lecture 9: TI MSP430 Interrupts & Low Power Modes.
CSCI 4717/5717 Computer Architecture
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.
Exception Processing ECE511: Digital System & Microprocessor.
1 Interrupts INPUT/OUTPUT ORGANIZATION: Interrupts CS 147 JOKO SUTOMO.
Introduction to Interrupts
INTERRUPTS PROGRAMMING
Exceptions and Interrupts 2
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.
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.
Week #5 General Interfacing Techniques
Chapter 6: Interrupts and Resets
M Semiconductor Products Sector Computer Operating Properly Module Detail Slide #1 of 7 Tutorial Introduction PURPOSE -To explain how to configure and.
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.
Microprocessors 1 MCS-51 Interrupts.
ELE22MIC Lecture 15 Applications of Parallel Input Output (I/O)
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.
Low Power Modes MTT48 V LOW POWER OPERATION.
1 © Unitec New Zealand Interrupt Lecture 6 Date: - 20 Sept, 2011 Embedded Hardware ETEC 6416.
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.
AT91 Interrupt Handling. 2 Stops the execution of main software Redirects the program flow, based on an event, to execute a different software subroutine.
Dec Hex Bin 14 E ORG ; FOURTEEN Interrupts In x86 PC.
System Integration Module MTT Motoola SYSTEM INTEGRATION MODULE (SIM)
Embedded Systems Design 1 Lecture Set 8 MCS-51 Interrupts.
MICRO-CONTROLLER MOTOROLA HCS12 Interrupts Mechatronics Department Faculty of Engineering Ain Shams University.
Resets & Interrupts MTT CPU08 Core Motorola CPU08 RESETS & INTERRUPTS.
بسم الله الرحمن الرحيم MEMORY AND I/O.
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.
Computer Operating Properly Module MTT COMPUTER OPERATING PROPERLY MODULE (COP)
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.
INTV1 & MMCV4 By: Prof. Mahendra B. Salunke Asst. Prof., Department of Computer Engg., SITS, Pune-41 URL: microsig.webs.com.
INSTITUTE: INSTITUTE:PARUL INSTITUTE OF TECHNOLOGY BRANCH : BRANCH :B.E. E.C.5 TH SEM. SUBJECT:MICROCONTROLLER & INTERFACING TOPIC:AVR INTTRUPT TOPIC:AVR.
Chapter 10 Interrupts. Basic Concepts in Interrupts  An interrupt is a communication process set up in a microprocessor or microcontroller in which:
HCS12 Exceptions Maskable Interrupts
ECE 3430 – Intro to Microcomputer Systems
8085 Interrupts LAKSHMI.B.E..
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.
Subject Name: Microprocessors Subject Code:10EC46 Department: Electronics and Communication Date: /20/2018.
Resets & Interrupts.
Lecture 9: TI MSP430 Interrupts & Low Power Modes
Interrupts.
Md. Mojahidul Islam Lecturer Dept. of Computer Science & Engineering
Md. Mojahidul Islam Lecturer Dept. of Computer Science & Engineering
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:

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) For a more detailed description see the Reset and Interrupt Section of the Reference Manual (pp )

3 Interrupts An interrupt is an event that causes the CPU to suspend whatever is doing (running a program) handle the interrupt (running a routine servicing the interrupt) and then resumes what it was doing To handle the interrupt the CPU jump to a special routine called an interrupt service routine (ISR) or an interrupt handler The difference from a subroutine is that ISRs are located at pre-determined starting addresses

4 Resets A Reset is a special type of interrupt. Resets do not return back to finish executing the interrupted program Resets are used to force the MCU to assume a set of initial conditions and to begin executing instructions from a predetermined starting address When a reset occurs, the CPU finishes executing the present instruction and then begins execution of the reset routine

5 Types of Reset RESET pin Power-On Reset (POR) Computer Operating Properly (COP) Watchdog Timer Reset Clock Monitor Fail (CMF) Reset

6 Resets Operation: RESET and POR POR and the external RESET pin have highest priority that any other reset or interrupt. They share the address vector $FFFE,$FFFF POR is delayed by 4046 clock cycles (to allow the oscillator to settle)

7 Resets Operation: COP COP failure is intended to detect software processing errors. If the CPU watchdog times out a reset is initiated. To prevent a COP failure reset from occurring the application program must “clear” the watchdog timer on a regular basis. To “clear” the COP timer the application program must follow a 2- step sequence. It must write a $55 to the COPRST (at $103A) register followed by writing a $AA to the COPRST register. The COP system is enabled or disabled depending on the state of the NOCOP bit in the CONFIG register (at $103F). The COP timeout period is set by the timer rate control bits CR1 and CR0 in the configuration OPTION register (at $1039).

8 Nominal COP Timeout

9 Control Registers

10 Resets Operation: Clock Monitor This reset triggers if the CPU clock drops below a frequency of 10KHz. To enable the clock monitor reset, set the clock monitor enable (CME) bit in the system’s configuration options register (OPTION at $1039) The clock monitor reset is based on an internal resistor-capacitor (RC) time delay. When a crystal fails it can still generate approximately 1000 more cycles due to its internal capacitance.

11 Types of Interrupt A microcontroller uses interrupts for “critical tasks” that cannot wait, such as I/O events. There are many separate interrupt sources Some are generated by a signal at an external pin Others are generated when special bits are set (a combination of hardware and software causes these bits to set).

12

13 Interrupt Vectors Customization The programmer can customize the service routine addresses by using a vector jump table. The “elements” of the vector jump table are called pseudo-vectors or jump vectors. The pseudo vectors are in RAM Each pseudo vector takes three bytes of RAM

14 Pseudo-vectors

15 Stacking the Registers An ISR will most likely change the content of some of the CPU registers An ISR also needs to know where to return to when it has completed servicing the request When an interrupt request occurs and it is enabled the CPU will push all the CPU register values onto the stack before it fetches the vector An ISR use the instruction RTI to return control back to the program interrupted. When RTI is executed, it pulls the data from the stack to restore them to the CPU registers Resets do not stack the CPU registers, since a reset routine does not normally return control back to the program interrupted.

16 Stacking Order

17 Interrupt Priority

18 Interrupt Priority

19 Priority of the Maskable Interrupts The priority of each interrupt source is fixed, however the user can promote one of the maskable interrupts to the highest priority among the maskable interrupts by programming the HPRIO register

20 Priority of the Maskable Interrupts

21 Nested Interrupts After Stacking the registers, the CPU sets the I bit in the CCR to prevent any other interrupts from occurring If the interrupt service routine does not clear the I bit, only non- maskable interrupts can interrupt the routine When interrupt routines are interrupted, a condition of nested interrupts is said to exist Many systems try to avoid nested interrupts because it makes the software more complicated and there is a danger of stack overflow Nonmaskable interrupts and resets will always be able to interrupt a low-priority maskable interrupt It is possible to change the priority level of any one of the maskable (I-bit related) interrupts using the highest priority interrupt (HPRIO at $103C) register

22 Interrupt masking and enabling  Microcontrollers can be programmed to ignore some interrupt sources. This is achieved by not setting a special bit called the interrupt’s enable bit.  The process of ignoring an interrupt is called masking.  Interrupts that can be enabled/disabled are called maskable.  Each maskable interrupt has its own corresponding enable or mask bit.  Typically, an enable/mask bit is set or cleared by writing to a specific I/O control or status register  When an enable bit is set to 1, the CPU will respond to the interrupt request, when is set to 0, the CPU will ignore the request.  When a mask bit is set to 1, the CPU will ignore the interrupt request, when is set to 1, the CPU will respond to the request.

23 CCR Register and Interrupts  Most interrupts are maskable by the I bit in the CCR.  If the I bit is set, all the associated interrupts are masked.  The SEI instruction set the I bit of the CCR. It disables interrupt globally.  The CLI instruction clear the I bit of the CCR. It enables interrupt globally.  To mask only some of the interrupts covered by the I bit, the I bit is cleared using the CLI instruction and then each interrupt is individually masked by writing to the associated control register.

24 CCR Register and Interrupts

25 Example

26 Hardware Interrupts Illegal Opcode Trap Non-Maskable Interrupt (XIRQ) Interrupt Request (IRQ)

27 Illegal Op code Trap A trap is the part of a program that catches an error condition and indicate to the user that an error has occurred. In many cases, the errors are of such a nature that program execution must be aborted. It is up to the programmer to decide what error conditions are to be trapped and how they are to be handled. For example a divide by zero error may be a trap. The 68HC11 comes with a built in trap for illegal op codes. If the fetched code does not correspond to any instruction the illegal op code trap (IOP) interrupt takes place. What the IOP interrupt routine should do depends on the application.

28 Non maskable interrupt (XIRQ) By default when you power up or reset the microcontroller, XIRQ is masked. That is, the X bit in the CCR is set. To unmask XIRQ, you use the TAP instruction to clear bit X. TPA ;get original CCR ANDA #$BF ;reset bit 6, (X) TAP;put it back in CCR Once the program has cleared X, executing another TAP will not set X again. The only way to set X again is through a reset. While the service routine is executing, the CPU will set bit X and I. Unless the service routine reset the I bit or the X bit this prevents other interrupts from interfering. When the service routine executes RTI the original CCR contents is recovered.

29 XIRQ Example

30 XIRQ Example in Assembly *Demonstrate XIRQ ORG $9000 mainLDS #$FF ;define the stack LDX #$1122;modify some registers LDY #$3344 LDAB #$55 *enable XIRQ TPA;get original CCR ANDA #$BF;reset bit 6 (X) TAP;put it back in CCR LDAA #$1C;now possible to interrupt LDAB #$C1 ; here BRA here ;end main * xirq service routine rxirqLDX #$6677;modify some registers LDY #$8899; LDAA #$AA LDAB #$BB RTI; return from rxirq *Define Vectors ORG $FFF4 VXIRQFDB rxirq;start address of rxirq VSWIFDB here VILLOPFDB VCOPFDB here VCMFFDB here VRESFDB main

31 /* XIRQ Example */ unsigned int data; /* data to increment */ void main(void) { data = 0; /* initialize data */ /* setup jump vector */ asm(“ldaa #0x7E”); /*opcode of jump (extended) */ asm(“staa 0xF1”);/* the jump instr. is put at address $00F1*/ asm(“ldd #rxirq); asm(“std 0xF2”); /*enable XIRQ */ asm(“tpa”); asm(“anda #0xBF”); asm(“tap”); while(1); /* loop forever */ } void rxirq(void) /* interrupt service routine for XIRQ */ { data++; asm(“rti”); } XIRQ Example in C

32 Interrupt request is maskable by setting bit 1 in the CCR You can mask IRQ using the instruction SEI You can unmask IRQ using CLI It is also possible to program IRQ to be edge sensitive or level sensitive To make IRQ edge sensitive only you have to set the IRQE bit (bit 5) in the OPTION register (at $1039). Some bits in OPTION are time protected. They can be changed only within the first 64 clock cycles after a reset. Interrupt Request (IRQ)

33 Interrupt Configuration To set up interrupt operation, it is necessary to do some configuration (“ritual”) During the configuration steps it is prudent to disable interrupts Typically, after configuration is complete, interrupts are enabled

34 Interrupt Configuration: Example *Demonstrate Interrupt Configuration ORG $9000 mainLDS #$FF ;define the stack SEI;mask IRQ interrupt LDX #$1000 BSET $39,X $20;turn on CR1 bit in OPTION CLI;unmask IRQ interrupt NOP;let interrupt drive program hereBRA here * irq service routine rirqINC $00;modify location $0000 of memory RTI;return from rirq *Define Vectors ORG $FFF2 VIRQFDB rirq;start address of rirq VXIRQFDB here VSWIFDB here VILLOPFDB here VCOPFDB here VCMFFDB here VRESFDB main; start address for reset

35 Interrupt Polling Interrupt polling is a way to determine which one of multiple devices has requested the interrupt. If several devices are all connected through external logic circuitry to the interrupt pin of the microcontroller, there is no immediate way to know which device requested the interrupt. The microcontroller reads the status register of each device to find the one that requested the interrupt. It can then call the appropriate service routine for that device.

36 Software Interrupt Software interrupt (SWI) is a special instruction that has several aplications When executed, it behaves like an interrupt by stacking the registers, setting the I bit in the CCR, and fetching the contents of address $FFF6, $FFF7. It can be used to simulate hardware interrupts during system development It can be used for debugging programs (setting breakpoints in your program)

37 CPU Control and Monitoring COP failure reset Clock monitor fail reset The Real Time Interrupt (RTII) generates an interrupt whenever a specifies period of time expire.

38 Real Time Interrupt (RTII) Some application do not need to be executing a program all the time but need to be “woken up” when required. The RTII is useful for programs that don’t need to be executing code all the time RTII can be used to “wake up” the program The microcontroller can reduce power consumption while waiting to be woken up.

39 Real Time Interrupt (RTII)

40 WAI and STOP instruction The WAI stacks the registers and waits for an unmasked interrupt, suspending execution The effect of executing STOP depends on the S bit in the CCR If the S bit is set. The CPU treats STOP like a NOP and continues on to execute any instructions following the STOP. If the S bit is reset all internal clocks in the CPU halt, thus halting execution. This puts the microcontroller in the state of lowest power consumption. To wake up the controller, a RESET, XIRQ or IRQ is needed.