15
INTRODUCTION TO MSP430 TIMER A INEL 4206 Microprocessors

INTRODUCTION TO MSP430 TIMER Aece.uprm.edu/~mtoledo/web/4206/F2017/Slides/timer.pdfINTRODUCTION TO EMBEDDED SYSTEMS: Using Microcontrollers and the MSP430 Chapter 7 TAIFG = counter’s

  • Upload
    others

  • View
    34

  • Download
    0

Embed Size (px)

Citation preview

Page 1: INTRODUCTION TO MSP430 TIMER Aece.uprm.edu/~mtoledo/web/4206/F2017/Slides/timer.pdfINTRODUCTION TO EMBEDDED SYSTEMS: Using Microcontrollers and the MSP430 Chapter 7 TAIFG = counter’s

INTRODUCTION TO MSP430 TIMER A

INEL 4206 Microprocessors

Page 2: INTRODUCTION TO MSP430 TIMER Aece.uprm.edu/~mtoledo/web/4206/F2017/Slides/timer.pdfINTRODUCTION TO EMBEDDED SYSTEMS: Using Microcontrollers and the MSP430 Chapter 7 TAIFG = counter’s

TIMER A• 16-bitgeneralpurposecounterandeventtimer

• softwareconfigurablewiththeTimer_AcontrolregisterTACTL

• twocapture/compareregistersTACCR0andTACCR1

• configurablePWMoutputs,andintervaltiming.

• interruptsthatmaybegeneratedon

• overflowconditionsand

• fromthecapture/compareregisters

• interruptsaredecodedusinganinterruptvectorregisterTAIV

Page 3: INTRODUCTION TO MSP430 TIMER Aece.uprm.edu/~mtoledo/web/4206/F2017/Slides/timer.pdfINTRODUCTION TO EMBEDDED SYSTEMS: Using Microcontrollers and the MSP430 Chapter 7 TAIFG = counter’s

© 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

Page 4: INTRODUCTION TO MSP430 TIMER Aece.uprm.edu/~mtoledo/web/4206/F2017/Slides/timer.pdfINTRODUCTION TO EMBEDDED SYSTEMS: Using Microcontrollers and the MSP430 Chapter 7 TAIFG = counter’s

© 2014 by M. Jiménez, R. Palomera, & I. Couvertier

INTRODUCTION TO EMBEDDED SYSTEMS: Using Microcontrollers and the MSP430 Chapter 7

Page 5: INTRODUCTION TO MSP430 TIMER Aece.uprm.edu/~mtoledo/web/4206/F2017/Slides/timer.pdfINTRODUCTION TO EMBEDDED SYSTEMS: Using Microcontrollers and the MSP430 Chapter 7 TAIFG = counter’s

© 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

Page 6: INTRODUCTION TO MSP430 TIMER Aece.uprm.edu/~mtoledo/web/4206/F2017/Slides/timer.pdfINTRODUCTION TO EMBEDDED SYSTEMS: Using Microcontrollers and the MSP430 Chapter 7 TAIFG = counter’s

© 2014 by M. Jiménez, R. Palomera, & I. Couvertier

INTRODUCTION TO EMBEDDED SYSTEMS: Using Microcontrollers and the MSP430 Chapter 7

Page 7: INTRODUCTION TO MSP430 TIMER Aece.uprm.edu/~mtoledo/web/4206/F2017/Slides/timer.pdfINTRODUCTION TO EMBEDDED SYSTEMS: Using Microcontrollers and the MSP430 Chapter 7 TAIFG = counter’s

© 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

Page 8: INTRODUCTION TO MSP430 TIMER Aece.uprm.edu/~mtoledo/web/4206/F2017/Slides/timer.pdfINTRODUCTION TO EMBEDDED SYSTEMS: Using Microcontrollers and the MSP430 Chapter 7 TAIFG = counter’s

© 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

Page 9: INTRODUCTION TO MSP430 TIMER Aece.uprm.edu/~mtoledo/web/4206/F2017/Slides/timer.pdfINTRODUCTION TO EMBEDDED SYSTEMS: Using Microcontrollers and the MSP430 Chapter 7 TAIFG = counter’s

© 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

Page 10: INTRODUCTION TO MSP430 TIMER Aece.uprm.edu/~mtoledo/web/4206/F2017/Slides/timer.pdfINTRODUCTION TO EMBEDDED SYSTEMS: Using Microcontrollers and the MSP430 Chapter 7 TAIFG = counter’s

© 2014 by M. Jiménez, R. Palomera, & I. Couvertier

INTRODUCTION TO EMBEDDED SYSTEMS: Using Microcontrollers and the MSP430 Chapter 7

Page 11: INTRODUCTION TO MSP430 TIMER Aece.uprm.edu/~mtoledo/web/4206/F2017/Slides/timer.pdfINTRODUCTION TO EMBEDDED SYSTEMS: Using Microcontrollers and the MSP430 Chapter 7 TAIFG = counter’s

© 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.

Page 12: INTRODUCTION TO MSP430 TIMER Aece.uprm.edu/~mtoledo/web/4206/F2017/Slides/timer.pdfINTRODUCTION TO EMBEDDED SYSTEMS: Using Microcontrollers and the MSP430 Chapter 7 TAIFG = counter’s

© 2014 by M. Jiménez, R. Palomera, & I. Couvertier

INTRODUCTION TO EMBEDDED SYSTEMS: Using Microcontrollers and the MSP430 Chapter 7

Page 13: INTRODUCTION TO MSP430 TIMER Aece.uprm.edu/~mtoledo/web/4206/F2017/Slides/timer.pdfINTRODUCTION TO EMBEDDED SYSTEMS: Using Microcontrollers and the MSP430 Chapter 7 TAIFG = counter’s

© 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

Page 14: INTRODUCTION TO MSP430 TIMER Aece.uprm.edu/~mtoledo/web/4206/F2017/Slides/timer.pdfINTRODUCTION TO EMBEDDED SYSTEMS: Using Microcontrollers and the MSP430 Chapter 7 TAIFG = counter’s

© 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!

Page 15: INTRODUCTION TO MSP430 TIMER Aece.uprm.edu/~mtoledo/web/4206/F2017/Slides/timer.pdfINTRODUCTION TO EMBEDDED SYSTEMS: Using Microcontrollers and the MSP430 Chapter 7 TAIFG = counter’s

© 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