Generate a Touch Project With MPLAB® Code Configurator (MCC) Melody

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

Objective

The following procedure shows how to create a Touch project with the MPLAB® Code Configurator (MCC) Melody platform, where touch sensors and their parameters can be graphically added and tuned. The resulting project supports the MPLAB XC8 compiler in MPLAB X IDE. The step-by-step procedure for generating a mutual capacitance project using MCC Melody has been provided here. This project uses the ATTINY3217 Xplained Pro board along with the T10 Mutual Capacitance Xplained Pro Extension Kit.

Materials

Hardware Tools

ToolAboutPurchase
ATTINY3217 XPROATtiny3217 Xplained ProATTINY3217-XPRO | Microchip Technology.
T10 XPROT10 Xplained Pro kitDM320204 | Microchip Technology

Software Tools

  • MPLAB X IDE with MCC installed

Procedure

Open MPLAB®X IDE.

Click and select the File > New Project option in MPLAB X IDE.

New Project

Back to Top


Choose the project.

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

Application Project

Back to Top


Type "TINY3217" in the Device option and select ATtiny3217.

ATtiny3217

In the Tool option, select the Attiny3217 Xplained Pro Tool from the drop-down and click Next.

Tool option

Back to Top


Select the compiler.

In the Select Compiler section, select the XC8 compiler and click Next.

Select Compiler section

Back to Top


Enter the Project Name, Project Location, and Project Folder for the project and click Finish.

New Project window

Back to Top


Select MCC from the toolbar.

Toolbar

When the MCC Content Manager window opens, click Next in MCC Melody.

MCC Content Type Wizard

Back to Top


Select the Touch Library content from the Component section and click Finish.

MCC Content Manager window

Back to Top


From Touch Configurator, add Touch from the Device Resources tab.

MCC tab

Back to Top


Touch is added to the project graph, as shown in the accompanying image.

Application Builder

Back to Top


Include RTC from Device Resources.

MCC tab

The builder with RTC and Touch is as follows.

Application Builder

Back to Top


Enable Overflow Interrupt in RTC.

RTC tab

Back to Top


Select Mutual-Cap from the drop-down.

Touch tab

 

Back to Top


Click the Button icon and add 4 buttons.

Touch tab

The Information dialog box opens, indicating that the Sensor pins are auto-assigned on creation. Click Ok.

Information dialog window

 

Back to Top


Now, click the Slider button and select 4 in segments. Click Add.

Touch tab

Now, four buttons and a four-channel slider are added.

Touch Configuration window

Back to Top


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 table.

If the MCU or the XPRO board is not available, then you can assign the pins based on the data sheet/user guide of that particular MCU/XPRO.

Based on the configuration, the X and Y lines should be selected as follows.

SensorChannel IDX LineY Line.
Button 0052
Button 1142
Button 2212
Button 3302
Slider 0453
543
613
703

Back to Top


The pin assignment can be done in Configure > Sensor Pins. The pins were selected with respect to the above table in Touch Configurator. Once the pins are selected, click Create.

Sensor Pins pane

Note: When configuring the pins, we can add or remove the X and Y lines as shown. 

Melody Pin Selection gif

Now the pin assignment can be seen in the Matrix view or Table view, as shown in the accompanying images. 

Sensor Pins pane

Sensor Pins pane

Back to Top


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

Note: All the parameters are tunable for buttons/sliders/wheels.

The Sensor Parameters pane allows you to configure 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

Sensor Parameters  pane

Here the CPU operating frequency can be set in the GCLK block in MHz as highlighted above.

Back to Top


For tuning the Touch parameters, Configure > Common Parameters and tune according to the application. The Common Parameters pane allows you to configure touch sensor parameters such as:

  • Acquisition
    • Scan rate
    • Peripheral Touch Controller (PTC) interrupt priority
    • Acquisition frequency
  • Sensor
    • Detect integration
    • Away from touch recall integration count
    • Away from touch recall threshold
    • Touch drift rate
    • Away from touch drift rate
    • Drift hold time
    • Re-burst mode
    • Max ON duration

Common Parameters Screen

Back to Top


Frequency Hop can be enabled by navigating to Configure > 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 compile time in Frequency Hop.

Touch tab

The auto-tune feature can be enabled by sliding the Enable Frequency Auto tuning button.

A detailed description on how to configure the Frequency Hop and Frequency Hop Auto tune is provided in the "How to Enable Frequency Hop Auto Tuning" page.

Touch tab

Back to Top


Enable the data streamer by selecting 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 tab

Back to Top


Click on the Summary tab to review the project configuration and find versions of library modules. Check whether all the necessary parameters are enabled and present.

Touch tab

Pin assignments can be checked as configured in the Pin Grid View.

Pin Grid View

 

Back to Top


In the Notifications tab, a few hints and warnings have been given for the project to build without any errors.

Notifications tab

To clear these hints and warnings, in Touch Configurator, click Important Notes.

Touch tab, Important Notes

A new pop-up with the notifications and a checkbox is displayed. Once all the items in the notifications are checked, the warnings and hints are cleared.

Important Notes

Back to Top


In the Resource management tab, select Interrupt Manager and enable the Global Interrupt as indicated in the hints.

Application Builder

Back to Top


Now click Generate from the Project Resource tab.

MCC tab

The "Generation complete" message is displayed in the output window.

User Output

Back to Top


Include touch_process() in the main while(1) loop. Now the project is ready for testing on the kit.

touch_process() in while()

Back to Top