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 2010Doc ID 17896 Rev 11/9
For further information contact your local STMicroelectronics sales office.
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/9Doc ID 17896 Rev 1
STM8-TOUCH-LIBLibrary 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 13/9
MCU resourcesSTM8-TOUCH-LIB
4 MCU resources
Tab le 1 shows the STM8 peripherals that are used by the STM8-TOUCH-LIB. Care must be
taken when using them to avoid any misbehavior.
Table 1.List of STM8 peripherals used by the STM8-TOUCH-LIB
PeripheralFunctionAcquisition principle
GPIOsI/O controlRC, CT
16-bit timer with 8-bit prescaler
(TIM2 or TIM3)
8-bit timer (TIM4)
Comparator (COMP)Charge transferCT
Routing interface (RI)I/O control and charge transferCT
4.1 Number of charge transfer capacitive sensing channels
measurementRC
V
IH/VIL
Generic timebase for the state
machine
RC, CT
Tab le 2 and Ta b l e 3 provide the maximum number of charge-transfer capacitive sensing
channels for the STM8L101x and STM8L15x package, respectively.
Table 2.STM8L101x resources used for CT acquisition
group
Acquisition
Group
1
Group
2
Maximum number
of channels
TSSOP20 / UFQFPN20WFQFPN28VFQFPN32 / LQFP32
I/O port
TSSOP pin
PB0107
PB11181314
PD09689
PD1--910
PB2129
PB313101516
PD2--1011
pin
UFQFPN
Number of
3
2
available
pins
channels
with one
sampling
capacitor
1 channel
with one
sampling
capacitor
Usage
2
Pin
12
14
PD3--1112
3
with 2 sampling capacitors
pins
available
Number of
channels
4
with one
sampling
capacitor
channels
4
with one
sampling
capacitor
6
with 2 sampling
capacitors
Usage
3
Pin
13
Number of
pins
available
Usage
3
channels
4
with one
sampling
capacitor
15
3
3
channels
4
with one
sampling
capacitor
6
with 2 sampling
capacitors
4/9Doc ID 17896 Rev 1
STM8-TOUCH-LIBMCU resources
Table 3.STM8L15x resources used for CT acquisition
The STM8-TOUCH-LIB size depends on the following parameters:
●Acquisition principle (RC or CT)
●C compiler and options: memory model, size or speed optimization
●Number of capacitive sensing channels used and type (touchkey or/and wheel or
slider)
For further information on memory resources for RC and CT acquisition, refer to
Section 5.1.
5.1 RC acquisition memory resources
Prerequisites
●COSMIC STM8 C Compiler 16-KByte version release 4.3.1 dated 02 July 2009
●Compiler options: +modsl0 +compact +split
●Sections counted for RAM: ZRAM_TSL_IO + ZRAM_TSL + ZRAM_TSLMCK +
RAM_TSL_IO + RAM_TSL + RAM_TSLMCK
●Sections counted for ROM: CODE_TSL_IO + CONST_TSL_IO + CONST_TSL +
CONST_TSLMCK + CODE_TSL + CODE_TSLMCK
RAM and ROM requirements
Tab le 4 gives the RAM and ROM memory space required to use the STM8-TOUCH-LIB for
RC acquisition.
Table 4.Typical RAM and ROM memory space required for RC acquisition
Configuration RAM (bytes) ROM (bytes)
STM8S207
5x single-channel keys
STM8L101x
3x single-channel keys
~120 ~2350
~90~2350
5.2 CT acquisition memory resources
Prerequisites
●COSMIC STM8 C Compiler 16-Kbyte version release 4.3.1 dated 02 July 2009
●Compiler options: +modsl0 +compact +split
●Sections counted for RAM: ZRAM_TSL_IO + ZRAM_TSL + ZRAM_TSLMCK +
RAM_TSL_IO + RAM_TSL + RAM_TSLMCK
●Sections counted for ROM: CODE_TSL_IO + CONST_TSL_IO + CONST_TSL +
CONST_TSLMCK + CODE_TSL + CODE_TSLMCK
6/9Doc ID 17896 Rev 1
STM8-TOUCH-LIBMemory resources
RAM and ROM requirements
Tab le 4 gives the RAM and ROM memory space required to use the STM8-TOUCH-LIB for
CT acquisition.
Table 5.Typical RAM and ROM memory space required for CT acquisition
Configuration RAM (bytes) ROM (bytes)
STM8L101x
3x single-channel keys
STM8L15X
10x single-channel keys
STM8L15X
10x single-channel keys +
1x multichannel key
~90~1800
~220~1700
~280~4200
Doc ID 17896 Rev 17/9
Revision historySTM8-TOUCH-LIB
6 Revision history
Table 6.Document revision history
DateRevisionChanges
27-Sep-20101Initial release.
8/9Doc ID 17896 Rev 1
STM8-TOUCH-LIB
Please Read Carefully:
Information in this document is provided solely in connection with ST products. STMicroelectronics NV and its subsidiaries (“ST”) reserve the
right to make changes, corrections, modifications or improvements, to this document, and the products and services described herein at any
time, without notice.
All ST products are sold pursuant to ST’s terms and conditions of sale.
Purchasers are solely responsible for the choice, selection and use of the ST products and services described herein, and ST assumes no
liability whatsoever relating to the choice, selection or use of the ST products and services described herein.
No license, express or implied, by estoppel or otherwise, to any intellectual property rights is granted under this document. If any part of this
document refers to any third party products or services it shall not be deemed a license grant by ST for the use of such third party products
or services, or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoever of such
third party products or services or any intellectual property contained therein.
UNLESS OTHERWISE SET FORTH IN ST’S TERMS AND CONDITIONS OF SALE ST DISCLAIMS ANY EXPRESS OR IMPLIED
WARRANTY WITH RESPECT TO THE USE AND/OR SALE OF ST PRODUCTS INCLUDING WITHOUT LIMITATION IMPLIED
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE (AND THEIR EQUIVALENTS UNDER THE LAWS
OF ANY JURISDICTION), OR INFRINGEMENT OF ANY PATENT, COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT.
UNLESS EXPRESSLY APPROVED IN WRITING BY AN AUTHORIZED ST REPRESENTATIVE, ST PRODUCTS ARE NOT
RECOMMENDED, AUTHORIZED OR WARRANTED FOR USE IN MILITARY, AIR CRAFT, SPACE, LIFE SAVING, OR LIFE SUSTAINING
APPLICATIONS, NOR IN PRODUCTS OR SYSTEMS WHERE FAILURE OR MALFUNCTION MAY RESULT IN PERSONAL INJURY,
DEATH, OR SEVERE PROPERTY OR ENVIRONMENTAL DAMAGE. ST PRODUCTS WHICH ARE NOT SPECIFIED AS "AUTOMOTIVE
GRADE" MAY ONLY BE USED IN AUTOMOTIVE APPLICATIONS AT USER’S OWN RISK.
Resale of ST products with provisions different from the statements and/or technical features set forth in this document shall immediately void
any warranty granted by ST for the ST product or service described herein and shall not create or extend in any manner whatsoever, any
liability of ST.
ST and the ST logo are trademarks or registered trademarks of ST in various countries.
Information in this document supersedes and replaces all information previously supplied.
The ST logo is a registered trademark of STMicroelectronics. All other names are the property of their respective owners.