Touch Scan Start by External Trigger

Touch Scan Start by External Trigger

Background

The CTSU (Capacitive Sensing Unit) allows touch sensor measurements to be started either by a software trigger or by an external trigger. When it is started by a software trigger, nondeterministic delays may occur due to software execution latency, resulting in variable intervals between measurements. In contrast, using a periodic timer interrupt as an external trigger provides more accurate timing control, making it suitable for applications that require precise measurement intervals. In addition, an external trigger can start a measurement without CPU intervention, allowing measurements to continue even while the CPU is in snooze mode. This mechanism enables low-power operation and is effective for products with strict power consumption requirements, such as battery-powered devices.

Implementation Method

The CTSU recieves an external trigger through the Event Link Controller (ELC) and can use it to start a touch sensor measurement. With this configuration, measurements can be automatically started in response to periodic peripheral event, such as timer, or non-periodic events, such as SCI or DTC, without requiring software control.

Step 1: Configuration in Smart Configurator and QE for Capacitive Touch

First, configure the CTSU module properties in Smart Configurator. In this step, select the external peripheral event to be used as the measurement start trigger. For example, AGT1 interrupt shown in the figure below. Based on this configuration, the event generated by the selected peripheral is routed through the ELC and delivered to the CTSU to trigger the measurement.

Next, configure the trigger method in QE for Capacitive Touch. After automatic tuning is completed by QE for Capacitive Touch, check the “Use external trigger” option before outputting the parameter file. If a software trigger is to be used, leave this option unchecked. Based on these two settings, the system is configured to start the CTSU measurement in response to external events.  

画像3.png
画像1.png

Step 2: Implementation in Application Code

When an external trigger source is configured via above Step 1, the measurement should be started by calling RM_TOUCH_ScanStart, in same way as with a software trigger. However, unlike with a software trigger, this API does not start the measurement immediately. Instead, it configures the CTSU so that the measurement begins as soon as the external trigger event is received. After one measurement cycle is completed, RM_TOUCH_ScanStart must be called again before the next external trigger is received. The code below illustrates this implementation using the AGT periodic event as the trigger source.

/* Open each peripherals */ RM_TOUCH_Open(&g_touch_ctrl, &g_touch_cfg); R_AGT_Open(&g_timer_ctrl, &g_timer_cfg); R_ELC_Open(&g_elc_ctrl, &g_elc_cfg); /* Enable Links between AGT interrupt and CTSU Measurement Start */ R_ELC_Enable(&g_elc_ctrl); /* Start periodic timer */ R_AGT_Start(&g_timer_ctrl); /* Main loop */ while (true) { /* prepare CTSU scan start */ RM_TOUCH_ScanStart(&g_touch_ctrl); /* Wait for scan start and complete (callback sets flag) */ while (0 == g_qe_touch_flag) {} g_qe_touch_flag = 0; /* Retrieve measurement results */ RM_CTSU_DataGet(&g_touch_ctrl, &button, &slider, &wheel); /* Processing according to the result*/ }