void setclock(void)
{
WDTCTL = WDTPW + WDTHOLD; // watchdog timer setup
if (CALBC1_1MHZ ==0xFF || CALDCO_1MHZ == 0xFF)
{
while(1); // If cal constants erased, trap CPU!!
}
BCSCTL1 = CALBC1_1MHZ; // Set range
DCOCTL = CALDCO_1MHZ; // Set DCO step + modulation
IFG1 &= ~OFIFG;
}
void settimer(){
TACTL=TACLR;
TACTL=TASSEL_2+MC_2;
TACCTL1=CM_3+CCIS_0+CAP+CCIE;
TACCTL1&=~CCIFG;
_EINT();
}
void setgpio(){
P1DIR=0X01;
P1OUT=0X01;
P1SEL=BIT2+BIT1;
}
void main(void)
{
setclock();
setgpio();
settimer();
while(1);
}
#pragma vector=TIMER0_A1_VECTOR
__interrupt void Timer_A (void)
{
if(TACCTL1&CCIFG){
TACCTL1&=CCIFG;
//CC=CCR1-C;
//C=CCR1;
P1OUT^=BIT0;
}
}
此帖出自
小平头技术问答
一周热门 更多>