introduction to msp430 timer aece.uprm.edu/~mtoledo/web/4206/f2017/slides/timer.pdfintroduction to...
Post on 11-Apr-2020
31 Views
Preview:
TRANSCRIPT
INTRODUCTION TO MSP430 TIMER A
INEL 4206 Microprocessors
TIMER A• 16-bitgeneralpurposecounterandeventtimer
• softwareconfigurablewiththeTimer_AcontrolregisterTACTL
• twocapture/compareregistersTACCR0andTACCR1
• configurablePWMoutputs,andintervaltiming.
• interruptsthatmaybegeneratedon
• overflowconditionsand
• fromthecapture/compareregisters
• interruptsaredecodedusinganinterruptvectorregisterTAIV
© 2014 by M. Jiménez, R. Palomera, & I. Couvertier
INTRODUCTION TO EMBEDDED SYSTEMS: Using Microcontrollers and the MSP430 Chapter 5
• Captureandcompareregs.(CCR0,CCR1,CCR2)• CCControlregisters:CCTL0,CCTL1,CCTL2•TwoModes•ModeisselectedwithbitCAPontheCCTLx• Comparemode• StorevalueonCCR• Interruptgeneratedwhentimerreachesvalue
• CCRxcanresetto0aftervalueisreached• Capturemode• EdgeoninputsignallatchestheTimer’sTARintotheCCRregister
• CCTL’ssignalCCISselectsinputsignal•TAR=TimerAregister•TACTL=TimerAControlregister
© 2014 by M. Jiménez, R. Palomera, & I. Couvertier
INTRODUCTION TO EMBEDDED SYSTEMS: Using Microcontrollers and the MSP430 Chapter 7
© 2014 by M. Jiménez, R. Palomera, & I. Couvertier
INTRODUCTION TO EMBEDDED SYSTEMS: Using Microcontrollers and the MSP430 Chapter 7
● TAIFG = counter’s interrupt flag ● TAIE = timer interrupt enable ● TACLR = clear counter, clock divider and
count direction (up/down) ● TASSELx = select clock source ● IDx = frequency division factor ● MCx = operating mode: 00 = Halt, 01 = up,
10 = continuous, 11 = up/down
© 2014 by M. Jiménez, R. Palomera, & I. Couvertier
INTRODUCTION TO EMBEDDED SYSTEMS: Using Microcontrollers and the MSP430 Chapter 7
© 2014 by M. Jiménez, R. Palomera, & I. Couvertier
INTRODUCTION TO EMBEDDED SYSTEMS: Using Microcontrollers and the MSP430 Chapter 7
● Capture mode: When capture occurs, ● TAR count is copied on TACCRx register ● TACCRx CCIFG interrupt flag is set ● can be used to measure time, etc. ● Capture is done using external or internal signals
connected to the capture inputs and selected with the CCISx bits
● Compare mode: used to ● generate PWM signals or interrupts at specific time
intervals ● TACCRx CCIFG = 1 when counter TAR counts to the
value stored in register TACCRx ● internal signal EQUx is set, and triggers an output
according to a selected output mode
© 2014 by M. Jiménez, R. Palomera, & I. Couvertier
INTRODUCTION TO EMBEDDED SYSTEMS: Using Microcontrollers and the MSP430 Chapter 7
● Capture mode: CAP = 1 ● CMx = capture input signal edge ● COV = capture overflow, ● SCS = synchronize capture source
© 2014 by M. Jiménez, R. Palomera, & I. Couvertier
INTRODUCTION TO EMBEDDED SYSTEMS: Using Microcontrollers and the MSP430 Chapter 7
● write a nonzero value to TACCR0 to start ● write a 0 to TACCR0 to stop ● value on TACCR0 sets the upper count
limit ● TACCR0 CCIFG is set on the (TACCR0 - 1)
to TACCR0 transition ● UP mode: TAIFG is set by the TACCR0-to-
zero transition ● Up/down mode: TAIFG is set when count
goes from 0001h to 0000h
Up and UP/Down
© 2014 by M. Jiménez, R. Palomera, & I. Couvertier
INTRODUCTION TO EMBEDDED SYSTEMS: Using Microcontrollers and the MSP430 Chapter 7
© 2014 by M. Jiménez, R. Palomera, & I. Couvertier
INTRODUCTION TO EMBEDDED SYSTEMS: Using Microcontrollers and the MSP430 Chapter 7
● Continuous mode ● counter always counts up to 0FFFFh ● sets the TAIFG interrupt flag in the 0FFFFh
to 0h transition ● useful for generating independent time
intervals controlled by hardware ● the output/compare registers can be used
independently to generate different time intervals or output frequencies.
© 2014 by M. Jiménez, R. Palomera, & I. Couvertier
INTRODUCTION TO EMBEDDED SYSTEMS: Using Microcontrollers and the MSP430 Chapter 7
© 2014 by M. Jiménez, R. Palomera, & I. Couvertier
INTRODUCTION TO EMBEDDED SYSTEMS: Using Microcontrollers and the MSP430 Chapter 7
Outputwaveform,usingP1.2withSMCLK/8=1MHz/8,CCR0=30000andCCR1=15000,set/resetmode
© 2014 by M. Jiménez, R. Palomera, & I. Couvertier
INTRODUCTION TO EMBEDDED SYSTEMS: Using Microcontrollers and the MSP430 Chapter 7
P1.0isconnectedtoREDLED,butcan’tbeusedastheTimerAoutput.ToblinktheLEDusingthetimerAoutputmode,• useanotheroutputpinsuchasP1.2,• removejumperaboveLED,and• connectP1.2topinaboveLED.
SeeavideooftheblinkingLED!
© 2014 by M. Jiménez, R. Palomera, & I. Couvertier
INTRODUCTION TO EMBEDDED SYSTEMS: Using Microcontrollers and the MSP430 Chapter 7
See examples on textbook section 7.4,http://www.simplyembedded.org/tutorials/timers/
Timers in Depthhttp://www.ti.com/lit/ml/slap113/slap113.pdf
top related