Introduction
The CAP1xxx library module will generate the low-level driver code to access the CAP1xxx register. The example code is also provided, showing you how to use the driver in application code.
The CAP1xxx library module is found under the Turnkey Touch library inside the Device Resources window in MPLAB® Code Configurator (MCC). Select the CAP1xxx library module and the I2C module will be added automatically.
Driver Configuration
There are several configuration options for the CAP1xxx driver code, as shown below.
Select Device
Choose the device that the host controller is communicating with.
Device Address
By default, all the CAP1xxx devices use 0x28 as the 7-bit I2C address. Some devices allow assigning different I2C addresses.
Generate Example
You have the option to generate an example code file that shows how to use the CAP1xxx driver in the application code.
I2C
This enables the MCC I2C driver for the device.
ALERT
The CAP1xxx has an ALERT pin to notify the host if an event happened, for example, touch, release, noise, etc.
If the ALERT pin is enabled, you will need to assign a pin on the host to read the ALERT state.
RESET
Some of the CAP1xxx devices feature a RESET pin which is active low.
WAKE
Some of the CAP1xxx devices feature a WAKE pin to wake up the device from Sleep mode. More information can be found on the CAP1xxx datasheet.
Select I2C Master
If the host has multiple I2C peripherals, you can choose the one to talk to the CAP1xxx device.
The I2C Master will need to be configured to support clock stretching in order to communicate with the CAP1xxx device, some of the devices have to do it manually in the I2C module configuration.
Generated Files
The module will generate the CAP1xxx driver and application example code (optional).
- cap1xxx_app.c, cap1xxx_app.h: low-level driver that accesses the register.
- cap11xx.h/cap12xx.h: full register description of the CAP1xxx device.
- cap1xxx_example.c, cap1xxx_example.h: example of how to use the driver in application code.
Code Example
Here are some examples using the driver code (PIC32MM as the host):
Use the example code directly
The example function provides a quick start to verify if the hardware is functional.
Use the driver code
Once the design is functional, you can use the driver code to integrate with your appliation.
Touch Tuning
Microchip recommends using the CAP1xxx GUI for intuitive and efficient tuning.
Application note AN2034 provides guidelines on touch performance tuning.