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.

[参考译文] CCS/MSP430F2274:MSP430F2274 CAN#39;t 进入计时器 A ISR

Guru**** 2522770 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/906332/ccs-msp430f2274-msp430f2274-can-t-enter-timer-a-isr

器件型号:MSP430F2274

工具/软件:Code Composer Studio

我想制作一个频率计、但不能进入 Timer A。软件配置有问题?

#include 
#include "MSP430F2274.h"

unsigned int capArray[16]={0};
unsigned char index = 2、flag = 0;
float Hz = 0;

//
*绝对值
*/
int abs (int x)
{
返回 x>0?x:-x;
}


void Hz_Init()
{
P2SEL |= BIT2;
P2REN |= BIT6;
P2DIR &=~BIT2;
P2DIR |= BIT6;

CCTL0 = CM_1 + SCS + CCIS_0 + CAP + CCIE;
TACTL = tassel_2 + MC_2;
}

/****** 中断服务程序********* /
#pragma vector=TIMER0_A0_VECTOR
__INTERRUPT void TIMER0_A0_ISR (void)
{
capArray[索引-]= TA0CCR0;
if (index ==0)
{
索引= 2;
TA0CCR0 = 0;
Flag = 1;
}
}

/**
* blink.c
*/
void main()
{
双温度= 213.456;
WDTCTL = WDTPW + WDTHOLD;
Hz_Init();
P2OUT &=~BIT6;

_EINT();
while (1)
{
如果(标志= 1)
{
temp = abs (capArray[1]- capArray[2]);
Hz =((double)(1000000))/温度;
if (Hz>=60)
{
P2OUT |= BIT6;
}
其他
{
P2OUT &=~BIT6;
}
标志= 0;
}
}

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    >   CCTL0 = CM_1 + SCS + CCIS_0 + CAP + CCIE;

    根据数据表(SLAS504G)表24、P2.2是 CCI0B、而不是 CCI0A。 尝试:

    >   CCTL0 = CM_1 + SCS + CCIS_1 + CAP + CCIE;