430G2553 launchpad测试定时器捕获功能发现用switch+case时不能进入捕获中断,不用则能正常进入,但是溢出中断能进入:
#include "msp430g2553.h"
int main( void )
{
WDTCTL = WDTPW + WDTHOLD;//停止看门狗
BCSCTL2 |= SELS;//SMCLK时钟源选择为LFXT1CLK(32768HZ)
P1DIR |= (BIT0 +BIT4 + BIT6);
P1DIR &= ~BIT2;
P1SEL |= (BIT4 + BIT2);//P1.4->SMCLK输出,P1.2->捕获输入
TACTL |= TASSEL_2 + MC_2 + TACLR + TAIE;//定时器A时钟源为SMCLK,连续计数模式,定时器清零
CCTL0 = CM_3 + SCS + CCIS_0 + CAP + CCIE;//上升沿和下降沿都捕获,同步,捕获模式,捕获中断允许
CCTL1 = CM_1 + SCS + CCIS_0 + CAP + CCIE;//上升沿捕获,同步,捕获模式,
_EINT();
while(1);
}
#pragma vector = TIMER0_A1_VECTOR
__interrupt void TIMER_A1(void)
{
switch(TAIV)
{
case 2: break;
case 4: P1OUT ^= BIT6;
break;
case 10: P1OUT ^= BIT0;
break;
}
}
此帖出自
小平头技术问答
一周热门 更多>