#include <msp430.h>
void ini_sys(void)
{ char i;
WDTCTL=WDTPW+WDTHOLD; //STOP W D T
do
{
IFG1&=~OFIFG; for(i=0xff;i>0;i--);
}
while ((IFG1&OFIFG)!=0);
}
int main(void)
{
ini_sys();
BCSCTL2|=SELS;
P1SEL|=0X04; //P1.1(ta0)
P2DIR|= 0x01; // P1.3 output
P2OUT|=0X00;
//CCTL1|=CM_1+SCS+CAP+CCIE;
//CCTL2|=CM_2+SCS+CAP+CCIE;
CCTL1|=CM_1+SCS+CAP+CCIE;
TACTL|= TASSEL_2 +ID_3+MC_1+TAIE; // SMCLK, up-down mode
_EINT();
// _BIS_SR(LPM0_bits);
while(1);
}
#pragma vector=TIMERA0_VECTOR
__interrupt void TimerA0(void)
{
if(CCTL1&CM1)
{//P2OUT&=~0X01;
CCTL1=CM_1+SCS+CAP+CCIE;
}
else if(CCTL1&CM0)
{//P2OUT|=0X01;
CCTL1=CM_2+SCS+CAP+CCIE;
}
}
/*#pragma vector=TIMERA1_VECTOR
__interrupt void TimerA1(void)
{switch(TAIV)
{case 2:P2OUT|=0X01;break;
case 4:P2OUT&=~0X01;break;
default:break;
}
}*/
#pragma vector=TIMERA1_VECTOR
__interrupt void TimerA1(void)
{switch(TAIV)
{
case 2:P2OUT^=BIT0;break;
default:break;
}
}