How to Create a dsPIC33A Touch Application in MPLAB® Code Configurator (MCC) Melody
Overview
The following procedure shows how to create a Touch project with MPLAB® Code Configurator (MCC) Melody platform where the touch sensors and their parameters can be graphically added and tuned. The project supports the MPLAB XC-DSC C compiler in MPLAB X Integrated Development Environment (IDE).
Materials
Hardware Tools
| Tool | About | Purchase |
|---|---|---|
dsPIC33A Curiosity Platform Development Board | dsPIC33A Curiosity Platform Development Board | EV74H48A | Microchip Technology |
| dsPIC33AK512MPS512 Curiosity GP DIM Board | dsPIC33AK512MPS512 Curiosity GP DIM Board | EV80L65A | Microchip Technology |
Software Tools
- MPLAB X IDE with MCC plug-in installed
Hardware Connections
Connect the dsPIC33AK512MPS512 Curiosity GP DIM Board to the J1 connector of the dsPIC33A Curiosity Platform Development Board as shown in the accompanying image.
Prcedure
The following steps outline the procedure for creating a 3-button touch application. The touch application uses the onboard sensors available on the Curiosity Platform Development Board.
Open MPLAB X IDE and select File> New Project.
In the New Project window under Categories, select Microchip Embedded. From Projects, select Application Project(s) and click the Next button.
In the Select Device pane, select the required device (here it is dsPIC33AK512MPS512) and click the Next button.
Select the compiler under Compiler Toolchains and click the Next button.
Provide a Project Name and a Project location. Then click the Finish button.
Open MCC from Window > MPLAB® Code Configurator > MPLAB® Code Configurator Open/Close.
Under the Device Resource tab, add Touch from the Touch Configurator listed under Libraries
The Touch library will be included in the project, and the Touch configurations will be available in the MCC window. Before configuring the Touch parameters, please see the important notes related to the clock setup.
Add the timer for touch from the Dependency Selector. Configure the scan rate periodicity as shown in the accompanying image.
Enable Clock Generator 6 in the system clock settings and select the Clock Source as any one of the phase-locked loops.
Configure the PLLx VCO Divider Frequency or the PLLx Out Frequency between 32-320 MHz.
Confirm that the clock configured in the previous step has been updated in Clock Source Frequency and Calculated Clock Generated Frequency correctly.
Configure Touch.
Create the required number of buttons/scrollers/wheels.
Configure the Sensor Pins.
Configure the Sensor Parameters.
Configure the Common Parameters.
Configure Frequency Hop/AFA.
Configure Driven Shield as required.
Under the Tune, select Touch Visualization (unidirectional, requires UART Tx).
Once all the required Touch parameters are configured, verify that the same is in the Summary tab of Touch configurator.
Configuring TouchUART.
Select the required Universal Asynchronous Receiver/Transmitter (UART) in the dependency selector. Configure the Baud rate as 115200.
Enable the required UART Tx pins in the Pin Grid view.
Click the Generate button. The User Output window shows "Generation Complete" after successfully generating the project.
In main.c, call touch_process() inside while(1) as shown in the accompanying image.