Generate a Touch Project With MPLAB® Code Configurator (MCC) Harmony
Objective
This procedure outlines how to create a touch project using the MPLAB® Code Configurator (MCC) with the Harmony platform. In this project, you can graphically add and adjust touch sensors and their parameters. The resulting project supports the MPLAB XC32 Compiler in MPLAB X IDE. The following step-by-step guide details how to generate a mutual capacitance project using MCC Harmony. This project utilizes the SAML10 Xplained Pro board along with the T10 Mutual Capacitance Xplained Pro Extension Kit.
Materials
| Tool | About | Purchase |
|---|---|---|
| ATSAML10 XPRO | Product details page | DM320204 - SAM L10 Xplained Pro |
| T10 XPRO | Product details page | AC47H23A - T10 Xplained Pro Extension Kit |
Software Tools
- MPLAB ® X IDE with MCC plugin installed
Procedure
Open MPLAB X IDE
Click File > New Project in MPLAB X IDE.
Choose Project
In the New Project window, select Application Project(s) and click Next.
Device Selection
Choose the device for which the project needs to be generated and click Next.
Compiler Selection
Choose the latest compiler for 32-bit devices and click Next.
Project Settings
Enter the Location, Folder, and Path for the project and click Next.
MCC Harmony with Touch Packages
MPLAB Harmony is opened along with the Project Graph.
Open the content manager and update touch under Harmony 3 - Capacitive Touch solutions and click Apply.
The latest touch repo will be downloaded and MPLAB Harmony is then ready to use for generating a touch project.
In the Device Resources pane, select Touch Library.
A pop-up window appears asking for PTC and RTC activation. Click Yes.
Now, Touch Library, RTC, and PTC are added to the Project Graph.
Launch Touch Configurator by selecting it from the Plugins drop down.
Choose Technology
The T10 Xplained Pro extension board consists of four mutual cap touch buttons and one slider sensor.
Choose Mutual Cap as the sensing technology from the drop-down in the Touch Configuration window, as shown.
Add Buttons
Click Button icon and input 4 as the number of buttons.
An Information pop-up indicating that the clock for CPU and peripherals is set appears. Click Ok.
Add Slider
Click the Slider icon and input 1 for Sliders and 4 for Segments (if not already present).
Now, four buttons and a four-channel slider are added.
Pin Assignment
A generalized pin assignment for a majority of the Xplained PROs, Curiosity PROs, and MCUs has been provided in the Curiosity Nano Touch Adapter Pin Configuration.
If the MCU or the XPRO board is not available, then you can assign the pins based on the data sheet or user guide for that particular MCU or XPRO.
Based on the configuration, the X and Y lines should be selected as follows.
| Sensor | Channel ID | X Line | Y Line |
| Button 0 | 0 | 5 | 2 |
| Button 1 | 1 | 4 | 2 |
| Button 2 | 2 | 1 | 2 |
| Button 3 | 3 | 0 | 2 |
| Slider 0 | 4 | 5 | 3 |
| 5 | 4 | 3 | |
| 6 | 1 | 3 | |
| 7 | 0 | 3 |
The pin assignment can be done in Configure > Sensor Pins. With respect to the previous table, in touch configurator, the pins were selected. Once the pins are selected, click Create.

The pin assignment can be seen in Matrix view or Table view, as shown in the accompanying image.
Sensor Parameters
For tuning the touch parameters, select Config > Sensor Parameters and tune according to the application.
All the parameters are tunable for buttons, sliders, and wheels.
The Sensor Parameters tab enables the configuration of touch sensor parameters, such as:
- Digital Filter Gain
- Digital Filter Oversampling
- Analog Gain
- Series Resistor
- Addition Charge Share Delay
- PTC Clock
- Sensor Detect Threshold
- Sensor Hysteresis
- Sensor AKS
Common Parameters
For tuning the touch parameters, select Config > Common Parameters and tune according to the application.
The Common Parameters tab enables the configuration of touch sensor parameters, such as:
- Acquisition
- Scan Rate
- PTC Interrupt Priority
- Acquisition Frequency
- Sensor
- Detect Integration
- Away from Touch Recal Integration Count
- Away from Touch Recal Threshold
- Touch Drift Rate
- Away from Touch Drit Rate
- Drift Hold Time
- Re-burst mode
- Max ON Duration
Frequency Hop
Frequency Hop can be enabled by navigating to Config > Frequency Hop and then sliding the Enable Frequency Hop button. A maximum of seven frequency steps can be selected, which can be individually configured using the drop-down. Hop Frequencies are fixed at the time of compilation in Frequency Hop. The auto-tune feature can be enabled by sliding the Enable Frequency Auto Tuning button. A detailed description of how to configure the Frequency Hop and Frequency Hop Autotune is provided in the How to Enable Frequency Hop Auto Tuning page.
Touch Tuning
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.
Summary
Click on the Summary tab to review the project configuration and find versions of library modules.
Once the project is configured, click on Project Resources > Generate to generate the code.
Include touch_process() in the main while(1) loop. Now the project is ready for testing on the kit.