为什么第二路不能够捕获呢?
#include <msp430x14x.h>
#include "LCD1602.h"
unsigned int upflag=0;
unsigned int downflag=0;
int main( void )
{
WDTCTL = WDTPW + WDTHOLD;
LcdInit();
P1DIR &=~ BIT2+BIT3;
P1SEL = BIT2+BIT3; //设置P1.2为端口功能模块使用,即做捕获源
TACTL = TASSEL_2 +TACLR +TAIE + MC1;//ACLK
CCTL1 = CM_1 +SCS +CAP +CCIE; //输入上升沿捕获,CCI0A为您捕获信号源
CCTL2 = CM_1 +SCS +CAP +CCIE; //输入上升沿捕获,CCI0A为您捕获信号源
_EINT();
while(1){
WriteCommand(0x80);
WriteData(upflag+0x30);
WriteCommand(0xC0);
WriteData(downflag+0x30);
}
}
/*******************************************\
定时器A中断服务子函数
捕获待测信号上升沿
**********************************************/
#pragma vector = TIMERA1_VECTOR
__interrupt void Timer_A(void)
{
switch(TAIV) //向量查询
{
case 2: //捕获中断
if(CCTL1 & CM0) //捕获到上升沿
upflag++; TACCTL1 &=~CCIFG; break;
case 4:
if(CCTL2 & CM0) //捕获到上升沿
upflag++; TACCTL2 &=~CCIFG; break;
default:
break;
}
} |