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.
Tool/software: Code Composer Studio
I want to make a frequency meter but can't enter Timer A.Is there a problem with the software configuration?
#include <msp430.h> #include "msp430f2274.h" unsigned int capArray[16] = {0}; unsigned char index = 2, flag = 0; float hz = 0; /* * 绝对值 */ int abs(int x) { return 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 TIME0_A0_ISR(void) { capArray[index--] = TA0CCR0; if(index == 0) { index = 2; TA0CCR0 = 0; flag = 1; } } /** * blink.c */ void main() { double temp = 213.456; WDTCTL = WDTPW + WDTHOLD; HZ_Init(); P2OUT &= ~BIT6; _EINT(); while(1) { if (flag == 1) { temp = abs(capArray[1] - capArray[2]); hz = ((double )(1000000))/temp; if(hz>=60) { P2OUT |= BIT6; } else { P2OUT &= ~BIT6; } flag = 0; } } }
>
CCTL0 = CM_1 + SCS + CCIS_0 + CAP + CCIE;
Per Data sheet (SLAS504G) Table 24, P2.2 is CCI0B, not CCI0A. Try:
>
CCTL0 = CM_1 + SCS + CCIS_1 + CAP + CCIE;
**Attention** This is a public forum