Renesas e2studio(24)----capacitive touch configuration(1)

overview

This document will create a capacitive touch application example using e2 studio to integrate QE, and light up the LED by touching the button. Recently, I am taking courses of ST and Renesas RA. If you need samples, you can add a group application: 615061293.

video teaching

https://www.bilibili.com/video/BV1vc411P7pV/

Renesas e2studio(24)----capacitive touch configuration(1)

csdn course

The csdn course is more detailed.
https://edu.csdn.net/course/detail/36131

sample application

https://www.wjx.top/vm/wBbmSFp.aspx#

Complete code download

https://download.csdn.net/download/qq_24312945/87798507

hardware preparation

First, you need to prepare a development board. Here I am preparing a development board with chip model R7FA4M2AD3CFP:
insert image description here

New Construction

insert image description here

project template

insert image description here

save project path

insert image description here

chip configuration

In this article, R7FA4M2AD3CFP is used for demonstration.
insert image description here

Project template selection

insert image description here

clock configuration

The external high-speed crystal oscillator on the development board is 12M, and XTAL needs to be modified to 12M.
insert image description here

Add TOUCH driver

Add touch components by clicking New Stack->CapTouch->Touch.
insert image description here
Check the instructions to know that the DTC component is required.
insert image description here
Enable DTC enable.
insert image description here
The capacitive touch in the development board mainly has two pins, P415 and P708.
insert image description here
Configure these 2 pins for capacitive touch mode.
insert image description here

Click Add DTC Driver for Transmission, select New-> Transfer(r_dtc ), and add DTC driver transmission.
insert image description here

Click Add DTC Driver for Reception, select New > Transfer(r_dtc) to add the dtc driver.
insert image description here

Configure CapTouch

From the menu in e2 studio, select Renesas View > Renesas QE > CapTouch Workflow (QE) to open the main view for configuring capacitive touch.
insert image description here
After opening, you can see the specific configuration process.
insert image description here

In the CapTouch Workflow (QE) pane, you first need to select the capacitive touch item to be configured, as shown below.
insert image description here

Execute "Prepare Configuration" to create a new Touch configuration by using the drop-down menu and selecting Create a new configuration.
insert image description here
Capacitive touch buttons can be added through Button, the specific process is as follows.
1. Select the Button menu item from the right and move the mouse over the canvas.
2. Click the left mouse button to drop the button icon. There are 2 capacitive touch buttons on the development board, two buttons can be added.
3. After the two buttons are added, press the side to select the Button menu to exit the placement.

insert image description here

Double-click the button to configure specific capacitive touch button pins.

insert image description here

Open the tuning interface

Click Renesas View -> Renesas QE -> CapTouch Tuning Result, the configuration of the touch interface will be displayed in the main view pane.
insert image description here

insert image description here

Start CapTouch Tuning

To start the automatic tuning process, click the start tuning button.
insert image description here
Need to pay attention to link to the development board.
QE for capacitive touch auto-tuning starts now, please read the tuning dialog windows carefully as they will guide you through the tuning process. A sample screen is shown below.
insert image description here
After going through a few automated steps, you will arrive at the dialog box with the information shown below.
This is the touch sensitivity measurement step of the tuning process. Press normal touch pressure on the sensor shown in the dialog.
insert image description here

As you press, the bar will increase to the right and the touch count will go up numerically. While maintaining the pressure, press any key on the computer keyboard to accept the measurement.
insert image description here

Once done, you will see the picture shown below, which is the detection threshold used by the middleware to determine if a Touch event has occurred.
insert image description here

Click the "Continue the Tuning Process" button in the dialog. This will exit the tuning process and disconnect the debug session on the target.

insert image description here
After the tuning process is complete, the default view presented here will be the tuning results for the sensors in that configuration. This allows the user to quickly see the adjustment results.
insert image description here

Output tuning parameter file. Click the "Output Parameter Files" button.
insert image description here

Look in the Project Explorer window and you'll see the files added. These files contain the adjustment information needed to enable touch detection.
insert image description here

Light up the LED by capacitive touch

To implement the application code for the capacitive touch state, click the "Show Sample" button.
insert image description here
A new menu window will open showing the sample code in the text. Click the "Output to a File" button.
insert image description here

Created a new project file describing the sample code. In the Project Explorer window, you will see that the qe_touch_sample.c file has been added.
insert image description here

Open hal_entry.c, add qe_touch_main() function in the example main program.
insert image description here

Configure the pins for the LEDs.
insert image description here
insert image description here
Add the touch button to light the LED in qe_touch_sample.c.

            /* TODO: Add your own code here. */
            if(button_status & (0b1 |0b10) )
            {
    
    
                R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_03_PIN_01, BSP_IO_LEVEL_HIGH);
            }
            else
            {
    
    
                R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_03_PIN_01, BSP_IO_LEVEL_LOW);
            }

insert image description here
You can also view the touch button value button_status.

insert image description here

Guess you like

Origin blog.csdn.net/qq_24312945/article/details/130477630