include <msp430g2553.h>
void main(void)
{WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
if (CALBC1_1MHZ ==0xFF || CALDCO_1MHZ == 0xFF)
{
while(1); // If calibration constants erased, trap CPU!!
}
BCSCTL1 = CALBC1_1MHZ; // Set range
DCOCTL = CALDCO_1MHZ; // Set DCO step + modulation
BCSCTL3 |= LFXT1S_2; // LFXT1 = VLO
IFG1 &= ~OFIFG; // Clear OSCFault flag
BCSCTL1 |= DIVA_3;//设置辅助时钟 其源是LFXT1,对其8分频 // ACLK = VLO/8
BCSCTL2 |= SELM_3 + DIVM_3 + DIVS_3; // MCLK = DCO/8, SMCLK = DCO/8
P1DIR|=BIT2;
P1SEL|=BIT2;
//以上(理论上要设置6个)2句是将P1.2用于输出PWM的设置
TACTL = TASSEL_2 + MC_1; // Source: 1/1*SMCLK, UP mode 增 允许中断
CCR0 = 3100;//Timer count 5100
CCR1 = 1000;
CCTL1 |= OUTMOD_3;
_BIS_SR(GIE);
for(;;);
} |