CAP1xxx Library User's Guide


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.


This enables the MCC I2C driver for the device.


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.


Some of the CAP1xxx devices feature a RESET pin which is active low.


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.

© 2024 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.