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.

MSP430FR2633: Unable to detect capacitive touch in the software

Part Number: MSP430FR2633


This is in reference to problems faced while making use of "accessing element state data directly or Indirectly" as mentioned in the software library document for keypad feature. To be precise even when we touch the keypad on BSWP the if condition (keypadSensor_E00.bTouch == true) isn't satisfied. Furthermore, when we tried

if (keypad.pCycle[0]->pElements[0]->bTouch == true) condition, CCS showed incompatible keypad declaration.
Please see attached the main.c file for the project that does not work out.
We want to understand what we are doing wrong.
  • Hi Veer Karan Goy,

    I don't see an attachment.

    I can see from your comments above you are calling the sensor "keypadSensor" and then "keypad".  Make sure you are consistent with the names.  Not sure if that is the issue, just an observation.

    What is your target conversion count and conversion gain settings?

    What is your touch threshold setting?

    When you touch the sensor while running the GUI, do you see green LED in GUI below the BAR in the BAR Chart view?

    When you touch the button, do you see the blue bar go below the green line?  What is the delta measurement between touch and no-touch.

  • Hi Dennis,

    As per your suggestion, we have observed that the blue bar goes below green bar in GUI when touched. The delta value of 134 (touch) and 0-2 (no touch) is seen for 500 and 100 conversion count & gain value. I have also attached the code for your reference. Only LED1 is switched ON in our case. 

    #include <msp430.h>                      // Generic MSP430 Device Include
    #include "driverlib.h"                   // MSPWare Driver Library
    #include "captivate.h"                   // CapTIvate Touch Software Library
    #include "CAPT_App.h"                    // CapTIvate Application Code
    #include "CAPT_BSP.h"                    // CapTIvate EVM Board Support Package
    tElement keypad_E00;
    void main(void)
    {
    //
    // Initialize the MCU
    // BSP_configureMCU() sets up the device IO and clocking
    // The global interrupt enable is set to allow peripherals
    // to wake the MCU.
    //
    WDTCTL = WDTPW | WDTHOLD;
    BSP_configureMCU();
    __bis_SR_register(GIE);
    
    //
    // Start the CapTIvate application
    //
    CAPT_appStart();
    
    //
    // Background Loop
    //
    while(1)
    {
    //
    // Run the captivate application handler.
    // Set LED1 while the app handler is running,
    // and set LED2 if proximity is detected
    // on any sensor.
    //
    // LED1_ON;
    if(CAPT_appHandler()==true){
       if(keypad_E00.bTouch == true)
    
         {
             LED2_ON; // ILLUMINATE LED
             LED1_OFF;
         }
          else
          {
              LED2_OFF; // TURN LED OFF
             LED1_ON;
            }
    
    
    //
    // This is a great place to add in any
    // background application code.
    //
    __no_operation();
    }
    //
    // End of background loop iteration
    // Go to sleep if there is nothing left to do
    //
    CAPT_appSleep();
    
    } // End background loop
    } // End main()

  • Hi Veer Karan Goyal

    On line #6 you need to have 'extern' before tElement keypad_E00;

    example

    extern tElement keypad_E00;

    The way you have you are creating a new Element named "keypad_E00" which is local to main.  When your logic checkes keypad_E00.bTouch, it will always be false because compiler set = false by default when you built the code.

    Adding the extern tells the compiler that keypad_E00 is somewhere else in the project and it will find it in CAPT_UserConfig.c

  • Hi Dennis

    We had already defined "keypad_E00" using extern in CAPT_UserConfig.h file and as per your suggestion we defined it in CAPT_UserCofig.c file instead. Furthermore, we checked again for CAPT_WAKEONPROX_ENABLE (false). But, we are unable to detect captivate touch in the software. For your reference we have also attached an image of how we had defined it previously.

     

  • This is really strange.  I took your code and it runs on my BSWP EVM.  If you set a breakpoint somewhere in the if(keypad_E00.bTouch = true {} does the code ever get there?  Or in debug mode reset the code, set a breakpoint on  if(keypad_E00.bTouch = true then put your finger on keypad_E00 and run the code.  When the program stops either mouse over the expression keypad_E00 or add to the expressions window and see if it is true or false.

  • We have tried your suggestion and the output of "keypad_E00.bTouch" is observed to be false. I am hereby providing the link for the entire project, if you may please run it on your BSWP EVM and check whether  it's working on it. The used version of CCS is 12.6.0 and for GUI it's 1.83.00.08.

    drive.google.com/.../1W_JahFk0lFTUS170TGfr-tkwHcshP9-a

**Attention** This is a public forum