Microchip® Advanced Software Framework

thirdparty/qtouch/devspecific/uc3/uc3l0/examples/example_at/touch_config_at32uc3l.h File Reference

Macros

#define AT_SP_SELECTED   (SP15)
 Autonomous QTouch Clock dependency note: The Example application uses a PBA clock of 48MHz. More...
 
#define SET_PIN(x)   (1u << (x))
 
Acquisition method manifest constants.

The following constants can be used to select the desired Touch acquisition methods to be used with the UC3L QTouch Library. Choose QMatrix, Autonomous QTouch, QTouch Group A and QTouch Group B methods by setting the corresponding macro to 1. It is possible for the QTouch Library to support one or more acquisition methods at the same time. For example, in order to use QMatrix and Autonomous QTouch acquisition methods at the same time, both DEF_TOUCH_QMATRIX and DEF_TOUCH_AUTONOMOUS_QTOUCH macros must be set to 1.

#define DEF_TOUCH_QMATRIX   (0)
 
#define DEF_TOUCH_AUTONOMOUS_QTOUCH   (1)
 
#define DEF_TOUCH_QTOUCH_GRP_A   (0)
 
#define DEF_TOUCH_QTOUCH_GRP_B   (0)
 
#define DEF_TOUCH_QDEBUG_ENABLE_QM   (0)
 Enable/Disable QDebug for touch debug information communication with QTouch Studio PC Software. More...
 
#define DEF_TOUCH_QDEBUG_ENABLE_AT
 
#define DEF_TOUCH_QDEBUG_ENABLE_QTA   (0)
 
#define DEF_TOUCH_QDEBUG_ENABLE_QTB   (0)
 
#define DEF_TOUCH_QDEBUG_ENABLE
 
Autonomous QTouch Clock and Register Configuration Options.
#define AT_CAT_CLK_DIV   (23u)
 Autonomous QTouch burst timing clock Divider. More...
 
#define AT_CHLEN   (2u)
 Autonomous QTouch Charge Length For Autonomous QTouch sensor, specifies how many burst prescaler clock cycles should be used for transferring charge to the sense capacitor. More...
 
#define AT_SELEN   (1u)
 Autonomous QTouch Settle Length. More...
 
#define AT_DILEN   (255u)
 Autonomous QTouch Discharge Length. More...
 
#define AT_DISHIFT   (0u)
 Autonomous QTouch Discharge Shift. More...
 
#define AT_MAX_ACQ_COUNT   (3000u)
 Autonomous QTouch Maximum Count. More...
 
#define AT_ENABLE_SPREAD_SPECTRUM   (1u)
 Autonomous QTouch Spread Spectrum Sensor Drive. More...
 
#define AT_ENABLE_EXTERNAL_SYNC   (0u)
 Autonomous QTouch External synchronization to reduce 50 or 60 Hz mains interference. More...
 
#define AT_FILTER   (2u)
 Autonomous Touch Filter Setting. More...
 
#define AT_OUTSENS   (8u)
 Autonomous Touch Out-of-Touch Sensitivity. More...
 
#define AT_SENSE   (15u)
 Autonomous Touch Sensitivity. More...
 
#define AT_PTHR   (5u)
 Autonomous Touch Positive Recalibration Threshold. More...
 
#define AT_PDRIFT   (60u)
 Autonomous Touch Positive Drift Compensation. More...
 
#define AT_NDRIFT   (60u)
 Autonomous Touch Negative Drift Compensation. More...
 
Touch common configuration options.
#define TOUCH_SYNC_PIN_OPTION   (USE_NO_PIN)
 Touch Sync Pin option. More...
 
#define TOUCH_SPREAD_SPECTRUM_MAX_DEV   (4u)
 Touch Maximum Deviation. More...
 
#define TOUCH_CSARES   (0x00000000)
 Touch Resistive Drive Enable for CSA lines. More...
 
#define TOUCH_CSBRES   (0x00000000)
 Touch Resistive Drive Enable for CSB lines. More...
 

#define AT_CAT_CLK_DIV   (23u)

Autonomous QTouch burst timing clock Divider.

The prescaler value is used to ensure that the CAT module clock (CLK_CAT) is divided to around 1 MHz to produce the burst timing clock. The prescaler uses the following formula to generate the burst timing clock: Burst timing clock = CLK_CAT / (2(DIV+1)). Range: 0u to 65535u.

#define AT_CHLEN   (2u)

Autonomous QTouch Charge Length For Autonomous QTouch sensor, specifies how many burst prescaler clock cycles should be used for transferring charge to the sense capacitor.

Units: Burst timing clock Range: 0u to 255u.

#define AT_DILEN   (255u)

Autonomous QTouch Discharge Length.

For Autonomous QTouch sensor, specifies how many burst prescaler clock cycles the CAT should use to discharge the capacitors before charging them. Units: Burst timing clock Range: 0u to 255u.

#define AT_DISHIFT   (0u)

Autonomous QTouch Discharge Shift.

For Autonomous QTouch sensor, specifies how many bits the DILEN field should be shifted before using it to determine the discharge time. Range: 0u to 3u.

#define AT_ENABLE_EXTERNAL_SYNC   (0u)

Autonomous QTouch External synchronization to reduce 50 or 60 Hz mains interference.

0u: For Autonomous QTouch sensor, specifies that external synchronization is disabled. 1u: For Autonomous QTouch sensor, specifies that external synchronization mode is enabled using the TOUCH_SYNC_PIN_OPTION pin option provided. Refer TOUCH_SYNC_PIN_OPTION option.

#define AT_ENABLE_SPREAD_SPECTRUM   (1u)

Autonomous QTouch Spread Spectrum Sensor Drive.

0u: For Autonomous QTouch sensor, specifies that spread spectrum sensor drive shall not be used. 1u: For Autonomous QTouch sensor, specifies that spread spectrum sensor drive shall be used.

#define AT_FILTER   (2u)

Autonomous Touch Filter Setting.

For the autonomous QTouch sensor, specifies how many positive detects in a row the CAT needs to have on the autonomous QTouch sensor before reporting it as a touch. Note: A FILTER value of 0 is not allowed and will result in undefined behavior. Range: 1u to 15u.

#define AT_MAX_ACQ_COUNT   (3000u)

Autonomous QTouch Maximum Count.

For Autonomous QTouch sensor, specifies how many counts (signal value) the maximum acquisition should be. Range: 0u to 65535u.

#define AT_NDRIFT   (60u)

Autonomous Touch Negative Drift Compensation.

For the autonomous QTouch sensor, specifies how often a negative drift compensation should be performed. When this field is zero, negative drift compensation will never be performed. When this field is non-zero, the negative drift compensation time interval is given by the following formula: Tndrift = NDRIFT * 65536 * (sample clock period) Range: 0u to 255u.

#define AT_OUTSENS   (8u)

Autonomous Touch Out-of-Touch Sensitivity.

For the autonomous QTouch sensor, specifies how sensitive the out-of-touch detector should be. When the sensor is not touched, the Autonomous Touch Current count register is same as the Autonomous Touch Base count register. When the sensor is touched the Autonomous Touch Current count register decreases. When using the Autonomous QTouch in proximity mode, the Autonomous Touch Base count register decreases as we move towards proximity of the sensor. The OUTSENS value can be arrived at by watching the CAT Autonomous Touch Base Count Register(at memory location 0xFFFF686Cu) and Autonomous Touch Current Count Register(at memory location 0xFFFF6870u) during a sensor touch/proximity and not in touch/proximity. A smaller difference between the Autonomous Touch Base count and Autonomous Touch Current count register can be chosen as the OUTSENS value. Range: 0u to 255u.

#define AT_PDRIFT   (60u)

Autonomous Touch Positive Drift Compensation.

For the autonomous QTouch sensor, specifies how often a positive drift compensation should be performed. When this field is zero, positive drift compensation will never be performed. When this field is non-zero, the positive drift compensation time interval is given by the following formula: Tpdrift = PDRIFT * 65536 * (sample clock period). Range: 0u to 255u.

#define AT_PTHR   (5u)

Autonomous Touch Positive Recalibration Threshold.

For the autonomous QTouch sensor, specifies how far a sensor's signal must move in a positive direction from the reference in order to cause a recalibration. Range: 0u to 255u.

#define AT_SELEN   (1u)

Autonomous QTouch Settle Length.

For Autonomous QTouch sensor, specifies how many burst prescaler clock cycles should be used for settling after charge transfer. Units: Burst timing clock Range: 0u to 255u.

#define AT_SENSE   (15u)

Autonomous Touch Sensitivity.

For the autonomous QTouch sensor, specifies how sensitive the touch detector should be. When the sensor is not touched, the Autonomous Touch Current count register is same as the Autonomous Touch Base count register. When the sensor is touched the Autonomous Touch Current count register decreases. When using the Autonomous QTouch in proximity mode, the Autonomous Touch Base count register decreases as we move towards proximity of the sensor. The SENSE value can be arrived at by watching the CAT Autonomous Touch Base Count Register(at memory location 0xFFFF686Cu) and Autonomous Touch Current Count Register(at memory location 0xFFFF6870u) during a sensor touch/proximity and not in touch/proximity. A larger difference between the Autonomous Touch Base count and Autonomous Touch Current count register can be chosen as the SENSE value. Range: 1u to 255u.

#define AT_SP_SELECTED   (SP15)

Autonomous QTouch Clock dependency note: The Example application uses a PBA clock of 48MHz.

When the UC3L PBA Clock is changed to a different frequency, the following parameters must be changed accordingly to ensure proper QMatrix operation.

  1. AT_CAT_CLK_DIV.
  2. TOUCH_SPREAD_SPECTRUM_MAX_DEV when Spread spectrum is enabled.

Autonomous QTouch Sensor Tuning Guide: When we start to tune the Proximity sensor, the values of AT_OUTSENS and AT_SENSE must be kept large. For example, AT_OUTSENS = 40u, AT_SENSE=80u. This will ensure that we do NOT hit the touch_at_status_change_interrupt_callback(), while we tune. With this setting, the Autonomous Touch Base Count Register (at memory location 0xFFFF686Cu) and Autonomous Touch Current Count Register (at memory location 0xFFFF6870u) should be watched using the IDE Memory window. In `no Touch' situation, the two memory addresses should read similar values. Expect these values to be at least few tens. When the sensor is touched, the Current count register should decrease with respect to the base count register. In order to increase the count, one could try increasing the AT_CHLEN and AT_SELEN. Once we see this behavior, we can then tune the AT_OUTSENS and AT_SENSE as desired, and this should result in proper interrupts. Also, please ensure that you are using Rev D UC3L chip and not Rev B. With the RevB has few know issue on the Autonomous Touch. A smaller difference between the Autonomous Touch Base count and Autonomous Touch Current count register can be chosen as the OUTSENS value. A larger difference between the Autonomous Touch Base count and Autonomous Touch Current count register can be chosen as the SENSE value. Autonomous QTouch Sense pair selected. Specify the Sense pair to be used for Autonomous QTouch. Choose any ONE Sense Pair from SP0 to SP16. Specify the Sense pair SPn directly. Do NOT use the SET_PIN() macro when specifying the Sense pair. Refer qt_pin_options_t enum in touch_api_at32uc3l.h file.

#define DEF_TOUCH_AUTONOMOUS_QTOUCH   (1)

When 1, Autonomous QTouch method acquisition is used.

When 0, Autonomous QTouch method acquisition is not used.

#define DEF_TOUCH_QDEBUG_ENABLE
Value:
#define DEF_TOUCH_QDEBUG_ENABLE_AT
Definition: thirdparty/qtouch/devspecific/uc3/uc3l0/examples/example_at/touch_config_at32uc3l.h:145
#define DEF_TOUCH_QDEBUG_ENABLE_QTA
Definition: thirdparty/qtouch/devspecific/uc3/uc3l0/examples/example_at/touch_config_at32uc3l.h:156
#define DEF_TOUCH_QDEBUG_ENABLE_QM
Enable/Disable QDebug for touch debug information communication with QTouch Studio PC Software...
Definition: thirdparty/qtouch/devspecific/uc3/uc3l0/examples/example_at/touch_config_at32uc3l.h:142
#define DEF_TOUCH_QDEBUG_ENABLE_QTB
Definition: thirdparty/qtouch/devspecific/uc3/uc3l0/examples/example_at/touch_config_at32uc3l.h:157
#define DEF_TOUCH_QDEBUG_ENABLE_AT
Value:
(1)
#define DEF_TOUCH_QDEBUG_ENABLE_QM   (0)

Enable/Disable QDebug for touch debug information communication with QTouch Studio PC Software.

The QTouch Library supports Autonomous QTouch, QMatrix, QTouch Group A/B modes at the sametime. However, when using QDebug, it is only possible to send the Touch debug information related to any one mode, at a given time. Only one among the DEF_TOUCH_QDEBUG_ENABLE_xx manifest constants below should be set to 1.

When 1, QDebug debug data communication to QTouch Studio is enabled. When 0, QDebug debug data communication to QTouch Studio is disabled.

#define DEF_TOUCH_QDEBUG_ENABLE_QTA   (0)
#define DEF_TOUCH_QDEBUG_ENABLE_QTB   (0)
#define DEF_TOUCH_QMATRIX   (0)

When 1, QMatrix method acquisition is used.

When 0, QMatrix method acquisition is not used.

#define DEF_TOUCH_QTOUCH_GRP_A   (0)

When 1, QTouch Group A method acquisition is used.

When 0, QTouch Group A method acquisition is not used.

#define DEF_TOUCH_QTOUCH_GRP_B   (0)

When 1, QTouch Group B method acquisition is used.

When 0, QTouch Group B method acquisition is not used.

#define SET_PIN (   x)    (1u << (x))

Helper macro to include a selected pin.

#define TOUCH_CSARES   (0x00000000)

Touch Resistive Drive Enable for CSA lines.

This option can be used to enable 1kOhm resistive drive capability, if available on a specific CSA pin. For the UC3L, the following CSA[n] pin have the resistive drive capability - CSARES: 0x0001AEEEu When bit n is 0, CSA[n] has the same drive properties as normal I/O pads. When bit n is 1, CSA[n] has a nominal output resistance of 1kOhm during the burst phase. Refer Table 28-2. Pin Selection Guide.

#define TOUCH_CSBRES   (0x00000000)

Touch Resistive Drive Enable for CSB lines.

This option can be used to enable 1kOhm resistive drive capability, if available on a specific CSA pin. For the UC3L, the following CSB[n] pin have the resistive drive capability - CSBRES: 0x0000BEECu When bit n is 0, CSB[n] has the same drive properties as normal I/O pads. When bit n is 1, CSB[n] has a nominal output resistance of 1kOhm during the burst phase. Refer Table 28-2. Pin Selection Guide.

#define TOUCH_SPREAD_SPECTRUM_MAX_DEV   (4u)

Touch Maximum Deviation.

When spread spectrum burst is enabled using the QM_ENABLE_SPREAD_SPECTRUM option, MAX_DEV indicates the maximum number of prescaled clock cycles the burst pulse will be extended or shortened. Range: When only QMatrix is used, 0u to ((2u * QM_CAT_CLK_DIV) + 1u). Range: When only Autonomous QTouch is used, 0u to ((2u * AT_CAT_CLK_DIV) + 1u). Range: When only QTouch Group A is used, 0u to ((2u * QTA_CAT_CLK_DIV) + 1u). Range: When only QTouch Group B is used, 0u to ((2u * QTB_CAT_CLK_DIV) + 1u). Range: When a combination of QMatrix, Autonomous QTouch, QTouch Group A or QTouch Group B is used, 0u to ((2u * least of(QM_CAT_CLK_DIV, AT_CAT_CLK_DIV, QTA_CAT_CLK_DIV, QTB_CAT_CLK_DIV )) + 1u)

#define TOUCH_SYNC_PIN_OPTION   (USE_NO_PIN)

Touch Sync Pin option.

Specify the sync pin option, if included in the hardware design. To prevent interference from the 50 or 60 Hz mains line the CAT can trigger acquisition on the SYNC signal. The SYNC signal should be derived from the mains line. The acquisition will trigger on a falling edge of this signal. Refer general_pin_options_t enum in touch_api_at32uc3l.h file.