21ic问答首页 - 我的捕获程序只能进一次中断怎么办求大神
我的捕获程序只能进一次中断怎么办求大神
laocuo11422020-11-13
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;
}
}
{
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;
}
}
您需要登录后才可以回复 登录 | 注册