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.

FREQUENCY CAPTURE IN MSP430G2152

Other Parts Discussed in Thread: MSP430G2152

Hi Guys;

        I am using msp430g2152 for my project application in that i want to capture 840khz  frequency signal..... by using 16mhz  oscillator signal... i cant able to capture my signal so help me..

 ADVANCE THANKS TO ALL

This is my code

TACTL = TASSEL_2 +MC_2;                         
TACCTL1 = CM_1+CCIS_0+SCS+CAP+CCIE;

840khz exact  count value is 19 but instead of that i got 39 or 59 or40 so please help me to capture that signal...

  • Hello,

    We may need more information before we can determine what the problem is - esp the clock settings/ port setting.

    In any case I have a simple example on the F20xx that captures a 1KHz signal using a 1MHz clock source.

    Compare it to your to see if you are missing anything...

    Regards,

    Priya

  • Hello Priya,

      

    0383.capture.txt
    #include <msp430g2152.h>					
    unsigned int new_cap=0;						
    unsigned int old_cap=0;						
    unsigned int cap_diff=0;					
    void main(void)
    {
        WDTCTL = WDTPW + WDTHOLD;                   		// Stop WDT
        BCSCTL1 = CALBC1_16MHZ;                    // Set Oscillator range
      DCOCTL = CALDCO_16MHZ; 
        P1SEL |= BIT2;                              		// Port 1.2/TACCR1 - Input                 
       P1DIR=0xF0;				        		// P1.4, P1.5, P1.6, P1.7 as a output
        P1OUT=0x00; 						// Initially reset port1                     
      P1OUT |=0x10;						// P1.4 High for Green status LED 
        TACTL = TASSEL_2 +MC_2;          				// SMCLK = 1 Mhz, continuous mode
        TACCTL1 = CM_1+CCIS_0+SCS+CAP+CCIE; 			// capture on rising edge & falling edge, Timer A select, Sync., capture mode, Enable timer interrupt
            
        __bis_SR_register(LPM0_bits + GIE);         		// LPM0 mode
    }    
    
    // Timer A1 interrupt service routine
    
    #pragma vector = TIMER0_A1_VECTOR
    __interrupt void TA1_ISR(void)
    {
     switch( TAIV )                                 // Efficient switch-implementation
      {
        case 2:                                     // CCR1 capture value
          new_cap = TACCR1;
        cap_diff = new_cap - old_cap;		
         old_cap = new_cap;                          // move current value 
       break;                 
      }
    }
    
    
    6014.capture.txt
    #include <msp430g2152.h>					
    unsigned int new_cap=0;						
    unsigned int old_cap=0;						
    unsigned int cap_diff=0;					
    void main(void)
    {
        WDTCTL = WDTPW + WDTHOLD;                   		// Stop WDT
        BCSCTL1 = CALBC1_16MHZ;                    // Set Oscillator range
      DCOCTL = CALDCO_16MHZ; 
        P1SEL |= BIT2;                              		// Port 1.2/TACCR1 - Input                 
       P1DIR=0xF0;				        		// P1.4, P1.5, P1.6, P1.7 as a output
        P1OUT=0x00; 						// Initially reset port1                     
      P1OUT |=0x10;						// P1.4 High for Green status LED 
        TACTL = TASSEL_2 +MC_2;          				// SMCLK = 1 Mhz, continuous mode
        TACCTL1 = CM_1+CCIS_0+SCS+CAP+CCIE; 			// capture on rising edge & falling edge, Timer A select, Sync., capture mode, Enable timer interrupt
            
        __bis_SR_register(LPM0_bits + GIE);         		// LPM0 mode
    }    
    
    // Timer A1 interrupt service routine
    
    #pragma vector = TIMER0_A1_VECTOR
    __interrupt void TA1_ISR(void)
    {
     switch( TAIV )                                 // Efficient switch-implementation
      {
        case 2:                                     // CCR1 capture value
          new_cap = TACCR1;
        cap_diff = new_cap - old_cap;		
         old_cap = new_cap;                          // move current value 
       break;                 
      }
    }
    
    

     I attached my coding....my aim is to capture above 840khz frequency by using 16mhz internal clock oscillator in msp430g2152 controller....so please refer my code and reply

    Thanks in advance

**Attention** This is a public forum