P2DIR &=~BIT0;
P2SEL |= BIT0;
TA1CTL |= TASSEL_2 + MC_2 + ID_3 +TACLR+0X0002; // ACLK, upmode,8fenpin clear TAR
TA1CCTL1 |=CAP+CCIS_1+CM_1+CCIE; //CM_1是捕获模式的选择
P7DIR |=BIT1;
P7SEL &=~BIT1;
P7OUT &=~BIT1;
freq=0;
start=end=0;
i=0;
_EINT();
while(1)
{
P7OUT |=BIT1;
num=overflow*65535+end-start;
freq=1/num*10000000;
Dogs102x6_clearScreen();
P7OUT &=~BIT1;
itoa(num,string,10);
Dogs102x6_stringDraw(3, 30, string, DOGS102x6_DRAW_NORMAL);
itoa(freq,string,10);
Dogs102x6_stringDraw(4, 30, string, DOGS102x6_DRAW_NORMAL);
}
}
#pragma vector=TIMER1_A1_VECTOR
__interrupt void TIMER1_A1_ISR(void)
{
switch(__even_in_range(TA1IV,14))
{
case 0: break; // No interrupt
case 2:
P1OUT ^= 0x01;
if(TA1CCTL1&CM0) //==捕获到上升沿==
{
if(i==0)
{
start=TA1R; //==记录初始时间==
}
if(i==1)
{
end=TA1R;
}
i++;
}
if(i==2)
i=0;
break; // CCR1 not used
case 4: break; // CCR2 not used
case 10:
overflow++;
break; // reserved
default: break;
}
}
这个是主要的部分,想用7.1口输出个波试一试,但是分步调试时都进不去中断的,请问是什么问题呢?快两天了,很着急.
谢谢帮助!
此帖出自
小平头技术问答
一周热门 更多>