Interrupts, Low Power Modes

Similar documents
Lecture 5: MSP430 Interrupt

Lab 4: Interrupt. CS4101 Introduction to Embedded Systems. Prof. Chung-Ta King. Department of Computer Science National Tsing Hua University, Taiwan

Wireless Sensor Networks (WSN)

Lecture test next week

What is an Interrupt?

Texas Instruments Mixed Signal Processor Tutorial Abstract

Interrupts CS4101 嵌入式系統概論. Prof. Chung-Ta King. Department of Computer Science National Tsing Hua University, Taiwan

// Conditions for 9600/4=2400 Baud SW UART, SMCLK = 1MHz #define Bitime_5 0x05*4 // ~ 0.5 bit length + small adjustment #define Bitime 13*4//0x0D

MSP430 Interrupts. Change value of internal variable (count) Read a data value (sensor, receive) Write a data value (actuator, send)

ECE2049: Embedded Computing in Engineering Design C Term Spring 2019 Lecture #22: MSP430F5529 Operating Mode & the WDT

Today's plan: Announcements General Strategy Microcontroller programming concepts/last bits of assembly Activity 2

Lab 4 Interrupts ReadMeFirst

IV B.Tech. I Sem (R13) ECE : Embedded Systems : UNIT -2 1 UNIT 2

Lab 1: I/O, timers, interrupts on the ez430-rf2500

University of Texas at El Paso Electrical and Computer Engineering Department. EE 3176 Laboratory for Microprocessors I.

Grundlagen Microcontroller Interrupts. Günther Gridling Bettina Weiss

6. General purpose Input/Output

CPE 325: Embedded Systems Laboratory Laboratory #7 Tutorial MSP430 Timers, Watchdog Timer, Timers A and B

Designing for Ultra-Low Power with MSP430

Interrupt Driven Programming in MSP430 Assembly (ESCAPE) *

TPL5000EVM User's Guide

ECE 492 WINTER 2015 GROUP 2. Texas Instruments MSP430-FR Bit ADC Setup Guide

MSP430. More on MSP430

CONTENTS: Program 1 in C:

ECGR 4101/5101, Fall 2016: Lab 1 First Embedded Systems Project Learning Objectives:

EEL 4744C: Microprocessor Applications. Lecture 7. Part 1. Interrupt. Dr. Tao Li 1

Reading Assignment. Interrupt. Interrupt. Interrupt. EEL 4744C: Microprocessor Applications. Lecture 7. Part 1

PHYS 319. Things to do before next week's lab Whirlwind tour of the MSP430 CPU and its assembly language Activity 1.

Interfacing CMA3000-D01 to an MSP430 ultra low-power microcontroller

Block diagram of processor (Harvard)

Timer Module Timer A. ReadMeFirst

Interrupt Basics Karl-Ragmar Riemschneider

Before next weeks lab:

UC Berkeley EE40/100 Lab Lab 6: Microcontroller Input/Output B. Boser, etc.

CPE 323: MSP430 Timers

Using peripherals on the MSP430 (if time)

Microprocessors & Interfacing

Interrupts (I) Lecturer: Sri Notes by Annie Guo. Week8 1

ECE2049: Embedded Computing in Engineering Design A Term Fall Lecture #8: Making it work: LEDs, Buttons & Keypad

University of Texas at El Paso Electrical and Computer Engineering Department. EE 3176 Laboratory for Microprocessors I.

063[[[0LFURFRQWUROOHUV /RZ3RZHU0RGHV &3($GYDQFHG0LFURFRPSXWHU7HFKQLTXHV 'U(PLO-RYDQRY /RZ3RZHU. Power: A First-Class Architectural Design Constraint

Interfacing CMR3000-D01 to an MSP430 ultra low-power microcontroller

MIDTERM#1. 2-(3pts) What is the difference between Von Neumann & Harvard processor architectures?

Create and Add the Source File

Introduction to Embedded Systems

Real Time Embedded Systems. Lecture 10 January 31, 2012 Interrupts

Interrupts and Using Them in C

Interrupts and Low Power Features

ECE PRACTICE EXAM #2 Clocks, Timers, and Digital I/O

ECE2049 Homework #2 The MSP430 Architecture & Basic Digital IO (DUE Friday 9/8/17 at 4 pm in class)

CHAPTER 11 INTERRUPTS PROGRAMMING

Design and Implementation Interrupt Mechanism

Review Activity 1 CALL and RET commands in assembler

Why embedded systems?

Interrupts. Why Interrupts

Physics 319 Spring 2015: Introduction to the Programming and Use of Microprocessors

ECE2049: Embedded Computing in Engineering Design C Term Spring Lecture #7: More Digital IO

Course Introduction. Purpose: Objectives: Content: 27 pages 4 questions. Learning Time: 20 minutes

Timers and Clocks CS4101 嵌入式系統概論. Prof. Chung-Ta King. Department of Computer Science National Tsing Hua University, Taiwan

Micro-Controller: PIC16C74 < Part 5: Interrupt >

Chapter 09. Programming in Assembly

Embedded Technosolutions

University of Texas at El Paso Electrical and Computer Engineering Department. EE 3176 Laboratory for Microprocessors I.

CPE 323 Introduction to Embedded Computer Systems: ADC12 and DAC12. Instructor: Dr Aleksandar Milenkovic Lecture Notes

MSP430xxxx Microcontrollers Low Power Modes

Introduction to the Texas Instruments ez430. By: Naren Anand

EE4390 Microprocessors

Embedded Systems and Software

ECE 372 Microcontroller Design Parallel IO Ports - Interrupts. ECE 372 Microcontroller Design Parallel IO Ports - Interrupts

e-pg Pathshala Subject : Computer Science Paper: Embedded System Module: Interrupt Handling Module No: CS/ES/13 Quadrant 1 e-text

C Language Programming through the ADC and the MSP430 (ESCAPE)

INTERRUPTS in microprocessor systems

ECE 492 WINTER 2015 GROUP 2. Texas Instruments MSP430-FR Bit ADC Setup Guide

ATmega Interrupts. Reading. The AVR Microcontroller and Embedded Systems using Assembly and C) by Muhammad Ali Mazidi, Sarmad Naimi, and Sepehr Naimi

Microcontrollers. Program organization Interrupt driven I/O. EECE 218 Microcontrollers 1

2.996/6.971 Biomedical Devices Design Laboratory Lecture 6: Microprocessors II

Getting Started with the Texas Instruments ez430

M68HC08 Microcontroller The MC68HC908GP32. General Description. MCU Block Diagram CPU08 1

ELEC 3040/3050 Lab 5. Matrix Keypad Interface Using Parallel I/O

CPE 323 Introduction to Embedded Computer Systems: MSP430 System Architecture An Overview

4) In response to the the 8259A sets the highest priority ISR, bit and reset the corresponding IRR bit. The 8259A also places

Embedded Software TI2726 B. 4. Interrupts. Koen Langendoen. Embedded Software Group

DEVICE DRIVERS AND INTERRUPTS SERVICE MECHANISM

Mark Redekopp, All rights reserved. EE 357 Unit 10b. Interrupts Timers

AGH University of Science and Technology Cracow Department of Electronics

BASICS OF THE RENESAS SYNERGY TM

Analog Peripherals. Introduction. Objectives

e-pg Pathshala Subject: Computer Science Paper: Embedded System Module: Interrupt Programming in Embedded C Module No: CS/ES/20 Quadrant 1 e-text

Concurrent programming: Introduction I

What happens when an HC12 gets in unmasked interrupt:

original M68K requests/priorities Interrupts to execute important code interrupts (n will always be I) I-bits bits in SR accomplish this

Interrupts & Interrupt Service Routines (ISRs)

AGH University of Science and Technology Cracow Department of Electronics

Chapters 2, 3: bits and pieces. Chapters 2 & 3. Chapters 2, 3: bits and pieces. Chapters 2, 3: bits and pieces. Using C. A last word about hardware

ELEC 3040/3050 Lab 5. Matrix Keypad Interface Using Parallel I/O

BASICS OF THE RENESAS SYNERGY PLATFORM

Hacettepe University

Digital Control of Electric Drives

EEL 4744C: Microprocessor Applications. Lecture 7. Part 2. M68HC12 Interrupt. Dr. Tao Li 1

5xx Active & Low Power Mode Operation

Transcription:

Interrupts, Low Power Modes

Registers Status Register

Interrupts (Chapter 6 in text) A computer has 2 basic ways to react to inputs: 1) polling: The processor regularly looks at the input and reacts as appropriate. + easy to implement and debug - processor intensive if event is rare, you waste a lot of time checking processor can t go into low power (slow or stopped) modes 2) interrupts: The processor is interrupted by an event. + very efficient time-wise: no time wasted looking for an event that hasn t occurred. + very efficient energy-wise: processor can be asleep most of the time. - can be hard to debug

Polling vs Interrupt This program sets P1.0 based on state of P1.4. #include <msp430x20x3.h> void main(void) { WDTCTL=WDTPW+WDTHOLD; // Stop watchdog P1DIR = 0x01; // P1.0 output P1OUT = 0x10; // P1.4 hi (pullup) P1REN = 0x10; // P1.4 pullup while (1) { // Test P1.4 if (0x10 & P1IN) P1OUT = 0x01; else P1OUT &= ~0x01; This program toggles P1.0 on each push of P1.4. #include <msp430x20x3.h> void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop watchdog P1DIR = 0x01; // P1.0 output P1OUT = 0x10; // P1.4 hi (pullup) P1REN = 0x10; // P1.4 pullup P1IE = 0x10; // P1.4 IRQ enabled P1IES = 0x10; // P1.4 Hi/lo edge P1IFG &= ~0x10; // P1.4 IFG cleared _BIS_SR(LPM4_bits + GIE); // Enter LPM4 // Port 1 interrupt service routine #pragma vector=port1_vector interrupt void Port_1(void) { P1OUT ^= 0x01; // P1.0 = toggle P1IFG &= ~0x10; // P1.4 IFG cleared The details are not important now, we will come back to the interrupt version later and go over it line-by-line, bit-by-bit.

What happens on interrupt? Interrupt Acceptance The interrupt latency is 6 cycles (CPU), from the acceptance of an interrupt request to the start of execution of the interrupt-service routine. The interrupt logic executes the following: 1. Any currently executing instruction is completed. 2. The PC, which points to the next instruction, is pushed onto the stack. 3. The SR is pushed onto the stack. 4. The interrupt with the highest priority is selected if multiple interrupts occurred during the last instruction and are pending for service. 5. The interrupt request flag resets automatically on single-source flags. Multiple source flags (e.g., I/O ports) remain set for servicing by software. 6. The SR is cleared. This terminates any low-power mode (next slide). Because the GIE bit is cleared, further interrupts are disabled. 7. The content of the interrupt vector is loaded into the PC: the program continues with the interrupt service routine at that address. 8. This is different from a typical function call because SR is saved. Return From Interrupt The interrupt handling routine terminates with instruction: RETI (return from ISR) The return from the interrupt takes 5 cycles (CPU) or 3 cycles (CPUx) to execute the following actions. 1. The SR with all previous settings pops from the stack. All previous settings of GIE, CPUOFF, etc. are now in effect, regardless of the settings used during the interrupt service routine. 2. The PC pops from the stack and begins execution at the point where it was interrupted.

Low power modes AA battery has capacity of about 2 Amp-hours. This is about 2 million hours (228 years) at 0.1 μa.

Getting into and out of LPM

Getting into and out of LPM Using C In main routine (enter LPM mode) bis_sr_register(cpuoff + GIE); //... // ADC10 interrupt service routine #pragma vector=adc10_vector interrupt void ADC10_ISR(void) { bic_sr_register_on_exit(cpuoff); // LPM0, ADC10_ISR will force exit // Clear CPUOFF bit from 0(SR) In ISR (exit LPM when returning to main program). _bis_sr_register(unsigned short mask); _bic_sr_register_on_exit(unsigned short mask); //BIS mask, SR //BIC mask, saved_sr

Registers that effect interrupts on P1 If a bit in PIES=0, the corresponding bit in P1IFG is set on rising edge on corresponding input pin (P1IN). If PIES=1, P1IFG is set on falling edge of P1IN. If interrupt enable bit is set in (P1IE), and Global Interrupts are enabled (GIE in Status Register), an interrupt is requested when the corresponding interrupt flag is set (P1IFG).

Using interrupts on Port 1 Toggles P1.0 on each push of P1.4. void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop watchdog P1DIR = 0x01; // P1.0 output P1OUT = 0x10; // P1.4 hi (pullup) P1REN = 0x10; // P1.4 pullup P1IE = 0x10; // P1.4 IRQ enabled P1IES = 0x10; // P1.4 Hi/lo edge P1IFG &= ~0x10; // P1.4 IFG cleared _BIS_SR(LPM4_bits + GIE); // Enter LPM4 // Port 1 interrupt service routine #pragma vector=port1_vector interrupt void Port_1(void) { P1OUT ^= 0x01; // P1.0 = toggle P1IFG &= ~0x10; // P1.4 IFG cleared P1.0 is output P1.4 resistor is enabled P1.4 resistor is connected to logic 1 Enable interrupt on P1.4 (GIE is still cleared) Set sensitivity to falling edge. Clear Interrupt flag (just in case). Enter LPM4 and enable interrupts Tell compiler to fill in interrupt vector with address of this function Tell compiler to return from function with iret (as opposed to ret ) Toggle P1.0 Clear interrupt flag. (Some interrupts do this automatically, check manual, or example code)

Keep ISR s short! It is important to keep interrupt service routines short. Since interrupts are disable globally during an ISR, you might miss something important. If you need to do a lot of processing, have the ISR set a flag, and have main routine act on it.