![](/html/0f/0fc8/0fc8dcbde4658ef12fa63c0915f94e1d19aa374b4063cb9410be7318aa5ecfe2/bg1.png)
STM8-TOUCH-LIB
STM8 touch sensing library
Data brief
Features
■ Complete C source code library with firmware
examples for all STM8 microcontrollers
■ Both resistor-capacitor (RC) and charge
transfer (CT) acquisition principles supported
■ Multifunction capability to combine capacitive
sensing functions with traditional MCU features
(communications, LED/beeper/ LCD control)
■ Configuration of STM8 GPIO as touchkey
■ Flexible touchkey/wheel/slider configuration
and combination
– RC acquisition: up to 24 keys and 2
wheels/sliders supported
– CT acquisition: up to 16 keys and 2
wheels/sliders supported
■ Acquisition, filtering and calibration functions
■ Enhanced processing features for optimized
sensitivity and immunity
■ Touch-sensing user interface through firmware
API for status reporting and application
configuration
■ MCU resources
– Minimized number of external components
– Reduced MCU memory space
■ Up to 8-bit wheel/slider resolution with only
three capacitive sensing channels
■ Active shield feature
■ Compliance with MISRA
■ Compliance with Cosmic, IAR and Raisonance
C compilers
Description
STMicroelectronics STM8-TOUCH-LIB is a touch
sensing library that provides a complete robust
free source-code solution to transform any 8-bit
STM8 microcontroller into a capacitive touch
sensing controller. This solution allows designers
familiar with the use of standard microcontrollers
to create higher-end human interfaces by
replacing conventional electromechanical
switches by touch sensing keys.
The STM8 touch sensing library is part of the
application firmware. It allows combining various
capacitive sensing touchkey, wheels or sliders
with traditional MCU features (communications,
control of LEDs, beeper or LCD) in the same
application.
Two acquisition principles, RC and CT, are
available and can be configured at compiling
level. Both acquisition principles offer the same
advanced processing algorithms to filter out noise
and to compensate environmental parameters
such as temperature, humidity, and power supply
variation.
September 2010 Doc ID 17896 Rev 1 1/9
For further information contact your local STMicroelectronics sales office.
www.st.com
9
![](/html/0f/0fc8/0fc8dcbde4658ef12fa63c0915f94e1d19aa374b4063cb9410be7318aa5ecfe2/bg2.png)
Resistor-capacitor (RC) acquisition principle STM8-TOUCH-LIB
1 Resistor-capacitor (RC) acquisition principle
The RC acquisition principle consists in measuring the charge and discharge time duration
of a RC cell made of the electrode capacitance (C
) and a load resistor (RL).
X
The RC acquisition is supported by all STM8S and STM8L microcontrollers and requires a
direct connection of the device to earth to operate properly.
The main features are the following:
● Up to 24 touchkeys distributed over 3 GPIO ports
● Up to 2 wheels or sliders with 2 different hardware implementations (5 or 8 capacitive
sensing channels)
● Capacitive sensing channels are acquired sequentially
2 Charge transfer (CT) acquisition principle
The charge transfer acquisition consists in charging the electrode capacitance (CX) and
transferring part of the accumulated charge into a sampling capacitor (C
repeated until the voltage across C
reaches a given threshold. The number of transfers
S
required to reach the threshold depends on the size of the electrode capacitance. This
acquisition principle provides a better sensitivity and robustness than RC acquisition.
). This sequence is
S
It requires a dedicated hardware composed of analog switches and STM8L MCU.
The charge transfer acquisition is only supported by STM8L101x and STM8L15x devices
since it requires a dedicated hardware composed of analog switches used to interconnect
several GPIOs which is only available on these products.
The main features are the following:
● Number touchkeys supported
– Up to 6 touchkeys on STM8L101x MCUs
– Up to 16 touchkeys on STM8L15x MCUs
● Up to 2 wheels or sliders with a single hardware implementation (3 capacitive sensing
channels)
● Number of capacitive sensing channels acquired simultaneously
– Up to 2 channels on STM8L101x MCUs
– Up to 8 channels on STM8L15x MCUs
2/9 Doc ID 17896 Rev 1
![](/html/0f/0fc8/0fc8dcbde4658ef12fa63c0915f94e1d19aa374b4063cb9410be7318aa5ecfe2/bg3.png)
STM8-TOUCH-LIB Library architecture
CORE
-AIN3TATE
-ACHINE
!0)LAYER
+EYS3TATE
-ACHINE
!PPLICATIONLAYER
4IMEBASE
(7LAYER
3ERVICES
AI
2#ACQUISITION
34-,X
#4ACQUISITION
34-,X
#4ACQUISITION
3 Library architecture
Figure 1 shows the STM8-TOUCH-LIB firmware layers.
Figure 1. STM8-TOUCH-LIB architecture
Doc ID 17896 Rev 1 3/9