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.

CCS/MSP430G2955: msp430g2955

Part Number: MSP430G2955
Other Parts Discussed in Thread: MSP430G2553, MSP430WARE

Tool/software: Code Composer Studio

hello,

My name is satyendra and i am trying to interface capacitve touch with msp430g2955. As far now i can easily interface one capacitive touch pad as switch with P1.0 but cannot interface other pins. So if anyone has interfaced capacitive touch as switch for any other pin please help me.

  • Hi Satyendra,

    I recommend taking a look at the MSP430Ware examples for the MSP430G2553. While this is not the device you're trying to implement capacitive touch on, it is in the same family of devices. There are also examples showing how to implement capacitive touch on multiple pins.

    You can access these examples in CCS via View --> Resource Explorer or on the cloud here. The examples you're looking for include pinosc in the name. Let me know if you need any further help.

    Best regards,

    Caleb Overbay

  • Thanks for reply but i cannot use it and i tried same code which is given for MSP430G2553 also does not work. If its possible that someone has interfaced P1.1 or any other of MSP430G2955 pin other that P1.0 as capacitive touch  please help. what does T0.0 means and how to access it.?

  • Hi Satyendra,

    The examples have been tested and proven to work and the example provided for the G2553 will work for the G2955. What problems were you encountering when trying out this example?

    Best regards,
    Caleb Overbay

  • Below is the fucntion for P1.0 it works perfectly

     

    void pin_osc_measure2(void)

    {

     

    TA0CTL = TASSEL_0+MC_2;                   // TACLK, cont mode

       TA0CCTL1 = CM_3+CCIS_2+CAP;               // Pos&Neg,GND,Cap

    //for (i = 0; i<NUM_SEN; i++)

       P1DIR &= ~ BIT0;                       // P1.1 is the input used here

         P1SEL &= ~ BIT0;

         P1SEL2 |= BIT0;

         /*Setup Gate Timer*/

         WDTCTL = WDT_meas_setting;             // WDT, ACLK, interval timer

         TA0CTL |= TACLR;                       // Clear Timer_A TAR

         __bis_SR_register(LPM0_bits+GIE);       // Wait for WDT interrupt

         TA0CCTL1 ^= CCIS0;                     // Create SW capture of CCR1

         meas_cnt[0] = TACCR1;                      // Save result

         WDTCTL = WDTPW + WDTHOLD;               // Stop watchdog timer

         P1SEL2 &= ~BIT0;

         TACCR1 &= 0;

         __delay_cycles(100);

         if(meas_cnt[0] < 1000)

         {

           P2OUT |= BIT2;

           // __delay_cycles(99000);

         }

         else

         {

           P2OUT &= ~BIT2;

           //__delay_cycles(99000);

         }

     

     

    }

    meas_cnt[0]=1948 when not touched

    meas_cnt[0]=558 when touched

    Function for P1.1. This is provided by TI

    void pin_osc_measure5(void)

    {

     

       TA0CTL = TASSEL_3+MC_2;                   // TACLK, cont mode

       TA0CCTL1 = CM_3+CCIS_2+CAP;               // Pos&Neg,GND,Cap

       P1DIR &= ~ BIT1;                       // P1.1 is the input used here

       P1SEL &= ~ BIT1;

       P1SEL2 |= BIT1;

     

         /*Setup Gate Timer*/

         WDTCTL = WDT_meas_setting;             // WDT, ACLK, interval timer

         TA0CTL |= TACLR;                       // Clear Timer_A TAR

         __bis_SR_register(LPM0_bits+GIE);       // Wait for WDT interrupt

        

         TA0CCTL1 ^= CCIS0;

        

        

         meas_cnt[2] = TACCR1;// Save result

         WDTCTL = WDTPW + WDTHOLD;               // Stop watchdog timer

         P1SEL2 &= ~BIT1;

         //TACCR1 &= 0;

         if(meas_cnt[1] < 111)

         {

           P2OUT |= BIT2;

           //__delay_cycles(99000);

         }

         else

         {

           P2OUT &= ~BIT2;

         // __delay_cycles(99000);

         }

     

     

    }

    When its touched or not, meas_cnt[1] which should change, have no change and gives 0.

     

  • Hi satyendra,

    I can't find that function in any of the TI provided code examples. Which example are you referring to? I think this example is what you should be referring to:

    msp430g2xx3_pinosc_02.c
    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    /* --COPYRIGHT--,BSD_EX
    * Copyright (c) 2012, Texas Instruments Incorporated
    * All rights reserved.
    *
    * Redistribution and use in source and binary forms, with or without
    * modification, are permitted provided that the following conditions
    * are met:
    *
    * * Redistributions of source code must retain the above copyright
    * notice, this list of conditions and the following disclaimer.
    *
    * * Redistributions in binary form must reproduce the above copyright
    * notice, this list of conditions and the following disclaimer in the
    * documentation and/or other materials provided with the distribution.
    *
    * * Neither the name of Texas Instruments Incorporated nor the names of
    * its contributors may be used to endorse or promote products derived
    * from this software without specific prior written permission.
    *
    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
    * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
    * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
    * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
    * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
    * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    *
    *******************************************************************************
    *
    * MSP430 CODE EXAMPLE DISCLAIMER
    *
    * MSP430 code examples are self-contained low-level programs that typically
    * demonstrate a single peripheral function or device feature in a highly
    * concise manner. For this the code may rely on the device's power-on default
    * register values and settings such as the clock configuration and care must
    * be taken when combining code from several examples to avoid potential side
    * effects. Also see www.ti.com/grace for a GUI- and www.ti.com/msp430ware
    * for an API functional library-approach to peripheral configuration.
    *
    * --/COPYRIGHT--*/
    //******************************************************************************
    // MSP430G2xx3 Demo - Capacitive Touch, Pin Oscillator Method, 4-buttons
    //
    // Description: Basic 4-button input using the built-in pin oscillation feature
    // on GPIO input structure. PinOsc signal feed into TA0CLK. WDT interval is used
    // to gate the measurements. Difference in measurements indicate button touch.
    // LEDs flash if input is touched.
    //
    // Input 1: LED1 (LED2 off)
    // Input 2: LED2 (LED1 off)
    // Input 3: Both LEDs on
    // Input 4: Both LEDs flash on/off
    //
    // ACLK = VLO = 12kHz, MCLK = SMCLK = 1MHz DCO
    //
    // MSP430G2xx3
    // -----------------
    // /|\| XIN|-
    // | | |
    // --|RST XOUT|-
    // | |
    // | P1.1|<--Capacitive Touch Input 1
    // | |
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Also, it's very hard to read your code when it's posted in plain text format. If you need to post code to the forum, can you use the Syntaxhighlighter?

    Best regards,

    Caleb Overbay

  • Hi Caleb,

    Sorry for posting in plain text. I am using the same example which u sent.

    I just made it as function for my application. Here is my complete code

    * Main Function*/
    
    #include  "msp430g2955.h"
    
    #define NUM_SEN     8                       // Defines number of sensors
    #define LED_1   BIT2                      // P2.0 LED output
    /* Defines WDT SMCLK interval for sensor measurements*/
    #define WDT_meas_setting (DIV_SMCLK_512)
    #define DIV_SMCLK_512   (WDT_MDLY_0_5)      // SMCLK/512
    
    // Global variables for sensing
    unsigned int meas_cnt[NUM_SEN];
    unsigned int watchdog_flag;
    const unsigned char electrode_P1[NUM_SEN] = { BIT0, BIT1, BIT2, BIT3, BIT4,
                                                  BIT5, BIT6, BIT7 };
    int i;
    void pin_osc_measure5(void);
    void pin_osc_measure4(void);
    void pin_osc_measure2(void);
    void main(void)
    {
        unsigned int i, j;
        WDTCTL = WDTPW + WDTHOLD;                 // Stop watchdog timer
        if (CALBC1_1MHZ == 0xFF)                   // If calibration constant erased
        {
            while (1)
                ;                               // do not load, trap CPU!!
        }
        DCOCTL = 0;                          // Select lowest DCOx and MODx settings
        BCSCTL1 = CALBC1_1MHZ;                    // Set DCO to 1MHz
        DCOCTL = CALDCO_1MHZ;
        BCSCTL3 |= LFXT1S_2;                      // LFXT1 = VLO
    
        IE1 |= WDTIE;                                      // enable WDT interrupt
        P2SEL = 0x00;                             // No XTAL
    
        P2DIR |= BIT2;
        P2OUT &= ~BIT2;
        P2OUT |= BIT2;
        __bis_SR_register(GIE);
        for (;;)
        {
    
            pin_osc_measure5();
            // pin_osc_measure2();// Establish baseline capacitance
        }
    }                                           // End Main
    
    void pin_osc_measure5(void)
    {
    
        TA0CTL = TASSEL_3 + MC_2;                   // TACLK, cont mode
        TA0CCTL1 = CM_3 + CCIS_2 + CAP;               // Pos&Neg,GND,Cap
    
        // TA0CCTL1 = CM_3+CCIS_3+CAP;
    
        //for (i = 0; i<NUM_SEN; i++)
    
        P1DIR &= ~ BIT1;                        // P1.1 is the input used here
        P1SEL &= ~ BIT1;
        P1SEL2 |= BIT1;
    
        /*Setup Gate Timer*/
        WDTCTL = WDT_meas_setting;              // WDT, ACLK, interval timer
        TA0CTL |= TACLR;                        // Clear Timer_A TAR
        __bis_SR_register(LPM0_bits + GIE);       // Wait for WDT interrupt
    
        TA0CCTL1 ^= CCIS0;
    
        meas_cnt[2] = TACCR1;       // Save result
        WDTCTL = WDTPW + WDTHOLD;               // Stop watchdog timer
        P1SEL2 &= ~BIT1;
        //TACCR1 &= 0;
        if (meas_cnt[1] < 111)
        {
            P2OUT |= BIT2;
            //__delay_cycles(99000);
        }
        else
        {
            P2OUT &= ~BIT2;
            //  __delay_cycles(99000);
        }
    
    }
    
    // TA0CTL = 0;                             // Stop Timer_A
    //for(i = 0; i < NUM_SEN; i++)
    void pin_osc_measure2(void)
    {
    
        TA0CTL = TASSEL_0 + MC_2;                   // TACLK, cont mode
        TA0CCTL1 = CM_3 + CCIS_2 + CAP;               // Pos&Neg,GND,Cap
    
        //for (i = 0; i<NUM_SEN; i++)
    
        P1DIR &= ~ BIT0;                        // P1.1 is the input used here
        P1SEL &= ~ BIT0;
        P1SEL2 |= BIT0;
    
        /*Setup Gate Timer*/
        WDTCTL = WDT_meas_setting;              // WDT, ACLK, interval timer
        TA0CTL |= TACLR;                        // Clear Timer_A TAR
        __bis_SR_register(LPM0_bits + GIE);       // Wait for WDT interrupt
        TA0CCTL1 ^= CCIS0;                      // Create SW capture of CCR1
        meas_cnt[0] = TACCR1;                      // Save result
        WDTCTL = WDTPW + WDTHOLD;               // Stop watchdog timer
        P1SEL2 &= ~BIT0;
        TACCR1 &= 0;
        __delay_cycles(100);
        if (meas_cnt[0] < 1000)
        {
            P2OUT |= BIT2;
            // __delay_cycles(99000);
        }
        else
        {
            P2OUT &= ~BIT2;
            //__delay_cycles(99000);
        }
    
    }
    
    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    #pragma vector=WDT_VECTOR
    __interrupt void watchdog_timer(void)
    #elif defined(__GNUC__)
    void __attribute__ ((interrupt(WDT_VECTOR))) watchdog_timer (void)
    #else
    #error Compiler not supported!
    #endif
    {
        TA0CCTL0 ^= CCIS1;
        TA0CCTL0 ^= CCIS0;
        TA0CCTL1 ^= CCIS0;
        TA0CCTL1 ^= CCIS1;               // Create SW capture of CCR1
        __bic_SR_register_on_exit(LPM3_bits);     // Exit LPM3 on reti
    }
    
    

  • Hi satyendra,

    I believe you issue is that you're using the wrong timer. On the G2553, Timer0_A3 has the appropriate internal connections for pin osc when selecting INCLK as the source. However on the G2955, Timer1_A3 has the appropriate connections as seend in Table 13 of the datasheet:

    Hope this helps and let me know if this works.

    Best regards,

    Caleb Overbay

  • Hi Caleb,
    i used TIMER!  as you suggested it works well. I will let you know if I have any more problem. Thanks for your precious support it was very difficult to find what was going wrong.

  • Hi Satyendra,

    I understand you're not using P2.0. In the example, the PINOSC signal the source to the timer being used to capture measurements. Table 13 shows that you need to use Timer1_A3 because it has the proper settings for to route the PINOSC signal to the timer. This is regardless of the pin number being used. Whereas in Table 12 you can see that setting Timer1_A3 to use INCLK, you are sourcing it from P2.x instead of PINOSC.

    Best regards,
    Caleb Overbay

**Attention** This is a public forum