Capacitive Touch example using the LPC845 Breakout Board

Document created by Miguel Mendoza Employee on Jan 15, 2019Last modified by Miguel Mendoza Employee on Mar 7, 2019
Version 6Show Document
  • View in full screen mode

This blog posting is an introduction to Capacitive Touch provided for the LPC845 MCU device. We are going to take advantages of the features that the LPC845 Breakout Board to show how to interface with the onboard Cap touch button using SDK drivers. 


The Capacitive Touch module measures the change in capacitance of an electrode plate when an earth-ground connected object (for example, the finger or stylus) is brought within close proximity. Simply stated, the module delivers a small charge to an X capacitor (a mutual capacitance touch sensor), then transfers that charge to a larger Y capacitor (the measurement capacitor), and counts the number of iterations necessary for the voltage across the Y capacitor to cross a predetermined threshold.


Mutual Capacitive Touch


Figure 1. Mutual Capacitive Touch


A pulse is applied between the transmitting and receiving electrode to generate an electromagnetic field. When a finger comes into close proximity, part of the electromagnetic field moves to the finger where the decrease in electromagnetic field strength is detected by the electrodes. The capacitance is detected and captured and recognized as a finger presence.


LPC845 MCU Capactive Touch Features

  • Up to nine mutual-capacitance touch sensors.
  • Both GPIO port pin and analog comparator measurement methods are available.
  • DMA for continuous sequential polling of all sensors with no CPU intervention.
  • Wake up from sleep, deep-sleep, and power-down modes.



  • Cap-touch interfaces can be incorporated into products with curved surfaces allowing for greater design flexibility.
  • No moving parts allow for increased durability and reduce the number of components, thus lowering overall costs.
  • Provides a smooth, sleek appearance without raised surfaces or button openings allowing for ease of cleaning and sealed designs.
  • Can be a complete plug-and-play interface or simply a graphic bonded to a cap-touch circuit that interfaces with the microcontroller.


Pin usage

The Capacitive Touch module uses one standard GPIO pin for YL and up to nine standard GPIOs for X0 through XMAX. 


YH, YL, and X functions are typically enabled on their pins using the switch matrix or IOCON, depending on the product family. Additionally, the set of X pins that the application will use must be enabled or identified to the module by writing ‘1’s to their bit positions in the XPINSEL field of the control register.



Programming of all these registers is performed only during initialization.


Capacitive Touch Registers


Table 1. Capacitive Touch Registers.

Capacitive Touch with the LPC845 Breakout Board.


The LPC845 Breakout Board include an on-board Cap Touch button that enables easy evaluation of the capacitive touch features of the LPC84x family of devices.


The connections for the capacitive touch button are shown in Table 2 below. If the Cap Touch button is not being used, the ports connected to it can be used for other purposes (such as GPIO), but note that PIO0_30 and PIO0_31 are effectively shorted together through resistor R19. If this zero ohm resistor may be removed if the Cap Touch button is not required.


Capacitive touch button signals


Table 2. Capacitive touch button signals


Capacitive Touch Example

   What we need:


The NXP example package includes projects to use the principal's peripherals that the board includes: ADC, I2C, PWM, USART, Captouch, and SPI. We are going to use the Captouch example include here, this after an initial calibration, once the cap touch button is touched, the RGB's Red led will turn on.


Once downloaded, we import the library project into the workspace using the ''Import project(s) from file system... from the Quickstart panel in MCUXpresso IDE:


Import projects


Figure 2. Import Projects.


Then browse the examples packages archive file:



Figure 3. Select Example Package.


Press next, and see that are a selection of projects to import, in this case, only keep select the LPC845_BoB_CAPTouch how it looks in the picture below:


Select CapTouch Project


Figure 4. Select CapTouch Project


Now with the project in the workspace, we are going to build and run the example, you are going to see instructions in the IDE console for the calibration. Put your finger in the captouch button and press enter to start the calibration, once finished, you are going to see a message, and with that the demo is ready, you are going to see the RGB red led on when the when the cap touch button is touched and off then it´s not.

1 person found this helpful