MSP430™CapTIvateSoftwareLibraryAPIGuide 1_70_00_03

Macros | Functions
CAPT_EMC

EMC plug-ins for enhanced noise immunity. More...

## Macros
#define | CAPT_EMC_STDFREQ_CNT (0x01)
#define | CAPT_EMC_MULTIFREQ_CNT (0x04)
#define | CAPT_EMC_SAMPLE_ERROR_CODE (0x00000)

## Functions
bool | CAPT_loadEMCConfig (const tEMCConfig *pConfig)
uint16_t | CAPT_getGlobalFilteredNoiseLevel (void)
void | CAPT_resetGlobalFilteredNoiseLevel (void)
void | CAPT_updateGlobalFilteredNoiseLevel (tElement *pElement, uint16_t ui16RelNoiseLevel)
void | CAPT_getEMCConversionSettings (tSenseTechnology method, tRawConversionStyle *pConversion, tOversamplingStyle *pOversampling)
uint8_t | CAPT_getRelNoiseStatusThreshold (void)
| Get the relative noise threshold parameter. More...
uint8_t | CAPT_getMaxRelThreshold (void)
bool | CAPT_testConversionFrequencyForNoise (tSensor *pSensor, uint8_t ui8Freq)
bool | CAPT_correctInvalidMultiFreqCalibration (tSensor *pSensor, uint8_t ui8NoiseMask)
void | CAPT_replaceFrequencyWithError (uint16_t *pNewSet, uint16_t ui16Replacement)
void | CAPT_resolveMultiFreqSet (const uint16_t *pNewSet, uint16_t *pResult, uint16_t *pNoiseLevel, bool bRemoveOutlier)
uint16_t | CAPT_computeJitterFilter (uint16_t ui16Prev, uint16_t ui16Curr)
| This function applies a basic single-level jitter filter to a sample. More...
uint8_t | CAPT_computeRelNoiseComp (void)

## Detailed Description

EMC plug-ins for enhanced noise immunity.

The EMC software module of the Captivate touch library provides a set of utilities that aid in designing for electromagnetic compatibility (EMC). These functions work together with the Captivate peripheral to provide a high level of immunity to conducted/radiated RF disturbances, EFT, and ESD transients.

Version
  VERSION Released on RELEASE_DATE

## Macro Definition Documentation

## § CAPT_EMC_STDFREQ_CNT

#define CAPT_EMC_STDFREQ_CNT (0x01)

## § CAPT_EMC_MULTIFREQ_CNT

#define CAPT_EMC_MULTIFREQ_CNT (0x04)

## § CAPT_EMC_SAMPLE_ERROR_CODE

#define CAPT_EMC_SAMPLE_ERROR_CODE (0x00000)

## Function Documentation

## § CAPT_loadEMCConfig()

bool CAPT_loadEMCConfig | ( | const tEMCConfig * | pConfig | ) |

Use this function to load an EMC configuration. This must be done prior to using the EMC layer. When a new EMC configuration is loaded, the the internal global noise level and highest noise element variables are both reset. If a null pointer is passed, the function will not adjust any variables and will exit leaving the existing configuration. The EMC configuration is a tEMCConfig structure that defines how the EMC layer processes data. The structure is defined in CAPT_Type.h.

Parameters

  pRawSet | is a pointer to the source data memory

Returns
  true if a valid pointer was passed, else false.

## § CAPT_getGlobalFilteredNoiseLevel()

uint16_t CAPT_getGlobalFilteredNoiseLevel | ( | void |  | ) |

Use CAPT_getGlobalFilteredNoiseValue() to retrieve the global filtered noise value. This value stores an aggregate noise level for all self-capacitance elements when bDynamicThresholdAdjustmentIsGlobal is true.

Parameters

  none |

Returns
  the global filtered noise value, expressed as a % of the LTA of any given sensor, with 0=0% and 128=100%

## § CAPT_resetGlobalFilteredNoiseLevel()

void CAPT_resetGlobalFilteredNoiseLevel | ( | void |  | ) |

Use CAPT_resetGlobalFilteredNoiseLevel() to seed the global filtered noise value to zero, effectively resetting it.

Parameters

  none |

Returns
  none

## § CAPT_updateGlobalFilteredNoiseLevel()

void CAPT_updateGlobalFilteredNoiseLevel | ( | tElement * | pElement,
|  | uint16_t | ui16RelNoiseLevel
| ) |  |

Use CAPT_updateGlobalFilteredNoiseLevel() to update the global filtered noise level based on a channel's noise level.

If the new noise level is above the current global value, the "up" direction filter beta will be applied; otherwise, the "down" direction filter beta will be applied.

Additionally, if the new noise level is "up" going and the new value is below the noise level filter entry threshold, no filtering will be applied. Likewise, if the new noise level is "down" going and the new value is below the noise level filter exit threshold, the filter will not be applied. This is to speed response to quick, drastic changes in values.

To maintain a valid global level when only one element is being interacted with, whenever a new high point is established the address of that data point (effectively the corresponding sensing element) will be stored. Then, only that data point is allowed to decrease the global value unless the global value is reset manually.

Parameters

  pElement | is the address of the element
  ui16RelNoiseLevel | is the new relative noise level

Returns
  none

## § CAPT_getEMCConversionSettings()

void CAPT_getEMCConversionSettings | ( | tSenseTechnology | method,
|  | tRawConversionStyle * | pConversion,
|  | tOversamplingStyle * | pOversampling
| ) |  |

Get the raw conversion style and oversampling style that are specified for an EMC conversion in self or projected mode.

Parameters

  method | is the sensing method to query
  pConversion | is a pointer to the location to store the raw conversion style
  pOversampling | is a pointer to the location to store the oversampling style.

Returns
  none

## § CAPT_getRelNoiseStatusThreshold()

uint8_t CAPT_getRelNoiseStatusThreshold | ( | void |  | ) |

Get the relative noise threshold parameter.

Parameters

  none |

Returns
  the relative noise threshold

## § CAPT_getMaxRelThreshold()

uint8_t CAPT_getMaxRelThreshold | ( | void |  | ) |

Get the maximum relative threshold parameter, as specified in the EMC configuration structure that is currently loaded. This may be used for bounds checks on adjusted thresholds by external functions.

Parameters

  none |

Returns
  the maximum relative threshold allowed

## § CAPT_testConversionFrequencyForNoise()

bool CAPT_testConversionFrequencyForNoise | ( | tSensor * | pSensor,
|  | uint8_t | ui8Freq
| ) |  |

This function will test a frequency for noise and return true if noise is detected. All elements in the sensor will be scanned at the requested frequency to determine if noise is present. The number of samples measured as well as the noise threshold used to determine the presence of noise may be adjusted in the EMC configuration structure via the ui8CalibrationTestSampleSize and ui16CalibrationNoiseLimit parameters, respectively.

Parameters

  pSensor | is a pointer to the sensor to test
  ui8Freq | is the frequency to test

Returns
  true if noise was detected, else false

## § CAPT_correctInvalidMultiFreqCalibration()

bool CAPT_correctInvalidMultiFreqCalibration | ( | tSensor * | pSensor,
|  | uint8_t | ui8NoiseMask
| ) |  |

This function will correct invalid calibration parameters for a given sensor based on the noise mask that is passed. BIT0 through BIT3 in the passed ui8NoiseMask indicate that noise is present on FREQ0 to FREQ3, respectively. If a frequency is marked as noisy, its calibration values are automatically considered to be invalid and are replaced with the next closest valid values. If no valid values are available to correct a frequency, the invalid values are left alone and the function returns true to indicate that no corrections were made. This would happen if noise was present on all frequencies.

Parameters

  pSensor | is a pointer to the sensor to correct
  ui8NoiseMask | is a bit mask of frequencies that have noise.

Returns
  true if the calibration values were not modified because all had noise, else false.

## § CAPT_replaceFrequencyWithError()

void CAPT_replaceFrequencyWithError | ( | uint16_t * | pNewSet,
|  | uint16_t | ui16Replacement
| ) |  |

This function inspects the new set of sample results at different conversion frequencies and if an error code is found (max count error), that frequency is replaced with the passed replacement value. Only one frequency will be corrected.

Parameters

  pNewSet | is a pointer to the new raw data set. Four words are expected at this location.
  ui16Replacement | is the value to replace any error codes with.

Returns
  none

## § CAPT_resolveMultiFreqSet()

void CAPT_resolveMultiFreqSet | ( | const uint16_t * | pNewSet,
|  | uint16_t * | pResult,
|  | uint16_t * | pNoiseLevel,
|  | bool | bRemoveOutlier
| ) |  |

This function resolves a set of conversions done in series at different conversion frequencies into a single conversion result.

Parameters

  pNewSet | is a pointer to the new raw data set. Four words are expected at this location.
  pResult | is a pointer indicating the memory location to store the output of the algorithm
  pNoiseLevel | is a pointer indicating the memory location to store the level of noise in the raw set. The noise level is calculated as max-min.
  bRemoveOutlier | tells the function to remove the outlier from the sample set.

Returns
  none

## § CAPT_computeJitterFilter()

uint16_t CAPT_computeJitterFilter | ( | uint16_t | ui16Prev,
|  | uint16_t | ui16Curr
| ) |  |

This function applies a basic single-level jitter filter to a sample.

Parameters

  ui16Prev | is the current natural count value.
  ui16Curr | is the new raw count value to filter in.

Returns
  The new, filtered value.

## § CAPT_computeRelNoiseComp()

uint8_t CAPT_computeRelNoiseComp | ( | void |  | ) |

This function computes the amount of threshold compensation to apply to an element. The noise level passed will be used as the input to determine the amount of threshold compensation to apply. If the global noise setting (bDynamicThresholdAdjustmentIsGlobal) is true, and the global noise value is higher than the passed noise level, the global noise reference will be used to compute the threshold compensation.

Parameters

  ui8NoiseLevel | specifies the relative noise level to adjust for, based on a 1/128 scale.

Returns
  The amount to adjust the threshold by.

© Copyright 1995-2018, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale