Hi everyone,
I would like to know if it's possible to dynamicaly set the capacitive touch parameters of my MSP430, ie conversion count, proximity and touch thresholds. I tried to set parameters as noinit so I can change the value and keep it in persitent memory (a method I use for another parameter), but I've got an error "#28 expression must have a constant value".
I'm pretty sure it is possible to change those value while the MSP is running, as it's what we do when we use Captivate Design Center tool to calibrate the touch sensors.
Any help on this would be very appreciated.
Best regards,
Yoann
#include "CAPT_UserConfig.h"
#pragma NOINIT(conv_count)
uint16_t conv_count;
#pragma NOINIT(prox_threshold)
uint16_t prox_threshold;
#pragma NOINIT(touch_threshold)
uint16_t touch_threshold;
//*****************************************************************************
//
//! 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: PRX01, Element: E00
uint16_t PRX01_E00_RawCnts[CAPT_SELF_FREQ_CNT];
tCaptivateElementTuning PRX01_E00_Tuning[CAPT_SELF_FREQ_CNT];
tElement PRX01_E00 =
{
.ui8RxPin = 0,
.ui8RxBlock = 1,
.ui8TouchThreshold = touch_threshold,
.pRawCount = PRX01_E00_RawCnts,
.pTuning = PRX01_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: PRX01_C00
tElement* PRX01_C00_Elements[1] =
{
&PRX01_E00,
};
tCycle PRX01_C00 =
{
.ui8NrOfElements = 1,
.pElements = PRX01_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: PRX01
const tCycle* PRX01_Cycles[1] =
{
&PRX01_C00,
};
tProxSensorParams PRX01_Params =
{
.pSensor = NULL,
.ui8NumberOfSensors = 0,
};
tSensor PRX01 =
{
// Basic Properties
.TypeOfSensor = eProx,
.SensingMethod = eSelf,
.DirectionOfInterest = eDOIDown,
.pvCallback = NULL,
.ui8NrOfCycles = 1,
.pCycle = PRX01_Cycles,
.pSensorParams = (tGenericSensorParams*)&PRX01_Params,
// Conversion Control Parameters
.ui16ConversionCount = conv_count,
.ui16ConversionGain = 200,
.ui8FreqDiv = 2,
.ui8ChargeLength = 0,
.ui8TransferLength = 0,
.bModEnable = false,
.ui8BiasControl = 3,
.bCsDischarge = true,
.bLpmControl = false,
.ui8InputSyncControl = 0,
.bTimerSyncControl = false,
.bIdleState = true,
// Tuning Parameters
.ui16ProxThreshold = prox_threshold,
.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,
};