![]() |
Synergy Software Package User's Manual
|
The capacitive touch sensing unit version 2 HAL driver (r_ctsu v2) provides an API to control the CTSU peripheral. This module performs capacitance measurement based on various settings defined by the configuration. This module is configured via the QE for Capacitive Touch.
The following build time configurations are defined in ssp_cfg/r_ctsu_cfg.h:
Build Time Configurations for r_ctsu
| Configuration | Options | Default | Description |
|---|---|---|---|
| Parameter Checking | - Default (BSP) - Enabled - Disabled | Default (BSP) | If selected code for parameter checking is included in the build. |
| Support for using DTC | - Enabled - Disabled | Disabled | Enable DTC support for the CTSU module. |
| Interrupt priority level | MCU Specific Options | Priority level of all CTSU interrupt (CSTU_WR,CTSU_RD,CTSU_FN) |
This module can be added to the Stacks tab via New Stack > Driver > CapTouch > CTSU Driver on r_ctsu.
Configurations for Driver > CapTouch > CTSU Driver on r_ctsu
| Configuration | Options | Default | Description |
|---|---|---|---|
| Scan Start Trigger | MCU Specific Options | CTSU Scan Start Trigger Select |
The first R_CTSU_Open function call sets CTSU peripheral interrupts. The user should provide a callback function to be invoked at the end of the CTSU scan sequence. The callback argument will contain information about the scan status.
The CTSU peripheral module uses PCLKB as its clock source. You can set the PCLKB frequency using the Clocks tab of the RA Configuration editor or by using the CGC Interface at run-time.
The TSn pins are sensor pins for the CTSU.
The TSCAP pin is used for an internal low-pass filter and must be connected to an external decoupling capacitor.
In order to improve the measurement accuracy, the correction coefficient is generated at the first R_CTSU_Open.
Therefore, the first R_CTSU_Open process takes about 40ms.
CTSU v2 has a current offset mechanism to cancel the parasitic capacitance. This module automatically adjusts to be within the dynamic range of the Sensor ICO, taking into account the amount of current that changes with touch. This adjustment uses normal measurement process and requires several R_CTSU_ScanStart and R_CTSU_DataGet. R_CTSU_DataGet returns SSP_ERR_CTSU_INCOMPLETE_TUNING if it is being adjusted. The member "so" of ctsu_element_cfg_t is used as the starting point for adjustment, so if this value is appropriate, it can be completed quickly. Normally, this value uses the value adjusted by QE for Capacitive Touch.
Scanning of sensors may begin by either a software trigger or an external event initiated by the Event Link Controller (ELC). This trigger can be set with the member "cap" of ctsu_cfg_t. Typically, a software trigger is used. Common usage is to have a periodic timer initiate scans. For software triggers, a periodic timer such as the CMT is configured whose interval is large enough to allow for all sensors to be scanned and data to be updated. Software triggers are issued by calling R_CTSU_ScanStart. Using an external trigger is processed almost identically to using software triggers. Call R_CTSU_ScanStart before starting the timer to set the measurement and prepare for external trigger measurement. After that, when the timer is started, the measurement start trigger is applied.
In self-capacitance mode each TS pin is assigned to one touch button. Electrodes of multiple TS pins can be physically aligned to create slider or wheel interfaces.
Set CTSU_MODE_SELF_MULTI_SCAN to "md" of ctsu_cfg_t. Also, add the number of terminals used for this measurement to CTSU_CFG_NUM_SELF_ELEMENTS. For details, refer to the configuration and sample application output by QE for Capacitive Touch.
In mutual-capacitance mode each TS pin acts as either a 'row' or 'column' in an array of sensors. As a result, this mode uses fewer pins when more than five sensors are configured. Mutual-capacitance mode is ideal for applications where many touch sensors are required, like keypads, button matrices and pads.
As an example, consider a standard phone keypad comprised of a matrix of four rows and three columns.
In mutual capacitance mode only 7 pins are necessary to scan 12 buttons. In self mode, 12 pins would be required.
Set CTSU_MODE_MUTUAL_FULL_SCAN to "md" of ctsu_cfg_t. Also, add the number of matrix used for this measurement to CTSU_CFG_NUM_MUTUAL_ELEMENTS. For details, refer to the configuration and sample application output by QE for Capacitive Touch.
The CTSU peripheral has a built-in function that diagnoses its own inner circuit. The diagnostic requirements are providing 5 types of diagnosis. The diagnosis function is executed by calling the R_CTSU_Diagnosis() API function. This is executed independently from the other measurements and does not affect them.
This is a basic example of minimal use of the CTSU in an application.
This is a optional example of using both Self-capacitance and Mutual-capacitance configurations in the same project.
This is an example code of using self-diagnosis functionality.