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: Temporarily Turn off appHandler

Part Number: MSP430FR2633
Other Parts Discussed in Thread: CAPTIVATE-FR2633

Hello, 

I am trying to execute a simple function when CAPT_appHandler() has been triggered from proximity sense, otherwise appSleep.

The function takes about a few seconds to execute, but it repeats well after the proximity trigger has been removed.  I assumed that I must turn off the proximity sensor until the function execution is complete. 

Using the example in this link: https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/811708/msp430fr2633-don-t-call-capt_apphandler-for-500ms
I stopped and cleared the timer right after CAPT_appHandler() == true, performed the function, and re-started the timer before the end of the if-true loop.

However, the function is still occurring multiple times. 

How should I properly stop the appHandler, execute command, and resume the appHandler without multiple executions?

Thank you,

Tom

  • Hi Tom,

    I don't get your point for this thread, you would like to disable CAPT_appHandler() function? 

    Just use MAP_CAPT_stopTimer(); is OK I think.

    Thanks!

    Best Regards

    Johnson

  • Hi Johnson, 

    I appreciate your response.  My apologies if my question is unclear to you, please allow me to elaborate.

    Here's my code starting from "CAPT_appStart()"    (just pin definitions prior): 

     CAPT_appStart();

        while(1)
        {

            if(CAPT_appHandler()==true) //proximity detection triggered
              {
                MAP_CAPT_stopTimer(); //temporarily halt the timer
                MAP_CAPT_clearTimer();
               

               //Blink LED two times

                P1OUT |= BIT7;                                             // Set P1.7 LED on


                 __delay_cycles(30000000);                         //delay


                P1OUT &= ~BIT7;                                         // Clear P1.7 LED off

                __delay_cycles(30000000);                         //delay


                P1OUT |= BIT7;                                             // Set P1.7 LED on


                 __delay_cycles(30000000);                         //delay


                P1OUT &= ~BIT7;                                         // Clear P1.7 LED off
                

                MAP_CAPT_startTimer();                             //resume the scanner

                }


            else

               {
                P1OUT &= ~BIT7;                                           // Clear P1.7 LED
               }


            __no_operation();


            CAPT_appSleep();

        } 

    As you can see, the function is very simple - just blink the LED 2 times whenever proximity detection occurs.

    However, when I introduce an object to trigger the proximity momentarily, the function to blink the LED 2 times repeat multiple times. 

    The sequence is: 

    1) Introduce object in proximity

    2) LED turns on

    3) remove the object in proximity

    4) LED turns off, but continues to blink multiple times even without object in proximity.

    The "MAP_CAPT_...." commands are added in an attempt to have the blinking of the LED 2 times only occur one time and doesn't repeat. But it is still happening multiple times.

    What is the best way to solve this phenomenon?  Let me know if you need more information.

    Thanks!

    Tom

  • Hi Tom,

    Sorry I missed this case, Could you share code here? I can do some test and try find root cause in my side when I back to office(May.4)

    Thanks!

    Best Regards

    Johnson

  • Hi Johnson,

    No problem. 

    I've already shared my code above, but I'll share it again with the entire main.c

    #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


    void main(void)
    {
        WDTCTL = WDTPW | WDTHOLD;
        BSP_configureMCU();
        __bis_SR_register(GIE);

        // pin initializations
        //-------------------------------------------------------------------------------------------------------------------------------------
        P1DIR |= BIT7;            // Set P1.7 - LED_EN to output direction
        P1OUT &= ~BIT7;           // P1.7 LED off

        //
        // Start the CapTIvate application
        //
        CAPT_appStart();

        while(1)
        {

            if(CAPT_appHandler()==true)
              {

                MAP_CAPT_clearTimer();

                P1OUT |= BIT7;  // Set P1.7 LED on

                __delay_cycles(30000000);                         //delay

                P1OUT &= ~BIT7; // Clear P1.7 LED off

                MAP_CAPT_stopTimer();

                MAP_CAPT_startTimer(); //resume the scanner

                }


            else
                P1OUT &= ~BIT7; // Clear P1.7 LED

            __no_operation();


            CAPT_appSleep();

        } // End background loop
    } // End main()

    I think the issue have something to do with the delay line "_delay_cycles(30000000)".  

    I attached the board to the Captivate program and attached the videos. 

    I set the threshold to be 100. As you can see, without the delay, the sensitivity works just fine. 

    I think that with the delay, the capacitance doesn't get a chance to fully reset so it triggers the event again.

  • The "Delay" video is me triggering the sensor only once. The "No Delay" video is me triggering the sensor 3 times

  • Hi Shiwei,

    Could you tell me which hardware you used? I can try your code in my side when I back to Officr(May.4).

    Thanks!

    Best Regards

    Johnson

  • Hi Johnson, 

    This may not be very helpful but I am using a custom PCBA with MSP430FR2633 chip. 
    Please let me know what other information you need.

    In the meantime, I'll see if I can reproduce the same phenomenon on the CAPTIVATE-FR2633 Dev Kit and share that code. 

    Thanks,

    Tom

  • Hi Johnson, 

    I can re-produce the same phenomenon on the CAPTIVATE-FR2633 Dev kit using the same code above. 

    Here's the code for my CAPT_UserConfig.c file (everything else is unchanged from default).   I am using  CAP3.1 as the sensor pin.


    //*****************************************************************************
    // 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: BTN00, Element: E00
    uint16_t BTN00_E00_RawCnts[CAPT_SELF_FREQ_CNT];
    tCaptivateElementTuning BTN00_E00_Tuning[CAPT_SELF_FREQ_CNT];
    tElement BTN00_E00 =
    {
    .ui8RxPin = 1, 
    .ui8RxBlock = 3,
    .ui8TouchThreshold = 10, 
    .pRawCount = BTN00_E00_RawCnts,
    .pTuning = BTN00_E00_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: BTN00_C00
    tElement* BTN00_C00_Elements[1] =
    {
    &BTN00_E00,
    };
    tCycle BTN00_C00 =
    {
    .ui8NrOfElements = 1,
    .pElements = BTN00_C00_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: BTN00
    const tCycle* BTN00_Cycles[1] =
    {
    &BTN00_C00,
    };

    tButtonSensorParams BTN00_Params;
    tSensor BTN00 =
    {
    // Basic Properties
    .TypeOfSensor = eButtonGroup,
    .SensingMethod = eSelf,
    .DirectionOfInterest = eDOIDown,
    .pvCallback = NULL,
    .ui8NrOfCycles = 1,
    .pCycle = BTN00_Cycles,
    .pSensorParams = (tGenericSensorParams*)&BTN00_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 = 10, 
    .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] =
    {
    &BTN00,
    };


    //*****************************************************************************
    //
    //! \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,
    };

    Please let me know if you need anything else, thanks again for your help.

    Tom

  • Hi Tom,

    Got it, I will test your code and back soon.

    Thanks!

    Best Regards

    Johnson

  • Hi Johnson, 

    Thank you so much, I look forward to hearing from you!

    I'm just using a solid 22AWG wire in the CAP3.1 port on J10 of the dev kit. Once again, I'm trying to avoid the repeated occurrence of the event (only happen 1 time per trigger). Please let me know if you need anything else.

    Thanks,

    Tom

  • Hi Shiwei,

    I found the root cause, this is cause by captivate filter function:

    please try to change the below parameter and test again:
    1: disable counter filter function.

    2: change Threshold.DbIn and Threshold.DbOut to 0.

    I did some test in my side, after changed those two contents, the function is normal, attach my test code:

    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)
            {
                MAP_CAPT_stopTimer();
                MAP_CAPT_clearTimer();
    
                LED2_ON;
                __delay_cycles(30000000);
                LED2_OFF;
                __delay_cycles(30000000);
                LED2_ON;
                __delay_cycles(30000000);
                LED2_OFF;
                __delay_cycles(30000000);
    
                MAP_CAPT_startTimer();
            }
    		else
    			LED2_OFF;
    		LED1_OFF;
    		
    		//
    		// 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()

    Thanks!

    Best Regards

    Johnson

  • Hi Johnson, 

    This indeed solved the problem, thank you so much!

    Tom

**Attention** This is a public forum