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.

[参考译文] MSP430FR2675:电容式触控动态参数

Guru**** 2481075 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/1285264/msp430fr2675-dynamic-parameters-for-capacitive-touch

器件型号:MSP430FR2675

大家好!

我想知道是否可以通过授权来设置 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,
};

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Yoann:

    有两种方法:一种是直接访问传感器结构中的成员。 另一个是间接使用指针。

    在代码示例中、我在回调函数中展示了这两种方法。  当然、如果您需要、您可以做到这一点。

    /* Direct access
     * Must use extern in the file you wish to access the sensor struct 
     */
    extern tSensor keypadSensor;
    void Demo_keypadSensorHandler(tSensor* pSensor)
    {
        uint16_t conversionCount;
        
        /* Direct access */
        conversionCount = keypadSensor.ui16ConversionCount;
    }
    
    /* Indirect access */
    void Demo_keypadSensorHandler(tSensor* pSensor)
    {
        uint16_t conversionCount;
    
        /* Indirect access using pointer */
        conversionCount = pSensor->ui16ConversionCount;
    
    }
    

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Dennis、

    感谢您的回答、但很抱歉、我是想动态设置、而不是获取触摸参数。

    为了告诉您有关我的应用的更多信息、我们有多个产品使用相同的 PCB、由于它们在机械学上的差异、校准和触摸参数也不相同。 我想在我的产品上使用一个通用的软件、只需在将代码刷写到 MSP 后提供参数。

    如果我不清楚、请告诉我。

    约安

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    好的、然后设置传感器的转换计数或增益或阈值 、例如、您只需按如下所示反转分配、然后分配所需的任何值。

       pSensor->ui16ConversionCount = 250;
       pSensor->ui16ConversionGain = 100;
       pSensor->ui16ProxThreshold = 10;
       pSensor -> ui16TouchThreshold = 25;

    等等...

    这是否合理、还是我仍未得到您所问的内容?

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Denis:

    谢谢,我觉得有点愚蠢,看到解决方案是如此简单。 它运行得非常好! 所以知道我将能够动态地调整我的触摸参数,谢谢你:)

    祝你度过美好的一天!

    约安