EasyManuals Logo

Texas Instruments MSP430 User Manual

Texas Instruments MSP430
413 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #128 background imageLoading...
Page #128 background image
128
Explanation
For this demo, I used a MSP430G2553 micro as it has two independent timers. One of these timers is
used as a waveform generator and the other as a waveform capture unit.
Timer0_A3 is set up as a PWM output generator with only CC channel 0 active. CC channel 0 is set just
to toggle its output logic states and not duty cycle. SMCLK is divided by two and feed to this timer, i.e.
this timer has a tick frequency of 500 kHz. As stated before, in order to change the PWM frequency,
we need to change the value of TA0CCR0 in up mode counting. We will employ this fact to alter
waveform frequency in the main loop.
/*
* TA0CCTL0, Capture/Compare Control Register 0
*
* CM_0 -- No Capture
* CCIS_0 -- CCIxA
* ~SCS -- Asynchronous Capture
* ~SCCI -- Latched capture signal (read)
* ~CAP -- Compare mode
* OUTMOD_4 -- PWM output mode: 4 - Toggle
*
* Note: ~<BIT> indicates that <BIT> has value zero
*/
TA0CCTL0 = CM_0 | CCIS_0 | OUTMOD_4;
/* TA0CCR0, Timer_A Capture/Compare Register 0 */
TA0CCR0 = 9999;
/*
* TA0CTL, Timer_A3 Control Register
*
* TASSEL_2 -- SMCLK
* ID_1 -- Divider - /2
* MC_1 -- Up Mode
*/
TA0CTL = TASSEL_2 | ID_1 | MC_1;
The other timer - Timer1_A3 is setup to capture the waveform generated by Timer0_A3. Timer
interrupt is used to quickly respond to incoming waveform’s rising edges. We will be measuring the
time period of Timer0_A3’s waveform and so we are interest in measuring the time difference
between like edges here rising edges. To get high accuracy, SMCLK is not divided. This gives us a
minimum capture period of 1 microsecond and a maximum of about 65 milliseconds provided that we
are using continuous mode counting. In other words, Timer1_A3 has double scanning rate than what
Timer0_A3 can throw at it a concept similar to Nyquist theorem.

Table of Contents

Other manuals for Texas Instruments MSP430

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Texas Instruments MSP430 and is the answer not in the manual?

Texas Instruments MSP430 Specifications

General IconGeneral
BrandTexas Instruments
ModelMSP430
CategoryMicrocontrollers
LanguageEnglish

Related product manuals