How to Create a Surface and Gesture Project in MPLAB® Code Configurator (MCC) Harmony
Objective
The following procedure shows how to create a touch project with the MPLAB® Code Configurator (MCC) Harmony platform where touch sensors and their parameters can be graphically added and tuned. The resulting project supports the MPLAB XC32 compiler in MPLAB X IDE. The step-by-step procedure for generating a self-capacitance surface and gesture project using MCC Harmony has been provided here. This project uses the PIC32CM PL10 Curiosity Nano Evaluation board along with the QT8 Self Capacitance Xplained Pro Extension Kit.
Materials
Hardware Tools
| Tool | About | Purchase |
|---|---|---|
| PIC32CM PL10 CNANO | PIC32CM PL10 Curiosity Nano Evaluation Kit | EV10P22A - PIC32CM PL10-CNANO |
| Curiosity Nano Touch Adaptor | Curiosity Nano Touch Adapter | AC80T88A | Microchip Technology |
| QT8 XPRO | QT8 XPLAINED PRO EXTENSION KIT | AC164161 | QT8 Xplained Pro Extension Kit |
Software Tools
- MPLAB X IDE with MCC plugin installed
Hardware Connections
Connect the PIC32CM PL10 CNANO Evaluation Kit to the Curiosity Nano touch adapter.
Connect the QT8 Xplained Pro Extension Kit to the EXT1 header of the Curiosity nano touch adapter as shown in the accompanying image.
Procedure
Following the steps outlined in the Generate a Touch Project With MPLAB® Code Configurator (MCC) Harmony page, continue with the instructions until you reach the step where you select the sensor in the Touch Configurator. From there, proceed with the steps here to create and tune a surface project that is compatible with the QT8 device.
Sensor Technology and Sensor Type: Choose Self-Cap as the sensing technology and click the surface icon.
Next, add 5 horizontal and 5 vertical segments, and select 1 & 2 Finger Gesture from the drop-down menu as shown.
Now, an information dialog box opens for sensor pin selection. Click Ok.
Now in the Configure tab, the surface sensor opens in Surface view. Click the pins assigned to a particular segment and select the appropriate pin according to the pin assignment given from PIC32CMPL10 CNANO with QT8 XPRO in the Table Representation of Curiosity Nano Boards Pin Outs > CNano Touch Adapter > Touch Extension Boards.
Once the pins are selected, from Configure > Sensor Parameters, configure the sensor parameters like Additional Charge Share Delay and Sensor Detect Threshold as shown.
Configure the ADC Prescaler as required, and the ADC Pump enabler based on the device operating voltage, as shown.
To obtain maximum compatibility and extraordinary performance with PIC32CM PL10, use the gesture parameters as shown in the accompanying image.
Select the PTC pin corresponding to the Driven Shield present in QT8 from the drop-down as shown.
Frequency Hop and Frequency Hop Autotuning will be enabled by default, as shown in the accompanying image.
For monitoring touch data in the MPLAB Data Visualizer, navigate to the Tune tab and enable Touch Tuning (bi-directional, requires UART Tx and Rx).
Verify the Summary before closing the Touch Configurator.
The Touch Library, along with RTC, ADC0, and PTC will be loaded in the Project Graph as shown.
Add SERCOM1 for data monitoring in the MPLAB Data Visualizer.
For enabling the LEDs connected to the QT8 board to report touch/gesture detection, SERCOM0 is added to enable I2C-based LED control using the MCP23017 driver. The settings can be configured as shown in the accompanying image.
Once the SERCOM is added, the led_driver.c and led_driver.h files can be added to the application program location. These files access the driver and ensure smooth operation of the LEDs present.
For this project, the CPU is configured to use a 24 MHz clock. You can change the clock configuration based on the requirements by selecting the Clock Configurations option from the Plugins drop-down.
Once the clock configurator is opened, the clock settings can be changed as shown in the accompanying image.
Select Pin Configuration from the Plugins dropdown.
Three tabs related to pin configurations are opened. Now, view the Pin Settings tab and check whether all the required touch pins have been added. Also, check whether the SERCOM pins have been configured as required.
After all components have been added to the Project Graph, resolve any warnings or errors listed in the Notifications tab, and then click the Generate button.
Now, add touch_process(), led_decode_gesture() and led_process() to main.c inside the while(1) loop as shown. Build and Flash the project to the PL10 Cnano connected to the PC.
QT8 functioning with PIC32CMPL10:
The following animation shows how to view touch, surface and gesture data in MPLAB Data Visualizer when QT8 is connected.

The following animation shows how surface data can be viewed with Bi-directional DV.

The following animation shows how gesture data can be viewed with Bi-directional DV.

The following animation shows the working of QT8 with LEDs incorporated in the application.
