Are CSLIB, CAPSENSE, and CSEN the same, an which one should I be using for my application?
These concepts are sometimes used “interchangeably” by customers trying out our development boards, leading to confusion and communication issues. The following KBA aims to provide an introduction to these terms as well as relevant documentation sources if deeper knowledge is required.
From a higher to a lower level, these are the different definitions:
CSLIB is a set of source code and pre-compiled libraries that demonstrate the capacitive sensing functionalities of our devices. At its core, CSLIB can configure and manage multiple low-level peripherals of our MCUs such as ACMP (Analog Comparator), LESENSE (Low Energy Sensor Interface), and CSEN (Capacitive Sense Module).
The sensing technique used in our CSLIB development board examples is dependent on the target device and its available peripherals, e.g., for the SLSTK3402A (EFM32PG12) the CSEN peripheral is used. Other starter kits such as the STK3700 (EFM32GG) didn’t have the CSEN peripheral, therefore, relied on the ACMP (and LESENSE in some instances) for this. We have a KBA that has a small breakdown table on the CSLIB implementation for different STKs.
The CSLIB can operate in conjunction with a Simplicity Studio tool called Capacitive Sense Profiler. Access to the source code of CSLIB is limited, due to the pre-compiled libraries, but the EMLIB implementation (MCU peripherals) is accessible. The available source code can be checked in the Simplicity Studio installation path:
STK CSLIB examples can be found in the following path, under the name "KITNAME_cslib".
For STKs that rely on the ACMP for capacitive sensing measurements, the CSLIB leverages not only the EMLIB peripheral APIs but also the CAPSENSE driver.
Other relevant CSLIB documentation can be found in the following links:
CAPSENSE is a development kit driver used to evaluate capacitive sensing but, contrary to CSLIB, it doesn’t implement any pre-compiled libraries, it instead leverages the EMLIB API for the ACMP peripheral for capacitive sensing. The pins are routed through the APORT (analog port) to the ACMP for measurement purposes.
STK CAPSENSE examples can be found in the following path, under the name "KITNAME_touch".
We have an application note for series 0 devices that explains how ACMP and LESENSE are used for capacitive measurements:
The main difference between CSLIB and CAPSENSE is how the capacitive measurements are performed. In the case of CSLIB it will be based on the available technique in the target STK (CSEN, ACMP+LESENSE, or ACMP). CAPSENSE uses ACMP exclusively. In the case of the STK3402A where both ACMP and CSEN peripherals are available, the available CSLIB example uses the CSEN peripheral but it’s possible to perform the capacitive measurement with any of the 2 peripherals.
The decision of which one to use will be ultimately based on your needs and of course available peripherals.
EMLIB is a series of APIs developed to provide customers with a software layer to access the peripherals of the MCU. This is the closest to direct register access that we have. Every peripheral of an MCU is covered through a specific EMLIB API. The documentation for all of them can be found in the following link.
EMLIB is usually implemented in all the middleware or high-level drivers developed for our development kits (such as CAPSENSE and CSLIB).
CSEN and ACMP are both peripherals of our MCUs. The CSEN peripheral was designed specifically for capacitance to digital conversions whereas ACMP was developed to work with all kinds of analog inputs. The best way to understand a peripheral is usually through consultation of the corresponding chapter in the reference manual and cross-referencing with our peripheral examples.
Note that our peripheral examples repository doesn’t have an example for the CSEN peripheral, but its implementation can be abstracted from the CSLIB examples.