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.

Timer In Capture mode.

Hi,

Where can I find C code samples for MSP430 timer in capture mode?

And also documents other than user guide describing details about capture mode..

 

Thankyou..

 

  • Chakra,

    For a capture-mode code example please see "fet140_ta_22.c" in the following zip file: http://www.ti.com/lit/zip/slac015

    Also the MSP430's user's guide discusses the capture mode operation in detail. For the 2xx this is page 401: http://focus.ti.com/lit/ug/slau144e/slau144e.pdf

  • Here's another one (Couldn't figure out the attachments option):

    //******************************************************************************
    //  MSP430F20xx Demo - Timer_A, Compare Mode, SMCLK
    //  Give a 1 KHz square wave to P1.1 (pin 3)
    //  Place breakpoint as inidicated below
    //  Read the value in 'buffer' variable
    //  buffer[i]-buffer[i-1] = pulse width
    //  In this example Signal frequency = 1KHz, TA CLK = 1MHz
    //  Captured clocks = 1M/1K = 1000
    //  buffer = [1000, 2000, 3000, 4000....]
    //******************************************************************************

    #include <msp430x20x2.h>
    unsigned int buffer[20];
    unsigned char i=0;
    void main(void)
    {
      WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
      if (CALBC1_1MHZ ==0xFF || CALDCO_1MHZ == 0xFF)                                    
      { 
        while(1);                               // If calibration constants erased
                                                // do not load, trap CPU!!
      }
      BCSCTL1 = CALBC1_1MHZ;                    // Set DCO to 1MHz
      DCOCTL = CALDCO_1MHZ;
      P1SEL |= BIT1;                            // P1.1 CCI0A
      TACTL = TASSEL_2 + MC_2;                  // SMCLK, contmode
      TACCTL0 = CM_1+CCIS_0+SCS+CAP+CCIE;
      _BIS_SR(LPM0_bits + GIE);                 // Enter LPM0 w/ interrupt
    }

    // Timer A0 interrupt service routine
    #pragma vector=TIMERA0_VECTOR
    __interrupt void Timer_A (void)
    {
      buffer[i++] = TACCR0;
      if (i>10)
        __no_operation();                       // PLACE BREAKPOINT HERE
                                                // VIEW 'BUFFER' VARIABLE
     
    }

  • Priya said:

    Here's another one (Couldn't figure out the attachments option):

    you can attach files on the 'Options' tab when creating a new post.

  • Hey Adrian,

    Tried that already. The only options I get are 1) Send replies to this post by email and 2) Do not send replies by email.

    There is no option to add attachments ;(

  • HELLO FRIENDS...

     we too have the same application in our program... so can you able to send your coding to us... it will be useful for us....

**Attention** This is a public forum