Escolar Documentos
Profissional Documentos
Cultura Documentos
Keith Quiring
MSP430 Applications Engineer
Texas Instruments
© 2006 Texas Instruments Inc, Slide 1
Agenda
• Introduction
• Basic Timer
• RTC
• Watchdog Timer (WDT/WDT+)
• Timer_A
• Timer_B
• Summary and Applications
#pragma
#pragma vector=BASICTIMER_VECTOR
vector=BASICTIMER_VECTOR
__interrupt
__interrupt void
void BT_ISR(void)
BT_ISR(void)
{{
incrementSeconds();
incrementSeconds();
if(sec==60)
if(sec==60) {sec
{sec == 0;
0; incrementMinutes();}
incrementMinutes();}
if(min==60)
if(min==60) {min
{min == 0;
0; incrementHours();}
incrementHours();}
if(hours>12)
if(hours>12) hours=1;
hours=1;
}}
© 2006 Texas Instruments Inc, Slide 6
Basic Timer: LCD Drive Example
Set Basic Timer void
void main(void)
main(void)
{{
for LCD refresh
int
int i;
i;
WDTCTL
WDTCTL == WDTPW
WDTPW ++ WDTHOLD;
WDTHOLD;
FLL_CTL0
FLL_CTL0 |=|= XCAP14PF;
XCAP14PF;
LCDCTL
LCDCTL == LCDP2
LCDP2 ++ LCD4MUX
LCD4MUX ++ LCDON;
LCDON;
BTCTL
BTCTL == BTFRFQ1;
BTFRFQ1; //// LCD
LCD freq=ACLK/128
freq=ACLK/128
P5SEL
P5SEL == 0xFC;
0xFC; //
// Set
Set LCD
LCD pins
pins
for
for (;;)
(;;)
for
for (i=0;
(i=0; i<7;
i<7; ++i)
++i) //
// Display
Display ##
LCDMEM[i]
LCDMEM[i] == digit[i];
digit[i];
}}
count++;
count++;
}}
© 2006 Texas Instruments Inc, Slide 8
Agenda
• Introduction
• Basic Timer
• RTC
• Watchdog Timer (WDT/WDT+)
• Timer_A
• Timer_B
• Summary and Applications
• Applications:
PWM generation
RTC
Thermostat
Timer_A UART
Up to value in
CCR0, count
Up/ down to 0000,
back up to
Down value in CCR0,
etc.
Up to value
specified by CCR0,
Continuous rolls over to 0000,
back up to CCR0
value, etc.
CCRX_ISR
CCRX_ISR add
add &TAIV,PC
&TAIV,PC ;; Offset
Offset to
to Jump
Jump table
table
reti
reti ;; No
No source
source
jmp
jmp CCR1_ISR
CCR1_ISR ;;
jmp
jmp CCR2_ISR
CCR2_ISR ;;
reti
reti ;; No
No source
source
reti
reti ;; No
No source
source
TIMOVH
TIMOVH xor.b
xor.b #08h,&P1OUT
#08h,&P1OUT
reti
reti
CCR1_ISR
CCR1_ISR xor.b
xor.b #02h,&P1OUT
#02h,&P1OUT
reti
reti
CCR2_ISR
CCR2_ISR xor.b
xor.b #04h,&P1OUT
#04h,&P1OUT
reti
reti
__BIS_SR(LPM0_bits);
__BIS_SR(LPM0_bits);
}}
Products Applications
Amplifiers amplifier.ti.com Audio www.ti.com/audio
Data Converters dataconverter.ti.com Automotive www.ti.com/automotive
DSP dsp.ti.com Broadband www.ti.com/broadband
Interface interface.ti.com Digital Control www.ti.com/digitalcontrol
Logic logic.ti.com Military www.ti.com/military
Power Mgmt power.ti.com Optical Networking www.ti.com/opticalnetwork
Microcontrollers microcontroller.ti.com Security www.ti.com/security
RFID www.ti-rfid.com Telephony www.ti.com/telephony
Low Power www.ti.com/lpw Video & Imaging www.ti.com/video
Wireless
Wireless www.ti.com/wireless
Mailing Address: Texas Instruments, Post Office Box 655303, Dallas, Texas 75265
Copyright © 2007, Texas Instruments Incorporated