Capacitive Touch HW trigger


Recently I am approching with Renesas RA and Capacitive Touch.

I've started my application following Application Note "Using QE and FSP to Develop Capacitive Touch Applications" Rev.2.00.

This AN suggests to use HW trigger (AGT) to start the touch button scan and a code example is shown in chapter 7.2.

But I was wondering why even if a HW trigger is used I found a TOUCH_ScanStart and a SoftwareDelay calls inside a while(true) loop.

It seems the same code used for software trigger.

Is it a mistake?

  • Yes, I think this section of the app note could be improved.

    Using a periodic timer to trigger the CTSU scan can be very useful.  Typically the AGT1 would be used in a low power example.  The AGT1 is one of the peripherals that can operate in Software Standby Mode.  The AGT1 Interrupt can cause a Snooze Request, transitioning the RA2L1 from Software Standby Mode to Snooze Mode.  The CTSU can operate in Snooze Mode if the DTC has been specified to write and read data from the CTSU.  The Scan End interrupt will transition the RA2L1 from Snooze mode to Active mode, the touch data can be processed for a touch.

    Typically, if a touch has not been detected then the RA2L1 will go back to software standby mode and the process repeats.

    It a touch is detected, then the application will stay in active mode until it is required to transition back to a power saving mode.

    Doing this, it is possible to see an active current consumption of 10uA when scanning a touch electrode.  This average current consumption is dependent on 2 thiings - 1, how many electrodes do you wish to scan in the low power mode, 2, the scan trigger interval.  This may be once every 100 or 200ms, depending on the required responsiveness of the wake up.

    Assume that the AGT1 is triggering a low power scan every 200ms, a touch is detected and the application is now active and "normal" touch scans are to be performed.  Scanning at 200ms in active mode will give a very slow touch response.  In the application examples, 20ms is used as the scan interval.

    You therefore have 2 options - change the interval time of the AGT1, or switch to a different hardware trigger, or software trigger.

    Thee issue with the CTSU driver is that once a trigger source is specified (Software or Hardware) it cannot be changed.

    So if you have specified AGT1 hardware trigger, how would you switch back to a software trigger.

    Well, the hardware trigger is an ELC Event trigger, and the ELC can be software triggered.

    The attached project shows how the ELC hardware trigger can be switched between an ELC_Software, ELC_AGT1 and ELC_GPT0 trigger.

    Now, to answer you original question.

    If using the ELC Software Trigger, then use you would still need the software delay.

    If using an ELC timer trigger, then no, the software delay is not required.

    The attached example is written for the RSSK_RA2L1, e2-studio 2022-07, FSP4.0

    The example scans the 3 buttons, TS_B1, TS_B2, TS_B3

    Hope this helps, and I'll pass your comments onto the app note team.

  • Thank you Richard,

    it was a really comprehensive answer and the source code example was also very helpful.

    However, I still have a doubt.

    In the example code you have shared, (HW trigger selected, AGT or GPT don't care), when the first scan is terminated the execution restarts immediately from the beginning of while(1) loop and it appears that the RM_TOUCH_ScanStart(g_qe_touch_instance_config01.p_ctrl); function is call immediately without waiting for the trigger.

    I can't figure out how the program stops executing the qe_touch_main () function and then waits for the AGT / GPT trigger (without software delay).

    Would you help me to understand better?

    Thank you