|
下面这段程序想实现:周期为1分钟,一分钟内出现一秒的高电平,也就是在输出加个发光二极管,一分钟闪一下,怎么都搞不定,真诚的希望各位高手帮忙。
#include <msp430x12x2.h>
;------------------------------------------------------------------------------
ORG 0E000h ; Program Start
;------------------------------------------------------------------------------
RESET mov.w #300h,SP ; Initialize stackpointer
StopWDT mov.w #WDTPW+WDTHOLD,&WDTCTL ; Stop WDT
SetupP1 bis.b #004h,&P1DIR ; P1.2 and P1.3 outputs
bis.b #004h,&P1SEL ; P1.2 and P1.3 TA1/2 option
bis.b #DIVA1+DIVA0,&BCSCTL1 ;设定8分频
mov.w #TASSEL0+ID1+ID0,&TACTL ;使用ACLK作定时器时钟并且8分频源
SetupC0 mov.w #0EA60h,&CCR0 ; PWM Period
SetupC1 mov.w #OUTMOD_7,&CCTL1 ; CCR1 reset/set
mov.w #0400h,&CCR1 ; CCR1 PWM Duty Cycle
SetupC2 mov.w #OUTMOD_7,&CCTL2 ; CCR2 reset/set
mov.w #128,&CCR2 ; CCR2 PWM duty cycle
SetupTA mov.w #TASSEL_1+MC_1,&TACTL ; ACLK, upmode
;
Mainloop bis.w #LPM3,SR ; Remain in LPM3
nop ; Required only for debugger
;
;------------------------------------------------------------------------------
; Interrupt Vectors
;------------------------------------------------------------------------------
ORG 0FFFEh ; MSP430 RESET Vector
DW 0E00h ;
END
|
|