This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
void TimrA1Init_captrue(void)
{
undefined
TA0CTL = TASSEL0+TACLR+TAIE+MC1; //时钟信号选择MCLK,计数模式为连续增计模式
TA0CCTL1 = CM1+SCS+CAP+CCIE; //输入下降沿捕获,CCI1A为捕获信号源
P1SEL |=BIT2; //设置P1.2端口为功能模块CCI1A输入捕获
}
unsigned int TimeGap=0;
#pragma vector=TIMER0_A1_VECTOR //定时器A中断处理
__interrupt void timer_a(void)
{
switch(TA0IV) //向量查询
{
case 2:
TimeGap=TA0R;//获取脉冲间隔
TA0R=0;
break;
default:
break;
}
}
请问:
TimeGap=TA0R;//获取脉冲间隔,这个正确吗?还是下面的语句是正确的:
TimeGap = TA1CCR0 ;
您好,应该是以下语句:
> TimeGap = TA0CCR1;
如果 MC1=MC_2 (连续) ,TA0R 会保持计数,因此不会偏差的太大,具体取决于软件延迟,但捕获的值位于 CCR 中。