1.1.2 Generate Touch Project with MCC Melody

Objective

The following procedure shows how to create a Touch project with the 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. This project uses the ATTINY3217 Xplained Pro board along with the T10 Mutual Capacitance Xplained Pro Extension Kit.

Materials

Hardware Tools

Software Tools

MPLAB®X IDE with MCC installed.

Procedure

Step 1: Open MPLAB®X IDE

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

Step 2: Choose Project

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

Step 3: Device and Tool Selection

Type TINY3217 in the Device option and select ATtiny3217.

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

Step 4: Compiler Selection

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

Step 5: Project Settings

Enter the project name, location and folder for the project and click Finish.

Step 6: MCC with Melody

Select MCC from the Toolbar

The MCC content Manager window opens and from it click Next in MCC Melody.

Step 7: Melody with Touch package

Select the Touch content from the Optional Content section and click Finish.

Step 8: Adding Touch to the project

Add Touch from Touch configurator from th Device Resources Tab.

Touch is added to the Project graph as shown below.

Include RTC from Device Resources

The builder with RTC and Touch is as follows.

Enable Overflow Interrupt in RTC.

Step 9: Select Technology

Select Mutual cap from the drop down as shown.

Step 10: Add Buttons

Click Button icon and add 4 buttons

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

Step 11: Add Slider

Now click Slider and select 4 in segments and click Add.

Now 4 buttons and 4 channel slider sensor are added.

Step 12: Pin Assignment

A generalized pin assignment for a majority of the Xplained PROs and MCUs have been provided in a downloadable file titled "Curiosity Nano Touch Adapter Pin Configurattion" the Documentation section in this link as shown in the figure.

If the MCU or the XPRO board is not available then the user can assign the pins based on the datatsheet/userguide of that particular MCU/ XPRO. A snapshot of the pinout for SAML10 and T10 XPRO can be seen from the below figure.

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

SensorChannel IDX LineY Line
Button 0054
Button 1144
Button 2214
Button 3304
Slider 0453
543
613
703

The pin assignement can be done in Configure → Sensor Pins. With respect to the above table in touch configurator the pins were selected.

Note: It can be seen that when configuring the pins, we can drag and drop the sensor to modify the X and Y lines. For changing the multiplexed X or Y line the corresponding line should be clicked as shown below.

Parameters

Step 13: Sensor Parameters

For tuning the touch parameters, ConfigSensor Parameters and tune according to the application.

Note: All the parameters are tunable for buttons/Sliders/Wheels.

The Sensor Parameters Tab allows 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

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

Step 14: Common Parameters

For tuning the touch parameters, ConfigCommon Parameters and tune according to the application.

The Common Parameters Tab allows to configure 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

Step 15: Frequency Hop:

Frequency Hop can be enabled by navigating to ConfigFrequency Hop and then sliding the Enable Frequency Hop button. A maximum of 7 frequency steps can be selected which can be induvidually configured using the drop down. Hop Frequencies are fixed at compile time in Frequency Hop.

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 Autotune is provided in the How to Enable Frequency Hop Auto tune page.

Step 16: Touch Tuning

Enable the datastreamer by selecting the Enable Touch tuning Data connection option. A detailed description on how to configure the datastreamer is provided in the Guide to view Touch Tune Data using MPLAB® Data Visualizer page.

Step 17: Summary

Click on the Summary Tab to review the project configuration and find versions of Library modules. Check whether all the necessary paramneters are enabled and present.

The pins assignment can be checked as configured above in the Pin Grid View.

Step 18: Configuring Hints and Warnings

In Notifications Tab, it can be seen that a few hints and warning have been given for the project to build without any errors.

To clear these hints and warning, in Touch Configurator → Click Important Notes.

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

In the Resource management tab select Interrupt Manager and enable the Global interrupt as indicated in the Hints.

Step 19: Project Generation

Now click Generate from the Project Resources Tab.

The Generation complete message is displayed in the output window.

Step 19: Include touch_process() to the main while(1) loop. Now the project is ready for testing on the kit.