How to Create a Surface Touch Application in MPLAB® Code Configurator (MCC) Melody

Last modified by Microchip on 2026/02/24 15:13

Objective

The following procedure shows how to create a Touch Surface project with the MPLAB®Code Configurator (MCC) Melody platform, where the touch sensors and their parameters can be graphically added and tuned. The project supports the MPLAB XC8 compiler in MPLAB X IDE. 

Materials

Hardware Tools

ToolAboutPurchase

AVR128DA48 CURIOSITY NANO

AVRDA Curiosity Nano Evaluation KitDM164151 | Microchip Technology
Curiosity Nano Touch AdaptorCuriosity Nano Touch AdapterAC80T88A | Microchip Technology
QT8 XPROQT8 XPLAINED PRO EXTENSION KITAC164161 | QT8 Xplained Pro Extension Kit

Software Tools

  • MPLAB X IDE with MCC plugin installed

Hardware Connections

Connect the AVR128DA48 Cnano Evaluation Kit to the Curiosity Nano Touch Adapter. 

Connect the QT8 Xplained Pro Extension Kit to EXT1 header of the Curiosity Nano Touch Adapter as shown in the image below.

Hardware setup AVRDA CNANO, CNANO Touch Adapter, QT8 Explained Pro

Back to Top

Procedure

The following steps describe the procedure to create a 5*5 Surface Touch Application. The touch application uses the QT8 Xplained Pro extension kit as the surface sensor.

Open  MPLAB X IDE by going to File > New Project.

File > New Project

Back to Top


In the New Project pop-up window, select Categories > Microchip Embedded and Projects > Application Project(s). Click Next.

New Project pop-up window

Back to Top


In the next window, select the required device, which is Device: AVR128DA48. Then click Next.

Select device

Back to Top


Select the Compiler Toolchains and click Next

Compiler Toolchains

Back to Top


Provide a Project Name and a Project location. Click Finish.

New Project window

Back to Top


Open MCC from Window > MPLAB Code Configurator > MPLAB Code Configurator Open/Close. Under the Device Resource tab, add Touch from the Touch Configurator listed under Libraries.

Window > MPLAB Code Configurator

Device Resources

Back to Top


The Touch library will be included in the project, and the Touch configurations will be available in the MCC window. Take note of these Important Notes related to clock setup before configuring the Touch parameters.

Important Notes

Back to Top


Enable the Global Interrupt Enable in the Interrupt Manager.

Interrupt Manager

Back to Top


Add RTC from Device Resources

Device Resources


Enable Overflow Interrupt Enable in RTC configurator.

RTC configurator

Back to Top


Under the Touch configurator tab, click Create, and select the surface. Configure a 5*5 surface sensor.

Touch configurator

Configure the sensor pins under the Configure tab.

Configure tab

Configure the Sensor Parameters.

Sensor Parameters

Configure the Common Parameters.

Common Parameters

Configure the Gesture Parameters.

Gesture Parameters

Configure the Frequency Hop/AFA.

Frequency Hop/AFA

Configure Driven Shield if required.

Driven Shield

Under the Tune tab, enable the Touch Tuning Data connection if required. Select the required Tuning mechanism.

Tune tab

Once all required Touch parameters are configured, verify them in the Summary tab of Touch configurator.

Summary tab

Back to Top


Configure Touch Universal Asynchronous Receiver Transmitter (UART).

Select the required Universal Synchronous Asynchronous Receiver Transmitter (USART) in the dependency selector. Configure the desired USART Baud rate.

Application Builder

Enable the required UART Tx/Rx pins in the Pin Grid view. Ensure the USART Tx and Rx are enabled in the USART configurator.

Easy View

Pin Grid view

Back to Top


Click the Generate button. The User Output window shows a "generation complete" message after successfully generating the project.

Generation button

Back to Top


In main.c, call touch_process() inside while(1) as shown.

touch_process() in while(1)

Back to Top