#include "msp430x14x.h"
void main (void)
{
WDTCTL = WDTPW + WDTHOLD;
//unsigned char i;
/*------选择系统主时钟为8MHz-------*/
/*BCSCTL1 &= ~XT2OFF; // 打开XT2高频晶体振荡器
do
{
IFG1 &= ~OFIFG; //清除晶振失败标志
for (i = 0xFF; i > 0; i--); // 等待8MHz晶体起振
}
while ((IFG1 & OFIFG)); // 晶振失效标志仍然存在?
BCSCTL2 |= SELM_2 + SELS; //主时钟,子系统时钟选择高频晶振*/
P4DIR |= BIT1; //设置方波参数
P4SEL |= BIT1;
TBCCR0 = 128;
TBCCTL1 |= OUTMOD_6;
TBCCR1 = 32;
TBCTL = TBSSEL_2 +ID_3 + MC_3;
TACCR0 = 4096*5-1; //设置延迟时间
TACTL = TASSEL_2 + ID_3 + MC_1;
CCTL0 = CCIE;
_BIS_SR(LPM0_bits + GIE);
}
#pragma vector = TIMERA0_VECTOR
__interrupt void timer_A (void)
{
TBCCR1 += 32;
if (TBCCR0==128) TBCCR1 = 32;
}