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.

MSP430FR2533: Capacitive touch

Part Number: MSP430FR2533
Other Parts Discussed in Thread: MSP430FR2522, TIDM-1021

Tool/software:

Hi,

I am planning to use Captivate feature of MSP430FR2533. Created a custom project and imported captivate and captivatconfig folder from the code generated by DesignCenter. Code snippet for application:

static void AppCaptivateInitialize(void)
{
MAP_CAPT_initUI(&g_uiApp);
MAP_CAPT_calibrateUI(&g_uiApp);
MAP_CAPT_selectTimerSource(CAPT_TIMER_SRC_ACLK);
MAP_CAPT_writeTimerCompRegister(CAPT_MS_TO_CYCLES(g_uiApp.ui16ActiveModeScanPeriod));
MAP_CAPT_startTimer();
MAP_CAPT_enableISR(CAPT_TIMER_INTERRUPT);
}

My code is getting stuck at MAP_CAPT_calibrateUI(&g_uiApp); and when when paused I get the following message as attached.

Please help in this regard.

  • Hi Mithilesh,

    Generally a calibration problem is due to incorrect connections between the CAPT IO pins and the sensor electrodes.  In other words, in the CAPT_UserConfig.c file, the RX (pin and  block)  assignments, and if the sensor is a Mutual cap type, the TX (pin and block assignments) don't match the actual physical connection to the sensors.

    What I would suggest is first to rule this out, program the Captivate project code generated by the GUI into the MSP430FR2522 and verify the sensors calibrate and you see data on the GUI.  If this works then the pin assignments -> sensor electrodes are correct.

    What type of sensors are you implementing, self or mutual?

    What is the conversion gain and target conversion count set to?

  • Self

    Currently the default values. Just want to see if the circuit work initially.

  • There are 12 buttons configured in self-capacitance mode.

  • Understand.  Then you should be able to take the generated output from the Captivate GUI, import that project, build and program your target.  Hopefully you have available on the MSP430FR2533 either an I2C or UART that can be wired up to the CAPT-PGMR and send/receive data with the GUI.  This way you will see the response and be able to "tune" the sensors at the same time.

  • Hi Dennis

    I have tried running the project generated by Captivate GUI and it works fine. Now I follow the instructions mentioned in CapTIvateTm Technology Guide: Software Library for standalone project. Now if I try to debug the code it gets stuck at  CAPT_calibrateUI(&g_uiApp) and when paused gives Break at address "0x7ffe" with no debug information available, or outside of program code. 

  • Hmm.....

    Ok, I have seen this type of unexplained behavior in the past and appears to be something with the debugger getting triggered on a phantom address.  Never have been able to prove it as it hard to duplicate.

    So first can you do the following, build with optimization level 0, if you aren't already.  This provides the best debugging experience and see if the problem still occurs.  If so, when halted, open the "View disassembly" window and take a snap shot and share with me.

  • The code gets stuck at point marked in yellow. I have tried with the optional clock setting defined in the document but the same issue.

      

  • Hi Mithilesh,

    Ok, that indicates there is most likely something wrong in the sensor configuration, such as the assignment of RX or TX is physically connected to wrong pin on the MSP.  Can you send me your USER_Config.c and .h files?  Also, can you share a schematic showing the connections from the MSP to the sensor(s)?  If you don't want to post your schematic, send me a "friendship request" and you can share with me privately.

  • Please find attached source code files. I have taken schematic referenced from TI Designs: TIDM-1021
    Liquid Tolerant Capacitive Touch Keypad Design. Attaching schematic for the same.5516.Schematic.pdf

    /* --COPYRIGHT--,BSD
     * Copyright (c) 2017, 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.
     * --/COPYRIGHT--*/
    
    
    // Generated by Captivate Design Center v1_83_00_08 on Mon Jun 16 20:12:05 IST 2025
    
    
    //*****************************************************************************
    // CAPT_UserConfig.c
    //
    // \version 1.83.00.05
    // Released on May 15, 2020
    //
    //*****************************************************************************
    
    //*****************************************************************************
    //
    // NOTE: This is an automatically generated source code file!  The Captivate
    // Design Center generates the User Configuration file automatically based
    // upon the sensor layout that was created.
    //
    // Changes to this file will be OVERWRITTEN if a you select
    // "Update Existing Project" under "Generate Source Code" in the Design Center.
    //
    // To avoid interference with the code generation process, keep ALL application
    // code external to this file.
    //
    //*****************************************************************************
    
    #include "CAPT_UserConfig.h"
    
    //*****************************************************************************
    //
    //! Captivate Element Definitions
    //! All elements in this application are defined below.
    //! Each element has 3 components:
    //!  1) a raw count array (One index per freq. scanned) (uint16_t)
    //!  2) a tuning array (One index per freq. scanned) (tCaptivateElementTuning)
    //!  3) a element structure (tElement)
    //
    //*****************************************************************************
    // Sensor: KeypadSensor, Element: E03
    uint16_t KeypadSensor_E03_RawCnts[CAPT_MUTUAL_FREQ_CNT];
    tCaptivateElementTuning KeypadSensor_E03_Tuning[CAPT_MUTUAL_FREQ_CNT];
    tElement KeypadSensor_E03 =
    {
        .ui8TxPin = 1,
        .ui8TxBlock = 0,
        .ui8RxPin = 0,
        .ui8RxBlock = 3,
        .ui8TouchThreshold = 10,
        .pRawCount = KeypadSensor_E03_RawCnts,
        .pTuning = KeypadSensor_E03_Tuning,
    };
    
    // Sensor: KeypadSensor, Element: E04
    uint16_t KeypadSensor_E04_RawCnts[CAPT_MUTUAL_FREQ_CNT];
    tCaptivateElementTuning KeypadSensor_E04_Tuning[CAPT_MUTUAL_FREQ_CNT];
    tElement KeypadSensor_E04 =
    {
        .ui8TxPin = 1,
        .ui8TxBlock = 0,
        .ui8RxPin = 0,
        .ui8RxBlock = 2,
        .ui8TouchThreshold = 10,
        .pRawCount = KeypadSensor_E04_RawCnts,
        .pTuning = KeypadSensor_E04_Tuning,
    };
    
    // Sensor: KeypadSensor, Element: E02
    uint16_t KeypadSensor_E02_RawCnts[CAPT_MUTUAL_FREQ_CNT];
    tCaptivateElementTuning KeypadSensor_E02_Tuning[CAPT_MUTUAL_FREQ_CNT];
    tElement KeypadSensor_E02 =
    {
        .ui8TxPin = 1,
        .ui8TxBlock = 0,
        .ui8RxPin = 1,
        .ui8RxBlock = 3,
        .ui8TouchThreshold = 10,
        .pRawCount = KeypadSensor_E02_RawCnts,
        .pTuning = KeypadSensor_E02_Tuning,
    };
    
    // Sensor: KeypadSensor, Element: E05
    uint16_t KeypadSensor_E05_RawCnts[CAPT_MUTUAL_FREQ_CNT];
    tCaptivateElementTuning KeypadSensor_E05_Tuning[CAPT_MUTUAL_FREQ_CNT];
    tElement KeypadSensor_E05 =
    {
        .ui8TxPin = 1,
        .ui8TxBlock = 0,
        .ui8RxPin = 1,
        .ui8RxBlock = 2,
        .ui8TouchThreshold = 10,
        .pRawCount = KeypadSensor_E05_RawCnts,
        .pTuning = KeypadSensor_E05_Tuning,
    };
    
    // Sensor: KeypadSensor, Element: E00
    uint16_t KeypadSensor_E00_RawCnts[CAPT_MUTUAL_FREQ_CNT];
    tCaptivateElementTuning KeypadSensor_E00_Tuning[CAPT_MUTUAL_FREQ_CNT];
    tElement KeypadSensor_E00 =
    {
        .ui8TxPin = 1,
        .ui8TxBlock = 0,
        .ui8RxPin = 2,
        .ui8RxBlock = 2,
        .ui8TouchThreshold = 10,
        .pRawCount = KeypadSensor_E00_RawCnts,
        .pTuning = KeypadSensor_E00_Tuning,
    };
    
    // Sensor: KeypadSensor, Element: E01
    uint16_t KeypadSensor_E01_RawCnts[CAPT_MUTUAL_FREQ_CNT];
    tCaptivateElementTuning KeypadSensor_E01_Tuning[CAPT_MUTUAL_FREQ_CNT];
    tElement KeypadSensor_E01 =
    {
        .ui8TxPin = 1,
        .ui8TxBlock = 0,
        .ui8RxPin = 2,
        .ui8RxBlock = 3,
        .ui8TouchThreshold = 10,
        .pRawCount = KeypadSensor_E01_RawCnts,
        .pTuning = KeypadSensor_E01_Tuning,
    };
    
    // Sensor: KeypadSensor, Element: E06
    uint16_t KeypadSensor_E06_RawCnts[CAPT_MUTUAL_FREQ_CNT];
    tCaptivateElementTuning KeypadSensor_E06_Tuning[CAPT_MUTUAL_FREQ_CNT];
    tElement KeypadSensor_E06 =
    {
        .ui8TxPin = 1,
        .ui8TxBlock = 0,
        .ui8RxPin = 3,
        .ui8RxBlock = 2,
        .ui8TouchThreshold = 10,
        .pRawCount = KeypadSensor_E06_RawCnts,
        .pTuning = KeypadSensor_E06_Tuning,
    };
    
    
    //*****************************************************************************
    //
    //! Captivate Time Cycle Definitions
    //! All time cycles in this application are defined below.  Time cycles are
    //! groups of elements that are measured together in parallel in one time slot.
    //! Each cycle has 2 components:
    //!  1) an element pointer array to the member elements (tElement*)
    //!  2) a cycle structure (tCycle)
    //
    //*****************************************************************************
    // Time Cycle: KeypadSensor_C00
    tElement* KeypadSensor_C00_Elements[2] =
    {
        &KeypadSensor_E03,
        &KeypadSensor_E04,
    };
    tCycle KeypadSensor_C00 =
    {
        .ui8NrOfElements = 2,
        .pElements = KeypadSensor_C00_Elements,
    };
    
    // Time Cycle: KeypadSensor_C01
    tElement* KeypadSensor_C01_Elements[2] =
    {
        &KeypadSensor_E02,
        &KeypadSensor_E05,
    };
    tCycle KeypadSensor_C01 =
    {
        .ui8NrOfElements = 2,
        .pElements = KeypadSensor_C01_Elements,
    };
    
    // Time Cycle: KeypadSensor_C02
    tElement* KeypadSensor_C02_Elements[2] =
    {
        &KeypadSensor_E00,
        &KeypadSensor_E01,
    };
    tCycle KeypadSensor_C02 =
    {
        .ui8NrOfElements = 2,
        .pElements = KeypadSensor_C02_Elements,
    };
    
    // Time Cycle: KeypadSensor_C03
    tElement* KeypadSensor_C03_Elements[1] =
    {
        &KeypadSensor_E06,
    };
    tCycle KeypadSensor_C03 =
    {
        .ui8NrOfElements = 1,
        .pElements = KeypadSensor_C03_Elements,
    };
    
    
    //*****************************************************************************
    //
    //! Captivate Sensor Definitions
    //! All sensors in this application are defined below.  Sensors are
    //! groups of time cycles that utilize raw measurement data to create an
    //! abstract sensor type, such as a button, slider, wheel, or prox sensor.
    //! Each sensor has 3 components:
    //!  1) a cycle pointer array to the member time cycles (tCycle*)
    //!  2) a sensor-specific parameter structure (tGenericSensorParams)
    //!  3) a sensor structure (tSensor)
    //
    //*****************************************************************************
    //Sensor: KeypadSensor
    const tCycle* KeypadSensor_Cycles[4] =
    {
        &KeypadSensor_C00,
        &KeypadSensor_C01,
        &KeypadSensor_C02,
        &KeypadSensor_C03,
    };
    
    tButtonSensorParams KeypadSensor_Params;
    tSensor KeypadSensor =
    {
        // Basic Properties
        .TypeOfSensor = eButtonGroup,
        .SensingMethod = eProjected,
        .DirectionOfInterest = eDOIUp,
        .pvCallback = NULL,
        .ui8NrOfCycles = 4,
        .pCycle = KeypadSensor_Cycles,
        .pSensorParams = (tGenericSensorParams*)&KeypadSensor_Params,
        // Conversion Control Parameters
        .ui16ConversionCount = 500,
        .ui16ConversionGain = 100,
        .ui8FreqDiv = 2,
        .ui8ChargeLength = 0,
        .ui8TransferLength = 0,
        .bModEnable = false,
        .ui8BiasControl = 3,
        .bCsDischarge = true,
        .bLpmControl = false,
        .ui8InputSyncControl = 0,
        .bTimerSyncControl = false,
        .bIdleState = true,
        // Tuning  Parameters
        .ui16ProxThreshold = 25,
        .ui16NegativeTouchThreshold = 30,
        .ui16ErrorThreshold = 8191,
        .ui16TimeoutThreshold = 65535,
        .ProxDbThreshold.DbIn = 1,
        .ProxDbThreshold.DbOut = 0,
        .TouchDbThreshold.DbIn = 1,
        .TouchDbThreshold.DbOut = 0,
        .bCountFilterEnable = true,
        .ui8CntBeta = 1,
        .bSensorHalt = false,
        .bPTSensorHalt = true,
        .bPTElementHalt = true,
        .ui8LTABeta = 7,
        .bReCalibrateEnable = true,
    };
    
    
    #if (CAPT_CONDUCTED_NOISE_IMMUNITY_ENABLE==true)
    //*****************************************************************************
    //
    //! \var g_EMCConfig
    //! This structure stores the EMC configuration for this application.
    //
    //*****************************************************************************
    const tEMCConfig g_EMCConfig =
    {
    	// Conversion Style
    	.selfModeConversionStyle = CAPT_SELF_MODE_CONVERSION_STYLE,
    	.projModeConversionStyle = CAPT_PROJ_MODE_CONVERSION_STYLE,
    	
    	// Oversampling Style
    	.selfModeOversamplingStyle = CAPT_SELF_MODE_OVERSAMPLING_STYLE,
    	.projModeOversamplingStyle = CAPT_PROJ_MODE_OVERSAMPLING_STYLE,
    	
    	// Jitter Filter Enable
    	.bJitterFilterEnable = true,
    	
    	// Noise Thresholds and Calibration Noise Limits
    	.ui8NoiseThreshold = CAPT_NOISE_THRESHOLD,
    	.ui16CalibrationNoiseLimit = CAPT_CALIBRATION_NOISE_LIMIT,
    	.ui8CalibrationTestSampleSize = 8,
    		
    	// Dynamic Threshold Adjustment Parameters
    	.bEnableDynamicThresholdAdjustment = CAPT_DYNAMIC_THRESHOLD_ADJUSTMENT,
    	.ui8MaxRelThreshAdj = 76,
    	.ui8NoiseLevelFilterEntryThresh = 40,
    	.ui8NoiseLevelFilterExitThresh = 0,
    	.ui8NoiseLevelFilterDown = 6,
    	.ui8NoiseLevelFilterUp = 1,
    	.coeffA = _IQ31(0.0065),
    	.coeffB = _IQ31(0.050)
    };
    #endif
    
    //*****************************************************************************
    //
    //! \var g_pCaptivateSensorArray
    //! This array allows for indexed access to any
    //! sensor in the configuration.
    //
    //*****************************************************************************
    tSensor* g_pCaptivateSensorArray[CAPT_SENSOR_COUNT] =
    {
        &KeypadSensor,
    };
    
    
    //*****************************************************************************
    //
    //! \var g_uiApp
    //! This structure stores the global settings for this application.
    //
    //*****************************************************************************
    tCaptivateApplication g_uiApp =
    {
        .state = eUIActive,
    	.pSensorList = &g_pCaptivateSensorArray[0],
        .ui8NrOfSensors = CAPT_SENSOR_COUNT,
        .ui8AppLPM = CAPT_LOW_POWER_MODE,
        .bElementDataTxEnable = true,
        .bSensorDataTxEnable = true,
        .ui16ActiveModeScanPeriod = 33,
        .ui16WakeOnProxModeScanPeriod = 100,
        .ui16InactivityTimeout = 32,
        .ui8WakeupInterval = 5,
    };
    
    3858.CAPT_UserConfig.h

  • But with the same configuration and importing code generated by Captivate Design Center everything works fine. Can please explain this unusual behavior.

  • Hi Mithilesh,

    Ok, now I"m seeing some differences.  You indicated you are basing your design on the schematic in TIDM-1021, which is a 12-button "mutual mode" capacitive design.

    I have taken schematic referenced from TI Designs: TIDM-1021
    Liquid Tolerant Capacitive Touch Keypad Design.

    I see from your CAPT_UserConfig.c file, which I assume you generated from the Captivate GUI for your project, that it uses 7 mutual cap buttons. Earlier you indicated a 12-button "self cap mode" so I just want to align on your design.

    There are 12 buttons configured in self-capacitance mode.

    Can you send me your Captivate Project file, .ser?

**Attention** This is a public forum