Other Parts Discussed in Thread: MSP430F5325
Tool/software: Code Composer Studio
hello all, i am facing a problem to measure timer ticks of a given signal frequency 50Hz square wave on port P1.1, I am using MSP430F5325
i want to measure timer ticks in its ON time i.e. in 10 msec. can anyone tell me how to do it or anyone having sample code for this
also i have a one question, suppose i measure the timer ticks in 10ms then with the help of timer ticks value can i control the pulse width or frequency of that signal?
#include <msp430.h> unsigned int rising_cap=0;
unsigned int falling_cap=0; volatile unsigned int rising_count = 0;
unsigned int i=0; int main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer for (i=0; i<20000; i++) // Delay for crystal stabilization { } P1DIR &=~ BIT1; P1SEL |= BIT1; // Set P1.1 to TA0 TA0CCTL0 |= CM_1 + SCS + CCIS_0 + CAP + CCIE; // Rising edge + CCI0A (P1.1) + Capture Mode + Interrupt TA0CCTL1 |= CM_2 + SCS + CCIS_0 + CAP + CCIE; //falling edge, capture mode, interrupt TA0CTL = TASSEL_2; // SMCLK _BIS_SR(GIE); // LPM0 + Enable global ints } #pragma vector = TIMER0_A0_VECTOR __interrupt void Timer0_A0_ISR (void) {
rising_count++;
if (rising_count==2)
{
rising_cap = TA0CCR0;
falling_cap = TA0CCR1;
}
