Introduction
The Cap-Touch Controller (CTC) provides 4 channels for capacitive sensing, which offers a wide range of capacitance detection. The sensitivity and threshold for each channel are configurable. For different applications and surroundings, you should tune parameters to achieve the best performance.
The Cap-Touch Controller (CTC) provides 9 channels for capacitive sensing, which offers a wide range of capacitance detection. The sensitivity and threshold for each channel are configurable. For different applications and surroundings, you should tune parameters to achieve the best performance.
The Cap-Touch Controller (CTC) provides 9 channels for capacitive sensing, which offers a wide range of capacitance detection. The sensitivity and threshold for each channel are configurable. For different applications and surroundings, you should tune parameters to achieve the best performance.
The Cap-Touch Controller (CTC) provides 9 channels for capacitive sensing, which offers a wide range of capacitance detection. The sensitivity and threshold for each channel are configurable. For different applications and surroundings, you should tune parameters to achieve the best performance.
Usage
Cap Test Tool
Cap Test Tool is the official Cap-Touch calibration tool developed by Realtek, which can calibrate the general and channel-specific Cap-Touch configurations.
We suggest doing CTC calibration by the Cap Test Tool directly and automatically. Of course, users can tune the configuration parameters manually to meet special requirements according to section CTC Initialization and CTC Calibration.
CTC Initialization
The CTC initialization is implemented by the following steps:
Call
CapTouch_StructInit()
to initialize the configuration parameters of Cap-Touch, such as SampleCnt, ScanInterval, DiffThreshold, etc.Set configuration parameters in the following table and update configuration parameters of Cap-Touch in step 1 with it, which include touch threshold, noise threshold, mbias current, and enable control for each channel.
const CapTouch_CHInitTypeDef ctc_ch_config[4] = { /*DiffThreshold, MbiasCurrent, ETCNNoiseThr, ETCPNoiseThr, CHEnable*/ {80, 0x0C, 40, 40, ENABLE}, /* Channel 0 */ {80, 0x0C, 40, 40, DISABLE}, /* Channel 1 */ {80, 0x0C, 40, 40, DISABLE}, /* Channel 2 */ {80, 0x0C, 40, 40, DISABLE}, /* Channel 3 */ };
const CapTouch_CHInitTypeDef ctc_ch_config[9] = { /*DiffThreshold, MbiasCurrent, ETCNNoiseThr, ETCPNoiseThr, CHEnable*/ {800, 0x0C, 400, 400, ENABLE}, /* Channel 0 */ {800, 0x0C, 400, 400, DISABLE}, /* Channel 1 */ {800, 0x0C, 400, 400, DISABLE}, /* Channel 2 */ {800, 0x0C, 400, 400, DISABLE}, /* Channel 3 */ {800, 0x0C, 400, 400, DISABLE}, /* Channel 4 */ {800, 0x0C, 400, 400, DISABLE}, /* Channel 5 */ {800, 0x0C, 400, 400, DISABLE}, /* Channel 6 */ {800, 0x0C, 400, 400, DISABLE}, /* Channel 7 */ {800, 0x0C, 400, 400, DISABLE}, /* Channel 8 */ };
const CapTouch_CHInitTypeDef ctc_ch_config[9] = { /*DiffThreshold, MbiasCurrent, ETCNNoiseThr, ETCPNoiseThr, CHEnable*/ {800, 0x0C, 400, 400, ENABLE}, /* Channel 0 */ {800, 0x0C, 400, 400, DISABLE}, /* Channel 1 */ {800, 0x0C, 400, 400, DISABLE}, /* Channel 2 */ {800, 0x0C, 400, 400, DISABLE}, /* Channel 3 */ {800, 0x0C, 400, 400, DISABLE}, /* Channel 4 */ {800, 0x0C, 400, 400, DISABLE}, /* Channel 5 */ {800, 0x0C, 400, 400, DISABLE}, /* Channel 6 */ {800, 0x0C, 400, 400, DISABLE}, /* Channel 7 */ {800, 0x0C, 400, 400, DISABLE}, /* Channel 8 */ };
const CapTouch_CHInitTypeDef ctc_ch_config[9] = { /*DiffThreshold, MbiasCurrent, ETCNNoiseThr, ETCPNoiseThr, CHEnable*/ {400, 0x0C, 200, 200, ENABLE}, /* Channel 0 */ {400, 0x0C, 200, 200, DISABLE}, /* Channel 1 */ {400, 0x0C, 200, 200, DISABLE}, /* Channel 2 */ {400, 0x0C, 200, 200, DISABLE}, /* Channel 3 */ {400, 0x0C, 200, 200, DISABLE}, /* Channel 4 */ {400, 0x0C, 200, 200, DISABLE}, /* Channel 5 */ {400, 0x0C, 200, 200, DISABLE}, /* Channel 6 */ {400, 0x0C, 200, 200, DISABLE}, /* Channel 7 */ {400, 0x0C, 200, 200, DISABLE}, /* Channel 8 */ };
This method to tune parameters for each channel can be found in Section CTC Calibration.
Note
The configuration parameters can be acquired in Cap Test Tool.
Call
CapTouch_Init()
to configure the Cap-Touch.Enable Cap-Touch by
CapTouch_Cmd()
and enable the interrupt byCapTouch_INTConfig()
.
After all, the Cap-Touch will start to work.
CTC Calibration
To achieve the best performance (sensitivity, reliability or response time), users need to tune touch threshold, noise threshold and mbias current during development.
Mbias Mbias current needs to be considered during development, because different circuits (such as PCB layout) have different parasitic capacitance and sensitivity.
When the circuit design is confirmed, the user can use Realtek cap test tool to initialize the Mbias.
The calibration principle is to adjust Mbias so that the signal value of baseline is about 3300~3600 without touch.
Threshold
Difference threshold: 80% of the difference threshold (baseline − touch signal) is recommendeded.
Noise threshold: 30%~40% of the difference threshold (baseline − touch signal) is recommendeded.
Users can increase or decrease the threshold value to meet the SNR requirement (SNR > 5).
Note
For operation instructions, please refer to Captesttool_manual.
Too large mbias will cause the charging voltage to exceed the full range, which may cause damage to the circuit.
When using Cap-Touch, to prevent leakage, the Cap-Touch pin should be configured as shutdown or configured as no-pull, at the same time input and output of the pad should be disabled.
CTC Wakeup
When using CTC as a wakeup source, configure the CTC and system as follows:
Initialize CTC and enable its interrupt according to CTC Initialization.
Set the related wakeup source (
WAKE_SRC_CTOUCH
) insleep_wevent_config[]
toWAKEUP_KM4
orWAKEUP_KM0
(based on which CPU you want to wake). The interrupt should be registered on the same CPU selected bysleep_wevent_config[]
.Switch CTC clock source to CTC IP clock before system enters sleep mode by
RCC_PeriphClockSource_CTC()
.Enter sleep mode by releasing the wakelock in KM4 (
PMU_OS
needs to be released since it is acquired by default when boot).Clear the CTC interrupt when wakeup and switching CTC clock source to LBUS clock by
RCC_PeriphClockSource_CTC()
.
When using CTC as a wakeup source, configure the CTC and system as follows:
Initialize CTC and enable its interrupt according to Section CTC Initialization.
Set the related wakeup source (WAKE_SRC_CTOUCH) in
sleep_wevent_config[]
to WAKEUP_AP or WAKEUP_NP (based on which CPU you want to wake). The interrupt should be registered on the same CPU selected bysleep_wevent_config[]
.Switch CTC clock source to CTC 131K clock before system enters sleep mode by
RCC_PeriphClockSource_CTC()
.Enter sleep mode by releasing the wakelock in AP (
PMU_OS
needs to be released since it is acquired by default when boot).Clear the CTC interrupt when wake up and switch CTC clock source to lbus clock by
RCC_PeriphClockSource_CTC()
.
When using CTC as a wakeup source, configure the CTC and system as follows:
Initialize CTC and enable its interrupt according to Section CTC Initialization.
Set the related wakeup source (WAKE_SRC_CTOUCH) in
sleep_wevent_config[]
to WAKEUP_AP or WAKEUP_NP (based on which CPU you want to wake). The interrupt should be registered on the same CPU selected bysleep_wevent_config[]
.Switch CTC clock source to CTC 131K clock before system enters sleep mode by
RCC_PeriphClockSource_CTC()
.Enter sleep mode by releasing the wakelock in AP (
PMU_OS
needs to be released since it is acquired by default when boot).Clear the CTC interrupt when wake up and switch CTC clock source to lbus clock by
RCC_PeriphClockSource_CTC()
.
When using CTC as a wakeup source, configure the CTC and system as follows:
Initialize CTC and enable its interrupt according to CTC Initialization.
Set the related wakeup source (WAKE_SRC_CTOUCH) in
sleep_wevent_config[]
to WAKEUP_AP, WAKEUP_NP, or WAKEUP_LP (based on which CPU you want to wake). The interrupt should be registered on the same CPU selected bysleep_wevent_config[]
.Switch CTC clock source to 131K clock before system enters sleep mode by
RCC_PeriphClockSource_CTC()
.Enter sleep mode by releasing the wakelock in CA32 (
PMU_OS
needs to be released since it is acquired by default when boot).Clear the CTC interrupt when wake up and switch CTC clock source to LS APB clock by
RCC_PeriphClockSource_CTC()
.