Tool/software: Code Composer Studio
Hello,
Days before I posted a doubt about trying to capture an external square wave signal using as an example "ta0_capture.c". but conecting in P1.3 an external signal instead of using the internal one. I achieved to capture the signal, but the increase of values of the timer (vector 'timerAcaptureValues') does not change if I increase the frecuency, neither the frequency of the external signal nor the frequency of the timer. What should I change or implement on the code, if I want that the Timer increment value changes if I modify the frequency of the external wave signal or the frequency of the timer?
Thank you,
**HERE IS THE CODE**
#include <msp430.h> #define NUMBER_TIMER_CAPTURES 20 volatile unsigned int timerAcaptureValues[NUMBER_TIMER_CAPTURES]; unsigned int timerAcapturePointer = 0; int main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer // Configure GPIO P1OUT &= ~0x01; // Clear P1.0 output P1DIR |= 0x01; P1SEL1 &= ~BIT3; // Set P1.3 to input direction P1SEL0 |= BIT3; P1DIR &= ~BIT3; // Disable the GPIO power-on default high-impedance mode to activate // previously configured port settings PM5CTL0 &= ~LOCKLPM5; // Clock System Setup CSCTL0_H = CSKEY >> 8; // Unlock CS registers CSCTL1 = DCOFSEL_0; // Set DCO to 1MHz CSCTL2 = SELS__DCOCLK; // set SMCLK = DCO CSCTL3 = DIVS__1; // Set dividers CSCTL0_H = 0x00; // Lock CS module (use byte mode to upper byte) __delay_cycles(1000); // Allow clock system to settle // Timer0_A3 Setup TA1CCTL2 = CM_1 | CCIS_0 | SCS | CAP | CCIE; // Capture rising edge, // Use CCI2A=P1.3, // Synchronous capture, // Enable capture mode, // Enable capture interrupt TA1CTL = TASSEL__SMCLK | MC__CONTINUOUS; // Use SMCLK as clock source, // Start timer in continuous mode __bis_SR_register(LPM0_bits | GIE); __no_operation(); } // Timer1_A3 CC1-4, TA Interrupt Handler #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__) #pragma vector = TIMER1_A1_VECTOR __interrupt void Timer1_A1_ISR(void) #elif defined(__GNUC__) void __attribute__ ((interrupt(TIMER1_A1_VECTOR))) Timer1_A1_ISR (void) #else #error Compiler not supported! #endif { switch (__even_in_range(TA1IV, TA1IV_TAIFG)) { case TA1IV_TA1CCR1: break; case TA1IV_TA1CCR2: timerAcaptureValues[timerAcapturePointer++] = TA1CCR2; if (timerAcapturePointer >= 20) { while (1) { P1OUT ^= 0x01; // Toggle P1.0 (LED) __delay_cycles(100000); } } break; case TA1IV_TA1IFG: break; default: break; } }