MSP430 Clock System and Timer

Slides:



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

UBI >> Contents Chapter 7 Timers Laboratories MSP430 Teaching Materials Texas Instruments Incorporated University of Beira Interior (PT) Pedro Dinis Gaspar,
Outline MSP430 LaunchPad MSP430 Microcontroller
Interrupts, Low Power Modes and Timer A (Chapters 6 & 8)
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.
LAB 6: Serial Communication
Notes on the ez430-RF2500. Sources
CS4101 嵌入式系統概論 Timers and Clocks 金仲達教授 國立清華大學資訊工程學系 Materials from MSP430 Microcontroller Basics, John H. Davies, Newnes, 2008.
CS4101 嵌入式系統概論 Software UART Revisited Prof. Chung-Ta King Department of Computer Science National Tsing Hua University, Taiwan ( Materials from MSP430.
Chung-Ta King National Tsing Hua University
Timers. Range of timers Watchdog timer: Included in all devices (watchdog timer+). Its main function is to protect the system against malfunctions but.
LAB 7: WDT+ and Low-Power Optimization
T IMERS - 2. O UTPUT U NIT Each capture/compare block contains an output unit. The output unit is used to generate output signals such as PWM signals.
Lecture 18: ADC Implementation Lecturers: Professor John Devlin.
1 MSP430F2013: 2KB + 256B Flash Memory 128B RAM. 2 MSP430 MSP ( mixed signal processor) The CPU is small and efficient, with a large number of registers.
CPE 323 Introduction to Embedded Computer Systems: The MSP430 System Architecture Instructor: Dr Aleksandar Milenkovic Lecture Notes.
MSP430 Mixed Signal Microcontroller – Parte 2 Afonso Ferreira Miguel Source: slau056d – Texas instruments.
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
TI MSP430 MICROCONTROLLERS BY ADITYA PATHAK. THE MSP FAMILY Ultra-low power; mixed signal processors Widely used in battery operated applications Uses.
1 Wireless Body Area Network. 2 MSP430F2013: 2KB + 256B Flash Memory 128B RAM.
Network and Systems Laboratory nslab.ee.ntu.edu.tw.
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 )
1 MSP430F2013: 2KB + 256B Flash Memory 128B RAM. 2 MSP430F2013.
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.
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.
Recall the Container Thermometer
Recall the Container Thermometer
Lecture 10: TI MSP430 Timers and Capture Modes
Introduction Why low power?
Introduction Why low power?
Recall the Container Thermometer
ECE 3430 – Intro to Microcomputer Systems
Lecture 8: TI MSP430 Interrupts, ISRs
CS4101 嵌入式系統概論 Serial Communication
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
CS4101 嵌入式系統概論 Interrupts Prof. Chung-Ta King
Chapter 6 General Purpose Input/Output
CS4101 Introduction to Embedded Systems Lab 1: General Purpose IO
MSP430 Teaching Materials
Prof. Chung-Ta King Department of Computer Science
ECE 3430 – Intro to Microcomputer Systems
Instructor: Dr Aleksandar Milenkovic Lecture Notes
MSP432 ARM Timer Programming
National Tsing Hua University CS4101 Introduction to Embedded Systems Lab 2: Timer and Clock Prof. Chung-Ta King Department of Computer Science National.
National Tsing Hua University CS4101 Introduction to Embedded Systems Lab 3: Interrupt Prof. Chung-Ta King Department of Computer Science National Tsing.
ECE 3430 – Intro to Microcomputer Systems
ECE 3430 – Intro to Microcomputer Systems
Subject Name: Microcontroller Subject Code: 10ES42
CS4101 Introduction to Embedded Systems Lab 7: Serial Communication
CS4101 Introduction to Embedded Systems Lab 4: Interrupt
I/O PORTS : MSP430x5xx devices have up to 12 digital I/O ports :
ECE 3430 – Intro to Microcomputer Systems
CS4101 Introduction to Embedded Systems Lab 7: Serial Communication
Lecture 9: TI MSP430 Interrupts & Low Power Modes
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
ECE 3567 Microcontrollers Lab
ECE 3567 Microcontroller Lab
Presentation transcript:

MSP430 Clock System and Timer College of Computer and Information Science, Northeastern University References: Texas Instruments, “MSP430x1xx Family User’s Guide” Texas Instruments, “MSP430x15x, MSP430x16x, MSP430x161x MIXED SIGNAL MICROCONTROLLER”,

Outline MSP430 basic clock module MSP430 Timer A Timer A examples

MSP430 Basic Clock Module Clock Sources: Tmote Sky Configuration: LFXT1CLK : Low-frequency/high-frequency oscillator XT2CLK : Optional high-frequency oscillator DCOCLK : Internal digitally controlled oscillator (DCO) Tmote Sky Configuration: LFXT1CLK : 32.768KHz crystal XT2CLK : N/A DCOCLK : Built-in DCO with configurable range from <100KHz to 4MHz

MSP430 Basic Clock Module Clock Signals: ACLK: Auxiliary clock. The signal is sourced from LFXT1CLK with a divider of 1, 2, 4, or 8. (The calibration program for the serial link sets the divider to 4, but after the calibration it can be changed to any other values.) ACLK can be used as the clock signal for Timer A and Timer B. MCLK: Master clock. The signal can be sourced from LFXT1CLK, XT2CLK (if available), or DCOCLK with a divider of 1, 2, 4, or 8. MCLK is used by the CPU and system. SMCLK: Sub-main clock. The signal is sourced from either XT2CLK (if available), or DCOCLK with a divider of 1, 2, 4, or 8. SMCLK can be used as the clock signal for Timer A and Timer B.

Clock System Registers

MSP430 Timer_A A 16-bit counter 4 modes of operation – Stop, Up, Continuous, Up/Down 3 capture/compare registers (CCRx) 2 interrupt vectors – TACCR0 and TAIV

Modes of Operation: Up Mode

Modes of Operation: Continuous Mode

Modes of Operation: Up/Down Mode

Timer_A Interrupt Vectors TACCR0 interrupt vector for CCIFG of CCR0 TAIV interrupt vector for TAIFG and CCIFGs of CCR1,CCR2

Timer_A Registers TACTL, Timer_A Control Register (PART 1)

TACTL, Timer_A Control Register (PART 2)

TACCTLx, Capture/Compare Control Register

TAIV, Timer_A Interrupt Vector Register

Example 1 Continuous Mode Output pin P5.4 (Red LED) with toggle rate = 32768/(32768) = 1 Hz #include "include/include.h" #include "include/hardware.h" int main ( void ) { WDTCTL = WDTPW + WDTHOLD; // Stop WDT P5DIR |= 0x10; // P5.4 output CCTL0 = CCIE; // CCR0 interrupt enabled CCR0 = 32768; TACTL = TASSEL_1 + MC_2; // ACLK, continuous mode eint(); // Enable the global interrupt LPM0; // Enter low power mode } // Timer_A TACCR0 interrupt vector handler interrupt (TIMERA0_VECTOR) TimerA_procedure( void ){ P5OUT ^= 0x10; // Toggle P5.4 CCR0 += 32768; // Add offset to CCR0 OR _BIS_SR(LPM0_bits + GIE);

Example 2 Up Mode Output pin P5.4 (Red LED) with toggle rate = 32768/(32768) = 1 Hz #include "include/include.h" #include "include/hardware.h" int main ( void ) { WDTCTL = WDTPW + WDTHOLD; // Stop WDT P5DIR |= 0x10; // P5.4 output CCTL0 = CCIE; // CCR0 interrupt enabled CCR0 = 32767; TACTL = TASSEL_1 + MC_1; // ACLK, upmode _BIS_SR(LPM0_bits + GIE); // Enable the global interrupt and enter LPM0 } // Timer_A TACCR0 interrupt vector handler interrupt (TIMERA0_VECTOR) TimerA_procedure ( void ){ P5OUT ^= 0x10; // Toggle P5.4

Example 3 Continuous Mode Output pin P5.4 with toggle rate = 32768/(16384) = 0.5 Hz Output pin P5.5 with toggle rate = 32768/(32768) = 1 Hz Output pin P5.6 with toggle rate = 32768/(65536) = 0.5 Hz #include "include/include.h" #include "include/hardware.h" int main ( void ) { WDTCTL = WDTPW + WDTHOLD; // Stop WDT P5DIR |= 0x70; // P5.4, P5.5, P5.6 in output mode CCTL0 = CCIE; // CCR0 interrupt enabled CCTL1 = CCIE; // CCR1 interrupt enabled CCTL2 = CCIE; // CCR2 interrupt enabled CCR0 = 0; CCR1 = 0; CCR2 = 0; TACTL = TASSEL_1 + MC_2+ TAIE; // ACLK, contmode, TAIE enabled _BIS_SR(LPM0_bits + GIE); // Enable the global interrupt and enter LPM0 }

Example 3, continued // Timer_A TACCR0 interrupt vector handler interrupt (TIMERA0_VECTOR) TimerA0_procedure ( void ){ P5OUT ^= 0x10; //on TACCR0 Toggle P5.4 (Red LED) CCR0 += 16384; // Add offset to CCR0 } // Timer_A TAIV interrupt vector handler interrupt (TIMERA1_VECTOR) TimerA1_procedure ( void ){ switch( TAIV ) { case 2: P5OUT ^= 0x20; // on TACCR1 CCIFG Toggle P5.5 (Green LED) CCR1 += 32768; // Add offset to CCR1 break; case 10: P5OUT ^= 0x40; // on Timer overflow TAIFG Toggle P5.6 (Blue LED)