Lecture 8: TI MSP430 Interrupts, ISRs

Slides:



Advertisements
Similar presentations
Why Keliang’s code maybe did (or maybe didn’t) work … or High (impedance) Anxiety.
Advertisements

Interrupts, Low Power Modes and Timer A (Chapters 6 & 8)
Chung-Ta King National Tsing Hua University
Chung-Ta King National Tsing Hua University
Chung-Ta King National Tsing Hua University
ECE 447 Fall 2009 Lecture 9: TI MSP430 Interrupts & Low Power Modes.
68HC11 Polling and Interrupts
CSC Timers Since this is a microcontroller it mainly finds itself in embedded devices Quite often embedded devices need to synchronize events The.
The 8051 Microcontroller and Embedded Systems
CS4101 嵌入式系統概論 Software UART Revisited Prof. Chung-Ta King Department of Computer Science National Tsing Hua University, Taiwan ( Materials from MSP430.
INTERRUPTS PROGRAMMING
Chung-Ta King National Tsing Hua University
LAB 7: WDT+ and Low-Power Optimization
A Simple Tour of the MSP430. Light LEDs in C LEDs can be connected in two standard ways. Active high circuit, the LED illuminates if the pin is driven.
MSP430 Mixed Signal Microcontroller – Parte 2 Afonso Ferreira Miguel Source: slau056d – Texas instruments.
Revised: Aug 1, ECE 263 Embedded System Design Lessons 23, 24 - Exceptions - Resets and Interrupts.
CPE 323 Introduction to Embedded Computer Systems: Watchdog Timer, Timer A Instructor: Dr Aleksandar Milenkovic Lecture Notes.
CS4101 嵌入式系統概論 Analog-to-Digital Converter 金仲達教授 國立清華大學資訊工程學系 ( Materials from MSP430 Microcontroller Basics, John H. Davies, Newnes, 2008 )
ECE 447 Fall 2009 Lecture 10: TI MSP430 Timers and Capture Modes.
Lecture 11: TI MSP430 Timers Compare Modes
LAB 8: Program Design Pattern and Software Architecture
6-1 Infineon 167 Interrupts The C167CS provides 56 separate interrupt sources that may be assigned to 16 priority levels. The C167CS uses a vectored interrupt.
ECE 448 – FPGA and ASIC Design with VHDL Lecture 19 PicoBlaze Interrupt Interface & Assembly Code Development.
ECE 447 Fall 2009 Lecture 7: MSP430 Polling and Interrupts.
Week 7 Low-Power Modes MSP430 Teaching Materials Hacettepe University Copyright 2009 Texas Instruments All Rights Reserved.
CS4101 嵌入式系統概論 Interrupt 金仲達教授 國立清華大學資訊工程學系 ( Materials from MSP430 Microcontroller Basics, John H. Davies, Newnes, 2008 )
EE/CS-352: Embedded Microcontroller Systems Part V The 8051 Assembly Language Interrupts.
Lecture 3 CSE 341 – Microprocessors Lecture 3 Md. Omar Faruqe UB 1228
67015 ACLK (32.768kHz) Timer count (ex. TA0R) Interrupt Note: Timer Settings : Upmode / CCR0=7 / CCR1 =7/ CCR2=1 Interrupts Enabled: CCR1/CCR2/overflow.
UNIT 2. CPUXV2 20-bit addressing User-definable Boot Strap Loader RAM starts at 0x1C00 Beginning of MAIN flash moves according to RAM Vector table starts.
An Introduction to Embedded Systems, and the PIC Microcontroller Lecture 8: Interrupts The aims of this session are to explore the structure and application.
ECE 382 Lesson 32 Lesson Outline Lab 6 Introduction Pulse Width Modulation Capture / Compare Example Lab 6 Tips Admin Lab#6 “prelab” due BOC lesson 33.
Lecture 10: TI MSP430 Timers and Capture Modes
Introduction Why low power?
Introduction Why low power?
CS4101 嵌入式系統概論 General Purpose IO
ECE 3430 – Intro to Microcomputer Systems
Microprocessor and Assembly Language
CS4101 嵌入式系統概論 Interrupts Prof. Chung-Ta King
Lesson Outline Interrupts Admin Assignment #9 due next lesson
PWM and DC Motor Control
CS4101 Introduction to Embedded Systems Lab 6: Low-Power Optimization
68HC11 Interrupts & Resets.
Microprocessor Systems Design I
CS4101 嵌入式系統概論 Interrupts Prof. Chung-Ta King
Timer and Interrupts.
Chapter 6 General Purpose Input/Output
Computer Architecture
Prof. Chung-Ta King Department of Computer Science
ECE 3430 – Intro to Microcomputer Systems
CS4101 嵌入式系統概論 General Purpose IO
MSP432 ARM Timer Programming
Interrupt Source: under
ECE 3430 – Intro to Microcomputer Systems
8259 Chip The Intel 8259 is a family of Programmable Interrupt Controllers (PIC) designed and developed for use with the Intel 8085 and Intel 8086 microprocessors.
ECE 3430 – Intro to Microcomputer Systems
CS4101 Introduction to Embedded Systems Lab 4: Interrupt
* * * * * * * 8051 Interrupts Programming.
ECE 3430 – Intro to Microcomputer Systems
Lecture 18 Interrupt 동국대학교 홍유표.
ECE 3430 – Intro to Microcomputer Systems
Interrupt Source: under
8259 Programmable Interrupt Controller
Lecture 9: TI MSP430 Interrupts & Low Power Modes
Interrupt Source: under
ECE 3430 – Intro to Microcomputer Systems
CS4101 Introduction to Embedded Systems Lab 2: Basic IO and Timer
Prof. Chung-Ta King Department of Computer Science
MSP430 Clock System and Timer
ECE 3567 Microcontrollers Lab
Presentation transcript:

Lecture 8: TI MSP430 Interrupts, ISRs ECE 447 Fall 2009 Lecture 8: TI MSP430 Interrupts, ISRs

ECE447: Interrupt Service Routines in Assembly PORT1_ISR: ; respond to inputs on port1 reti ; return from interrupt ORG 0FFE8 DW PORT1_ISR -- or -- COMMON INTVEC ORG PORT1_VECTOR The service routine itself is quite simple. (Note the “reti” instruction.) To store the address of this ISR in the proper vector table location an ORG directive is used. PORT1_VECTOR is defined in the header file relative to the INTVEC segment. The COMMON directive must be used to place the defined address (PORT1_ISR) in the correct location. This is useful for defining ISRs in multiple files.

ECE447: Interrupt Service Routines in C // tell the compiler the vector for this ISR #pragma vector = PORT1_VECTOR __interrupt void port1_isr(void) { // respond to inputs on port1 } “#pragma vector” tells the compiler to store the address of this routine in the PORT1_VECTOR location. “__interrupt” is used to tell the compiler that this function should end with a “reti” instruction.

ECE447: Interrupt Vector Jump Table The jump table tells the program where to go when an interrupt occurs. A vector points to the address where the interrupt service routine starts. The MSP430 jump table is stored in RAM from 0xFFC0 to 0xFFFF and can be modified by the programmer.

ECE447: MSP430 Interrupts

ECE447: MSP430 Status Register GIE (bit 3): Global Interrupt Enable 1: Enables all interrupts (interrupts must also be enabled individually) 0: Disable all interrupts NOTE: SR is saved on the stack and cleared when an ISR is executed.

ECE447: Setting and Clearing the General Interrupt Mask Assembly EINT – Enable interrupts (set GIE) DINT – Disable interrupts (clear GIE) C asm(“ EINT”); asm(“ DINT”); C (#include intrinsics.h) __enable_interrupt(); __disable_interrupt();

ECE447: MSP430 Interrupt execution flow RAM JUMP TABLE 0xFFFF PC SR EE 10EE 00F8 10 0000 0xFFC0 STACK F8 00 SP RAM SERVICE ROUTINE 0x10EE

Interrupts Example: Toggling LEDs // Listing 6.5: Toggles LEDs in ISR using interrupts from timer A CCR0 // in Up mode with a period of about 0.5s #define LED1 BIT3 #define LED2 BIT4 void main (void) { WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer P2OUT = ~LED1; // Preload LED1 on, LED2 off P2DIR = LED1 | LED2; // Set pins with LED1,2 to output TACCR0 = 49999; // Upper limit of count for TAR TACCTL0 = CCIE; // Enable interrupts on Compare 0 TACTL = MC_1 | ID_3 | TASSEL_2 | TACLR; // Set up and start Timer A // “Up to CCR0” mode, divide clock 8, clock SMCLK, clear timer __enable_interrupt ( ); // Enable interrupts (intrinsic) for (;;) { // Loop forever doing nothing } // Interrupts do the work } // Interrupt Service Routine for Timer A channel 0 #pragma vector = TIMERA0_VECTOR // Assoc. the funct. w/ an interrupt vector __interrupt void TA0_ISR (void) // name of the interrupt function (can be anything) P2OUT ^= LED1 | LED2; // Toggle LEDs

ECE447: MSP430 Interrupt Class Exercise Write a program that collects samples from input Port 2. A signal line that indicates a new data value is available is connected to pin P1.0. Use an interrupt to detect a rising edge on the P1.0. When an interrupt is triggered the value on Port2 should be stored into a byte array of 32 entries. When 32 samples have been collected, P1.7 should be driven as an output high to indicate the memory is “full”