How to Create a TrustZone®-based Touch Project Using MPLAB® Code Configurator (MCC) Harmony

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

Objective

The following procedure shows how to create a secure 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 secure self-capacitance touch project using MCC Harmony has been elaborated here. This project uses the onboard touch button present on the PIC32CMLS00 Curiosity Nano Evaluation board.

Materials

Hardware Tools

ToolAboutPurchase
PIC32CM LS00 CNanoPIC32CM LS00 Curiosity Nano+ Touch Evaluation Kit | Microchip TechnologyEV41C56A | Microchip Technology

Software Tools

  • MPLAB  X IDE with MCC plugin installed

Procedure

This secure touch project has been created for the onboard button with shield enabled. The touch peripheral will be designated as secure in this project. 

This step-by-step elaborates on the features of TrustZone®, which uses two projects: secure and non-secure projects. These projects work together on the same MCU and offer security isolation between the trusted and the non-trusted resources in the device. 

Open MPLAB X IDE.

Click File > New Project in MPLAB X IDE.

File menu

Back to Top


Choose the project.

In the New Project window, select Application Project(s) and click Next.

New Project window

Back to Top


Select the device.

Choose the device for which the project needs to be generated and click Next.

Device Selection

Back to Top


Select the compiler.

Choose the latest compiler for 32-bit devices and click Next.

Compiler Selection

Back to Top


Update the project settings.

Enter the LocationFolder, and Path for the project and click Finish.

Project Settings

MPLAB Harmony is opened along with the Project Graph. Three projects can be seen:

  1. Project group
  2. Secure project
  3. Non-secure project

Project Graph

By default, once a project is created, the non-secure project is set as the main project and MCC is opened. If it does not open, right-click on the non-secure project and click Set as Main project.

Project Graph

 

Back to Top


In the Device Resources pane, select Touch Library.

Device Resources pane

A pop-up window appears asking for PTC and RTC activation. Click Yes.

Components auto-activation

Back to Top


Now, Touch Library, RTC, and PTC are added to the Project Graph.

Project Graph

Launch Touch Configurator by selecting it from the Plugins drop-down.

Plugins drop-down

Back to Top


Choose the technology.

Choose Self-Cap technology and add 1 button, as this project is developed for the onboard touch button present. 

Choose Technology

An Information pop-up indicating that the clock for CPU and peripherals is set appears. Click Ok.

Back to Top


The pin assignment can be done in Configure > Sensor Pins. With respect to the following table, in touch configurator, the pins can be selected.

 Pins
Touch buttonPA22
Driven Shield for TouchPA21
LEDPA15

Pin assignment

Back to Top


Tune sensor parameters.

For tuning the touch parameters, select Config > Sensor Parameters and tune according to the application.

Sensor Parameters

Back to Top


Tune the common parameters.

For tuning the touch parameters, select Config > Common Parameters and tune according to the application.

Common Parameters

Back to Top


Enable Driven Shield then select the corresponding shield pin from the dropdown. 

Driven shield

Back to Top


Frequency Hop can be enabled by navigating to Config > Frequency Hop and then sliding the Enable Frequency Hop button.

Frequency Hop

 

Back to Top


Enable the data streamer by enabling the Enable Touch Tuning Data connection option. A detailed description of how to configure the data streamer is provided in the "Tuning Options for Touch in MPLAB® Code Configurator (MCC) Melody and Harmony" page.

Touch Tuning

Back to Top


Click on the Summary tab to review the project configuration and find versions of library modules.

Summary tab

Back to Top


Now add SERCOM3 for visualizing data using MPLAB Data Visualizer. Connect SERCOM3 block's UART to Touch block's UART.

Configure SERCOM settings by selecting the correct pad for TX and RX.

Project Graph

 

Back to Top


Configure Touch and SERCOM3 as Secure Peripheral as shown.

Peripheral configuration

Back to Top


Configure the pins and assign SERCOM pins as NON-SECURE from the drop-down.

Pin Settings

Back to Top


Once the project is configured, click on Project Resources > Generate to generate the code.

Project Resources > Generate

A "generation complete" message can be seen as shown. 

Generation complete message

The main project can then be built and checked for errors. 

Generation complete message

Back to Top


Include touch_process() and the code for LED in the main while(1) loop inside the secure project.

touch_process()

Now right-click on the secure project and select Make and Program device.

Make and Program device

Back to Top


The project is flashed in the device, and touch detection can be seen in MPLAB Data Visualizer.

MPLAB DV

Back to Top