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.

单片机是F5529,用定时器A捕获功能时的一些问题



我用捕获功能测试脉宽,单片机是MSP430F5529LP(捕获管脚在P1.2和P1.3),   时钟选择的SMCLK(默认1MHZ),然后选择的捕获源是CCIXA对应的应该是P1.2,然后这是我的一段代码,不知道哪里出了问题,我捕获一个50KHZ,占空比为50%的方波一直捕获不到!

#include <msp430.h>
#define uchar unsigned char
#define uint unsigned int
uint start,end,cha;

void main()
{

WDTCTL = WDTPW+WDTHOLD;
P1SEL|=BIT2;
TA0CCTL1 |=CAP+CM_3+CCIS_0+SCS+CCIE;//捕获模式,上升和下降都捕获,选择CCI2A,同步,捕获中断开
TA0CTL |= TASSEL_2 + MC_2; //SMCLK=1M,连续计数模式
_EINT();
LPM0;
while(1);

}

#pragma vector=TIMER0_A0_VECTOR
__interrupt void TIMER0_A0_ISR(void)
{
switch(TA0IV)
{
case 2:

if(TA0CCTL1&CCI)
start=TA0CCR1;
else
end=TA0CCR1;
cha=start-end;

break;

default:break;

}
LPM0_EXIT;
}