Objective
The following lab shows you how to create a Touch project with the MPLAB® Harmony platform where you can graphically add sensors and configure QTouch® parameters. The resulting project supports the MPLAB XC32 compiler in MPLAB X IDE. This project uses the SAMC21N Xplained Pro board along with the QT1 Mutual Capacitance Xplained Pro Extension Kit.
Materials
Hardware Tools
Tool | About | Purchase |
---|---|---|
ATSAMC21N18A
ATSAMC21N18A |
| |
ATSAMC21N18A
Xplained Pro |
| |
QT1 Xplained Pro
Extension Kit |
| |
Software Tools
Tool | About | Installers |
Installation
Instructions |
||
---|---|---|---|---|---|
Windows | Linux | Mac OSX | |||
MPLAB® Harmony 1.xx
Integrated Software Framework |
| | | | |
Procedure
6
Launch MPLAB Harmony Configurator (MHC) with Touch Packages:
7
Add Touch Library Middleware with Needed Components:
Touch Component
From the Touch drop-down, drag and drop Touch Library middleware from the available components list to the Project Graph window.
- A pop-up window appears asking for auto-activation of RTC component. Click Yes.
- Another pop-up appears asking for auto-connecting the RTC component. Click Yes.
9
Choose Technology and Add Sensor:
The QT1 Mutual Capacitance Xplained Pro Extension Kit has two touch buttons, one wheel sensor and one slider sensor.
10
Pin Assignment:
Refer to the following SAMC21N Xplained Pro header and QT1 Mutual Capacitance Xplained Pro documents for connection details.
Based on the design files, the X and Y lines should be selected as follows.
Select the Pins tab and select the correct X and Y lines for buttons.
Click on Table View to switch the view and assign the X, Y pins from the drop-down list for each sensor.
Click on Matrix View to switch the view back.
- Drag and drop the channels to the required combination of X and Y.
- Click on the channel displayed as X(Y) or Y(X) to toggle X to Y or Y to X.
- The Matrix View is only provided in case of mutual capacitance, to quickly drag and drop the sensors and configure the pins.
11
Parameters:
Select the Parameters tab.
d
Noise Handling
Scroll down the sensor page to configure noise handling. Frequency Hop can be enabled by selecting the Enable Frequency Hop checkbox. You can select up to seven Frequency Steps and then configure the Hop Frequencies from the drop-down list. Hop Frequencies are fixed at compile time in Frequency Hop.
The auto-tune feature can be enabled by selecting the Enable Frequency Auto Tuning checkbox. Hop Frequencies are tuned by the library at run time as per the Auto Tune Parameters thresholds configured during noisy conditions.
e
Debug Parameters
Enable the datastreamer by selecting the Enable Data Visualizer option. A detailed description on how to configure the datastreamer is provided in the "Configure Datastreamer and Visualize Touch Data using Data Visualizer" page.
Results
Once you have finished configuring your project, generate the code. The source files and header files will be added to the project. Check for compilation errors and run it in the board.