大家好!
我想知道是否可以通过授权来设置 MSP430的电容式触控参数、即转换计数、接近和触控阈值。 我试图将参数设置为 noinit、以便我可以更改该值并将其保存在超常存储器中(我用于另一个参数的方法)、但收到错误"#28表达式必须具有常数值"。
我非常确信可以在 MSP 运行时更改这些值、因为这正是我们使用 CapTIvate 设计中心工具来校准触控传感器时所要做的。
非常感谢在这方面提供任何帮助。
此致、
约安
#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,
};