PIC18F57Q43 Curiosity Nano and QT8 Touch Board Example

 Objective

This guide shows you how to use the MPLAB® Code Configurator (MCC) mTouch® Sensing Solutions module to create a touch surface project and view the data in the 2D touch surface utility. The set-up requires the PIC18F57Q43 Curiosity Nano Board, Curiosity Nano Touch Adapter, QT8 Xplained Pro Extension Kit, and a connecting cable.

QT8.png

 Materials

Hardware Tools

Software Tools

Tool About Installers
Installation
Instructions
Windows Linux Mac OSX
MPLAB® X
Integrated Development Environment
swtool-28px.png
MPLAB® Code Configurator
Dynamic Code Generation
MPLAB® XC8
C Compiler

 Procedure

1

Create an MPLAB X IDE Project for the PIC18F57Q43

  • Choose Project: Standalone Project
  • Select Device: PIC18F57Q43
  • Select Tool: PIC18F57Q43 Curiosity Nano
  • Select Compiler: XC8
  • Select Project Name and Folder
CreateProject.png

If you are not familiar with MPLAB X IDE, please visit the Developer Help page.

2

Open MCC in MPLAB X IDE

If you do not see the MCC logo, please check that you have installed the MCC plugin. More information on MCC installation can be found on the step-by-step MCC installation page.

MCCv3.png

3

Configure the System Clock

Open the System Module from the Project Resources menu. Select HFINTOSC from the Oscillator Select drop-down box and select 32_MHz from the HF Internal Clock drop-down box. Choose a division factor of 1 from the Clock Divider drop-down box. This will result in a 32 MHz system clock.

SystemModule.png

To ensure the performance of the mTouch surface, the system clock is required to be at least 8 MHz. If you select a system clock slower than 8 MHz, the mTouch module will generate a warning in the notification window.

4

Load the mTouch Module

Double click on the mTouch button in the Libraries list inside the Device Resources window.

DeviceResources.png

After loading the module, the mTouch button will appear in the Project Resources pane.

ProjectResources.png

5

Select the mTouch Sensors

After loading the mTouch module, all available mTouch sensor pins will be shown in the Pin Manager: Grid View pane. You will need to select the physical sensors based on the sensor pinout information. Choose the sensors in the following order:

  1. RB0
  2. RA2
  3. RA6
  4. RC4
  5. RA7
  6. RC5
  7. RD4
  8. RA0
  9. RB3
  10. RC6
PinManager.png

6

Add mTouch Surface and Link to the Sensors

Go to the Surfaces configuration view, click Create New Surface.

SurfaceSettings.png

Now, based on the surface design configuration, make the changes. Choose Horizontal Key Count as 5 and Vertical Key count as 5 and click Create/Upgrade Grid.

NewSurface.png

7

Enable Debugging with 2D Surface Utility and Configure Universal Asynchronous Receiver Transmitter (UART) Module

Go to the Debug tab within the mTouch module. Check the Enable Debug box, select UART1 to be the UART module, and select 2D Surface Utility as the debug method. The UART module will be automatically added to the project and should appear in the Project Resources window.

SurfaceUtility.png

Click on the UART1 module in the Project Resources window to check that it is configured correctly.

UARTSettings.png

Check that the RX and TX pins are properly selected in the Pin Manager: Grid View. The RX pin should be RB1 and the TX pin should be RB0.

PinGridView.png

8

Configure LEDS through I2C

The LEDs in the QT8 board are driven using the I2C peripheral. Choose the I2C peripheral from the Device Resources menu.

I2C.png

I2C peripheral will be added to the Project Resources.

I2C1.png

Use the Pin Manager: Grid View to select the I2C pins.
SCL – RB1, SDA – RB2

I2CPins.png

9

Generate Code

Click on the Generate button.

Generate.png

10

Call mTouch Service and Enable Interrupts in main.c

Open the generated main.c file. Place MTOUCH_Service_Mainloop() into the while loop as shown in the code block, uncomment the functions that enable interrupts.

Add the files corresponding to the LED driver (led_driver.c, led_driver.h) to the project and call the LED functions correspondingly.
The contents of main.c, led_driver.c, led_driver.h files are shown below.

main.c

led_driver.c:

led_driver.h:

11

Program the Board

After you connect the board to the PC with a USB cable, click the Program button to program the board.

ProgramBoard.png

12

Connect to 2D Surface Utility

Open the 2D Surface GUI, change the Baud rate to 115200 and click Apply.

SurfaceUtilityParameters.png

When a successful connection is established, you will see the live touch data appear in the utility window. This data can be useful for debugging and tuning a touch project.

SurfaceUtilityWindow.png
© 2020 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.