msp430g2553 捕获功能,好像没有进入中断~求指导~
#include <msp430g2553.h>
unsigned int capture1_value = 0;
void main()
{
WDTCTL = WDTPW + WDTHOLD;
BCSCTL1 = CALBC1_16MHZ; //设定cpu
DCOCTL = CALDCO_16MHZ; //配置DCOCLK产生16M时钟
BCSCTL2 |= SELM_1 + DIVM_0 + DIVS_0; //主时钟MCLK选择DCOCLK,不分频.子时钟SMCLK选择DCOCLK,不分频
P1DIR &= ~BIT2; //P1.2 INPUT
P1SEL |= BIT2;
TACTL = TASSEL_2 + TACLR + MC_1; //SMCLK,up mode
//capture 1
TACCTL1 = CCIE + CM_2 + CCIS_0 + CAP + SCS ; //neg. edge,enabled interrupt,CCIxA,capture mode,
TACCR1 = 16;
_BIS_SR(GIE);
while(1)
{}
}
#pragma vector = TIMER0_A0_VECTOR
__interrupt void Timer_A0 (void)
{
switch (TAIV)
{
case 0x02:
TACCTL1 &= ~CCIFG;
capture1_value = TACCR1;
case 0x04:break; //capture 2
case 0x0a:break;
}
}
此帖出自
小平头技术问答
改为#pragma vector = TIMER0_A1_VECTOR
CCR1、CCR2的中断在A1里面
一周热门 更多>