dm00075710 Stmtouch Driver User Manual Stmicroelectronics
dm00075710 Stmtouch Driver User Manual Stmicroelectronics
User manual
STMTouch driver user manual
Introduction
The document covers the following touch sensing library product codes:
• STM8L-TOUCH-LIB
• STM8TL-TOUCH-LIB
• 32L1-TOUCH-LIB
• 32F0-TOUCH-LIB
• 32F3-TOUCH-LIB
Contents
2 STMTouch driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.1 Supported devices and development tools . . . . . . . . . . . . . . . . . . . . . . . 13
2.1.1 Supported devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.1.2 Development tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.2 Package description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.3 Main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.4 Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.4.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.4.2 STMTouch driver layers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.4.3 Acquisition and processing layers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.4.4 Header files inclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.5 Channel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.5.1 Principle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.5.2 Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.5.3 Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.5.4 Usage example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.6 Bank . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.6.1 Principle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.6.2 Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.6.3 Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.6.4 Usage example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.7 Zone . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
2.7.1 Principle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
2.7.2 Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
2.7.3 Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
2.7.4 Usage example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
2.8 Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
2.8.1 Principle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
2.8.2 Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
2.8.3 Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
2.8.4 Usage example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
2.9 Touchkey sensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2.9.1 Principle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2.9.2 Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2.9.3 Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
2.9.4 Usage example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
2.10 Linear and rotary sensors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.10.1 Principle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.10.2 Number of channels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.10.3 Delta coefficient table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.10.4 Electrodes placement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
2.10.5 Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
2.10.6 Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
2.10.7 Usage example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
2.11 Main state machine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
2.12 Sensors state machine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
2.12.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
2.12.2 States constant table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
2.12.3 States detail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
2.12.4 Calibration state . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
2.12.5 RELEASE state . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
2.12.6 Proximity state . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
2.12.7 DETECT state . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
2.12.8 TOUCH state . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
2.12.9 ERROR state . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
2.12.10 OFF state . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
2.12.11 Debounce states . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
List of tables
List of figures
1.1 Glossary
The table below summarizes all the terms and acronyms used inside this user manual.
1.3.1 General
• Source code complies with ANSI C standard.
• No warning after compilation. Any warnings that cannot be eliminated are commented
in the source code.
• ANSI standard data types are used and defined in the ANSI C header file <stdint.h>.
• No blocking code is present and all required waiting loops (polling loops) are controlled
by a timeout.
1.5.1 Generalities
The C programming language is growing in importance for embedded systems. However,
when it comes to developing code for safety-critical applications, this language has many
drawbacks. There are several unspecified, implementation-defined, and undefined aspects
of the C language that make it unsuited for developing safety-critical systems.
The motor industry software reliability association's guidelines for the use of the C language
in critical systems (MISRA-C 2004 [1]) describe a subset of the C language well suited for
developing safety-critical systems.
The STMTouch driver has been developed to be MISRA-C 2004 compliant.
The following section describes how the STMTouch driver complies with MISRA-C 2004 (as
described in section 4.4 Claiming compliance of the standard [1]):
• A compliance matrix has been completed which shows how compliance has been
enforced.
• The whole STMTouch driver source code is compliant with MISRA-C 2004 rules.
• Deviations are documented. A list of all instances of rules not being followed is being
maintained, and for each instance there is an appropriately signed-off deviation.
• All the issues listed in section 4.2 “The programming language and coding context of
the standard” [1], that need to be checked during the firmware development phase,
have been addressed during the development of the STMTouch driver and appropriate
measures have been taken.
2 STMTouch driver
a. Arm is a registered trademark of Arm Limited (or its subsidiaries) in the US and/or elsewhere
2.4 Architecture
2.4.1 Overview
The following figure shows the interactions between the STMTouch driver and the other
firmware layers.
$SSOLFDWLRQ 8VHUDSSOLFDWLRQVH[DPSOHV
OD\HU
6707RXFKGULYHU
+DUGZDUH
DEVWUDFWLRQOD\HU
+$/
6WDQGDUGSHULSKHUDOVOLEUDU\
+DUGZDUH
0&8
OD\HU
06Y9
The HAL is the hardware abstraction layer (HAL) which controls the device itself through
hardware registers.
It is composed of different components:
• The STMTouch driver
• The standard peripherals library
• The CMSIS firmware (for STM32 devices only)
• Utilities and third-parties firmwares
Note: The STMTouch driver can access directly to the MCU hardware registers using the map file
provided by the standard peripherals library.
$SSOLFDWLRQ 6707RXFKGULYHU
OD\HU 8VHUDSSOLFDWLRQ
FRQILJXUDWLRQ
3URFHVVLQJ
OD\HU
(&6 )LOWHUV
6707RXFK
GULYHU
7RXFKNH\ /LQHDUDQG
VHQVRU URWDU\VHQVRUV
$FTXLVLWLRQ $F
$FTXLVLWLRQ
FT$FTXLVLWLRQ
XLVLWLRQ $FTXLVLWLRQ
OD\HU 0&8
0
0&80&8
0&8
6WDQGDUGSHULSKHUDOV
OLEUDU\
06Y9
&KDQQHO
GDWDOD\HU
VHQVRUV
(&6
';6
3URFHVVLQJ WRXFKNH\ OLQHDUURWDU\ '72
OD\HU )LOWHUV
7LPLQJ
06Y9
The acquisition layer role is to perform the acquisition of the different channels. The result
of the acquisition (measure and flags) is stored inside the channel data layer. These
informations will be accessed by the processing layer.
The acquisition layer has only access to the channel, bank and zone elements. It does not
have access to the sensor elements.
The channel data layer role is to share information between the acquisition and processing
layers. It stores the result of the acquisition (measure) for each channel and store different
informations coming from the processing layer (reference, delta, flags, etc...).
Located in RAM, the ChannelData structure is the only interface between the acquisition
and processing layers.
This processing layer consists in executing each sensors state machine, executing the
different data processing like ECS, DXS, DTO and storing any useful information for the
acquisition layer inside the channel data area.
The processing layer does not have direct access to the channels, banks and zones. This
access is made through the sensors.
$SSOLFDWLRQ
PDLQK WVOBFRQIBPFX!K
OD\HU
WVOBILOWHUK
WVOBHFVK
WVOBREMHFWK
6707RXFK
WVOK WVOBWRXFKNH\K
GULYHU
WVOBOLQURWK
WVOBDFTK WVOBDFTBPFX!K
WVOBW\SHVK
WVOBWLPHK WVOBWLPHBPFX!K
WVOBJOREDOVK
6WDQGDUG
SHULSKHUDO PFX!KPDSSLQJILOH
OLEUDU\
06Y9
2.5 Channel
2.5.1 Principle
A channel is the basic element that is used to store several information like:
• where the source measurement can be found after the acquisition is performed (i.e. RX
registers for STM8TL5x devices or TSC_IOGxCR registers for
STM32F0xx/STM32F3xx devices)
• where are stored the measure, the reference, the delta, flags etc...
2.5.2 Resources
A channel is defined by 3 data structures:
• TSL_ChannelSrc_T: contains all information about the source measurement (index of
the register containing the measurement, masks,...)
• TSL_ChannelDest_T: contains all information about the measurement destination
(index in the channel data array).
• TSL_ChannelData_T: contains all data for the channel (measure, delta, reference, ...)
The channel depends on the acquisition technology. This is why the contents of this
structures are not common for all acquisitions. They are declared in each acquisition header
files (tsl_acq_<mcu>.h):
• tsl_acq_stm8l_hw.h for STM8L devices using hardware acquisition mode
• tsl_acq_stm8l_sw.h for STM8L devices using software acquisition mode
• tsl_acq_stm8tl5x.h for STM8TL5x devices
• tsl_acq_stm32l1xx_hw.h for STM32L1xx devices using the hardware acquisition
mode
• tsl_acq_stm32l1xx_sw.h for STM32L1xx devices using the software acquisition mode
• tsl_acq_stm32f0xx.h for STM32F0xx devices
• tsl_acq_stm32f3xx.h for STM32F3xx devices
The maximum number of channels is only limited by the device (memory size and channels
supported).
The user must declare all the channels array in its application code. It can be done directly
in the main.c file or in any other file.
2.5.3 Parameters
• TSLPRM_TOTAL_CHANNELS
Example of channel destination array declaration for STM32F0xx devices. This structure
must always be placed in ROM.
const TSL_ChannelDest_T MyChannels_Dest[TSLPRM_TOTAL_CHANNELS] =
{ { CHANNEL_0_DEST },
{ CHANNEL_1_DEST },
{ CHANNEL_2_DEST }};
Note: The "CHANNEL_x_SRC" and "CHANNEL_x_DEST" are "#define" constants and are used
for readability. The values are acquisition dependant.
Example of channel data array declaration (i.e. channel data layer). This structure must
always be placed in RAM.
TSL_ChannelData_T MyChannels_Data[TSLPRM_TOTAL_CHANNELS];
Example:
%DQN %DQN
&KDQQHO
GDWDOD\HU &+ &+ &+ &+ &+ &+ &+
06Y9
2.6 Bank
2.6.1 Principle
A bank is a group of channels that are acquired simultaneously. The number of channels in
the bank is variable.
2.6.2 Resources
The bank data are held by only one structure:
• TSL_Bank_T
• The bank depends also on the acquisition technology. These structures are declared in
each acquisition header files (tsl_acq_<mcu>.h):
The maximum number of banks is only limited by the device.
The user must declare all the banks array in its application code. It can be done directly in
the main.c file or in any other file.
The banks are used mainly by the functions described below. Some functions are common
whatever the device and acquisition technology. Some others are dependent on the device.
Common functions:
• TSL_acq_BankGetResult()
• TSL_acq_BankCalibrate()
Device dependent functions:
• TSL_acq_BankConfig()
• TSL_acq_BankStartAcq()
• TSL_acq_BankWaitEOC()
2.6.3 Parameters
• TSLPRM_TOTAL_BANKS
// Bank 1
&MyChannels_Src[4],
&MyChannels_Dest[4],
MyChannels_Data,
BANK_1_NBCHANNELS,
// For STM8TL5x acquisition only
BANK_1_MSK_CHANNELS,
BIT_MASK_TX(BANK_1_TX),
BANK_1_GROUP,
#if (BANK_1_MSK_TX < 0x8000) // a TX pin is used as transmitter
BANK_1_MSK_CHANNELS,
#else // a RX pin is used as transmitter
(BIT_MASK_RX(BANK_1_TX)| BANK_1_MSK_CHANNELS),
#endif
};
The "BANK_x_NBCHANNELS", "BANK_x_MSK_CHANNELS", "BIT_x_MASK_TX", etc...
are defines and are used for readability. These values are for STM8TL5x devices acquisition
only.
2.7 Zone
2.7.1 Principle
A zone is an ordered group of banks. It is used to easily cascade the acquisition of many
banks. The acquisition of the next bank in a zone is launched directly in the interrupt routine
managing the acquisition result of the current acquired bank.
2.7.2 Resources
This feature is optional and is enabled/disabled using the TSLPRM_USE_ZONE parameter.
The zone data are held by only one structure:
• TSL_Zone_T
The zones are used mainly by the function:
• TSL_acq_ZoneConfig()
2.7.3 Parameters
• TSLPRM_USE_ZONE
2.8 Objects
2.8.1 Principle
The term “object” or “sensor” stands for any sensors type (touchkeys, linear and rotary
touch sensors, etc...) supported by the STMTouch driver.
2.8.2 Resources
All processing that affect the sensors in general are defined in:
• tsl_object.c
• tsl_object.h
The functions are:
• TSL_obj_GroupInit()
• TSL_obj_GroupProcess()
• TSL_obj_SetGlobalObj()
A sensor is described by the structures:
• TSL_Object_T
• TSL_ObjectGroup_T
2.8.3 Parameters
• TSLPRM_TOTAL_OBJECTS
2.9.1 Principle
The touchkey sensor is composed of only one channel. It acts as a simple “button” with two
states RELEASE and DETECT (or TOUCH if DXS is enabled).
2.9.2 Resources
All the functions related to this sensor are described in the files:
• tsl_touchkey.c
• tsl_touchkey.h
2.9.3 Parameters
• TSLPRM_TOTAL_TKEYS
2.10.1 Principle
The linear and rotary sensors are like a touchkey sensor except that they are composed of a
variable number of channels. The difference between the linear and rotary touch sensors is
how the electrodes are organized together.
The linear and rotary sensors have additional fields in their structure compared to touchkey
sensors:
• Number of channels
• Delta coefficient table
• Position offset table
• Sector computation parameter
• Position correction parameter for linear sensor
The last 3 fields are used to calculate the position.
,ĂůĨͲĞŶĚĞĚ >/Eͺ,
ĞůĞĐƚƌŽĚĞƐ
ĚĞƐŝŐŶ ĐŚϭ ,Ϯ ,ϯ ĐŚϭ
ZKdͺ
ƵĂů
ĞůĞĐƚƌŽĚĞƐ Ͳ
ĚĞƐŝŐŶ
06Y9
/,1B0 /,1B0
&+ &+
FK &+ &+ &+ FK
&+ &+
/,1B+
/,1B' 527B0
527B' 06Y9
The following table summarizes the different linear and rotary sensors electrodes designs
supported by the STMTouch driver:
2.10.5 Resources
All the functions related to this sensor are described in the files:
• tsl_linrot.c
• tsl_linrot.h
Two types of linear and rotary sensor are available:
• basic: defined by the TSL_LinRotB_T structure
• extended: defined by the TSL_LinRot_T structure
The difference between “basic” and “extended” is the same as for the touchkey sensor.
Three functions (called methods) are used to initialized the sensor parameters, run the
sensor state machine and calculate the position.
• TSL_linrot_Init()
• TSL_linrot_Process()
• TSL_linrot_CalcPos()
2.10.6 Parameters
• TSLPRM_TOTAL_LINROTS
The declaration of the linear and rotary sensor is done by the user in the application code in
the same manner as for touchkey sensor.
Example with 2 “basic” linear touch sensors, one with 3 channels half-ended and the other
with 5 channels mono electrodes design:
CONST TSL_LinRotB_T MyLinRots[2] =
{
// LinRot sensor 0
&MyLinRots_Data[0],
&MyLinRots_Param[0],
&MyChannels_Data[CHANNEL_9_DEST],
3, // Number of channels
MyLinRot0_DeltaCoeff, // Delta coefficient table
(TSL_tsignPosition_T *)TSL_POSOFF_3CH_LIN_H, // Position table
TSL_SCTCOMP_3CH_LIN_H, // Sector compensation
TSL_POSCORR_3CH_LIN_H, // Position correction
// LinRot sensor 1
&MyLinRots_Data[1],
&MyLinRots_Param[1],
&MyChannels_Data[CHANNEL_12_DEST],
5, // Number of channels
MyLinRot1_DeltaCoeff, // Delta coefficient table
(TSL_tsignPosition_T *)TSL_POSOFF_5CH_LIN_M2, // Position table
TSL_SCTCOMP_5CH_LIN_M2, // Sector compensation
TSL_POSCORR_5CH_LIN_M2 // Position correction
};
Example of one “extended” (i.e. having its own state machine and methods) linear touch
sensor with 3 channels half-ended:
CONST TSL_LinRot_T MyLinRots[1] =
{
// LinRot sensor 0
&MyLinRots_Data[0],
&MyLinRots_Param[0],
&MyChannels_Data[CHANNEL_0_DEST],
3, // Number of channels
MyLinRot0_DeltaCoeff,
(TSL_tsignPosition_T *)TSL_POSOFF_3CH_LIN_H,
TSL_SCTCOMP_3CH_LIN_H,
TSL_POSCORR_3CH_LIN_H,
MyLinRots_StateMachine, // Specific state machine
&MyLinRots_Methods // Specific methods
};
Example of one “extended” rotary touch sensor with 3 channels mono electrode design:
CONST TSL_LinRot_T MyLinRots[0] =
{
// LinRot sensor 0
&MyLinRots_Data[0],
&MyLinRots_Param[0],
&MyChannels_Data[CHANNEL_0_DEST],
3, // Number of channels
MyLinRot0_DeltaCoeff,
(TSL_tsignPosition_T *)TSL_POSOFF_3CH_ROT_M,
TSL_SCTCOMP_3CH_ROT_M,
0, // No position correction needed on a Rotary sensor
MyLinRots_StateMachine, // Specific state machine
&MyLinRots_Methods // Specific methods
};
&KDQQHOVEDQNV]RQHVVHQVRUV
FRQILJXUDWLRQ
%DQNFRQILJXUDWLRQ
%DQNVDQGVHQVRUVLQLWLDOL]DWLRQ
%DQN
VWDUWDFTXLVLWLRQ
%DQNDFTXLVLWLRQ
%DQNZDLWHQG
DFTXLVLWLRQ
6HQVRUVSURFHVVLQJ %DQNJHWUHVXOW
(&6';6
8VHUDSSOLFDWLRQ
06Y9
Note: The debouncing, Detection Time Out and re-calibration are automatically performed inside
this step.
5. The ECS, DXS step is used to execute other algorithms that are not performed in the
sensor state machine like the ECS, DXS, other filters, etc... This step is optional and it
can be executed at certain time intervals (mainly for ECS).
6. The user application step is used to execute the application layer (read the sensors
state, decide which actions to perform, manage ERROR states, etc...). The user
application can also be placed between other steps, for example it can be done
between the “sensors processing” step and the "ECS/DXS".
There are multiple manners to perform the main state machine. The following figures show
some examples with two banks.
%DQN
%DQN
%DQN
%DQN
(&6 (&6
';6 ';6
06Y9
2.12.1 Overview
The state machine is managed in the files:
• tsl_touchkey.c and tsl_touchkey.h for the touchkey sensors
• tsl_linrot.c and tsl_linrot.h for the linear and rotary sensors
GHE
5(/($6(7
GHE
5(/($6('
GHE
5(/($6(3
,QLW
GHE
'(7(&7 ';6
GHE GHE
&$/,% 5(/($6( 352; '(7(&7 728&+
&$/,% 352;
GHE
352;
'(7(&7 GHE
352;
728&+
GHE
(5525 8VHU
GHFLVLRQ
(5525 2))
06Y9
/* 3 */ { TSL_STATEMASK_DEB_RELEASE_PROX,
TSL_tkey_DebReleaseProxStateProcess },
#else
/* 3 */ { TSL_STATEMASK_DEB_RELEASE_PROX, 0 },
#endif
/* 4 */ { TSL_STATEMASK_DEB_RELEASE_DETECT,
TSL_tkey_DebReleaseDetectStateProcess },
/* 5 */ { TSL_STATEMASK_DEB_RELEASE_TOUCH,
TSL_tkey_DebReleaseTouchStateProcess },
#if TSLPRM_USE_PROX > 0
// Proximity states
/* 6 */ { TSL_STATEMASK_PROX, TSL_tkey_ProxStateProcess },
/* 7 */ { TSL_STATEMASK_DEB_PROX, TSL_tkey_DebProxStateProcess },
/* 8 */ { TSL_STATEMASK_DEB_PROX_DETECT,
TSL_tkey_DebProxDetectStateProcess },
/* 9 */ { TSL_STATEMASK_DEB_PROX_TOUCH,
TSL_tkey_DebProxTouchStateProcess },
#else
/* 6 */ { TSL_STATEMASK_PROX, 0 },
/* 7 */ { TSL_STATEMASK_DEB_PROX, 0 },
/* 8 */ { TSL_STATEMASK_DEB_PROX_DETECT, 0 },
/* 9 */ { TSL_STATEMASK_DEB_PROX_TOUCH, 0 },
#endif
// DETECT states
/* 10 */ { TSL_STATEMASK_DETECT, TSL_tkey_DetectStateProcess },
/* 11 */ { TSL_STATEMASK_DEB_DETECT, TSL_tkey_DebDetectStateProcess
},
// TOUCH state
/* 12 */ { TSL_STATEMASK_TOUCH, TSL_tkey_TouchStateProcess },
// ERROR states
/* 13 */ { TSL_STATEMASK_ERROR, MyTKeys_ErrorStateProcess },
/* 14 */ { TSL_STATEMASK_DEB_ERROR_CALIB, TSL_tkey_DebErrorStateProcess
},
/* 15 */ { TSL_STATEMASK_DEB_ERROR_RELEASE, TSL_tkey_DebErrorStateProcess
},
/* 16 */ { TSL_STATEMASK_DEB_ERROR_PROX, TSL_tkey_DebErrorStateProcess
},
/* 17 */ { TSL_STATEMASK_DEB_ERROR_DETECT, TSL_tkey_DebErrorStateProcess
},
/* 18 */ { TSL_STATEMASK_DEB_ERROR_TOUCH, TSL_tkey_DebErrorStateProcess
},
// Other states
/* 19 */ { TSL_STATEMASK_OFF, MyTKeys_OffStateProcess }
};
The STMTouch driver contains all the functions needed to manage each state. However the
user can copy and adapt one or several functions to fit its application requirements.
Example:
/* 0 */ { TSL_STATEMASK_CALIB, MyTkeys_CalibrationStateProcess },
Note: The two functions used to manage the ERROR and OFF states are not part of the
STMTouch driver. These functions are managed by the application.
For linear and rotary sensor state machine, it is the same principle. The functions used to
manage each state start with the prefix “TSL_linrot_”:
CONST TSL_State_T MyLinRots_StateMachine[] =
{
// Calibration states
/* 0 */ { TSL_STATEMASK_CALIB, TSL_linrot_CalibrationStateProcess },
UM1606
The two tables below show the detail of how each state is entered following the thresholds measured.
Delta
deb PROX
or
DETECT OUT Th PROX+DTO
same
or
CALIB if DTO deb PROX- deb PROX-
PROX IN Th RELEASE
DETECT TOUCH
same or same
or or
ERROR
PROX+DTO PROX+DTO
deb deb
RELEASE- RELEASE-
same DETECT TOUCH
PROX OUT Th or or
RELEASE RELEASE
deb RELEASE- deb RELEASE- deb RELEASE-
PROX DETECT TOUCH
or or or
CALIB Th
deb CALIB deb CALIB RELEASE RELEASE RELEASE
or or
CALIB CALIB
STMTouch driver
deb ERROR deb ERROR deb ERROR deb ERROR deb ERROR deb ERROR deb ERROR deb ERROR
if
or or or or or or or or same
ACQ ERROR
ERROR ERROR ERROR ERROR ERROR ERROR ERROR ERROR
39/10
Table 5. Detailed sensors states 2/2
40/10
STMTouch driver
2,2p,6,10,
Previous state 6 10 10p,8 12 12p,9 2p,11p 10p 12p 2 2p,6,7 2,2p 10p,12,12p
,0
Delta
same same
PROX OUT Th or or
RELEASE RELEASE
RELEASE RELEASE
deb deb
same same same RELEASE- RELEASE-
or or or DETECT TOUCH
CALIB Th RELEASE RELEASE RELEASE or or
same
RELEASE RELEASE
or
CALIB
if
PROX DETECT DETECT TOUCH TOUCH RELEASE DETECT TOUCH RELEASE RELEASE RELEASE ERROR
ACQ ERROR
UM1606
UM1606 STMTouch driver
Calibration delay
If a noise filter is used it should be necessary to wait a certain amount of measurement
samples before to start the reference calculation. This number of samples to wait is defined
by the TSLPRM_CALIB_DELAY parameter.
Re-calibration
If the calibration threshold is reached while in RELEASE state, a new calibration is
performed. This “re-calibration” prevents the application to get stuck if something touches
permanently the sensor like a drop of water for example.
2.13.1 Principle
Power supply voltage, temperature and air humidity, may induce a slow variation of the
measured signal. The Environment Change System (ECS) is used to adapt the reference to
these environment changes.
The ECS processing is based on an infinite response digital low pass filter of the first order
(IIR filter):
Y(n ) = K × X( n) + (1 – K ) × Y(n – 1 )
with:
Y = reference
X = acquisition value (last measurement)
K = coefficient.
The higher value is K, the faster is the response time. Two default K coefficients are
available to obtain fast and slow responses.
The sampling frequency is programmable using a timing utility routine (see example below).
If the sensor is in PROX, DETECT or TOUCH states, the ECS is disabled for the duration of
the detection timeout or for the duration of the touch (whichever ends first).
When the ECS is disabled, Yn=Yn-1
As soon as the recalibration times out or the detection ends, the filter is set active again.
2.13.2 Resources
The ECS functions are provided in the files:
• tsl_ecs.c
• tsl_ecs.h
The functions are:
• TSL_ecs_Process(): main function to be used by the user
• TSL_ecs_CalcK(): additional function
• TSL_ecs_ProcessK(): additional function
2.13.3 Parameters
• TSLPRM_ECS_K_FAST
• TSLPRM_ECS_K_SLOW
• TSLPRM_ECS_DELAY
2.14.1 Principle
The DXS processing is used to prevent several sensors to be in the DETECT state at the
same time. This could happen if the sensors are closed to each other or if their sensitivity is
too high. This can be useful also in some applications to prevent the user to touch at the
same time several sensors with "opposite" meaning (volume up and volume down for
example).
The first sensor in the group of sensors has the priority and enters in the DETECT state
(with the DxSLock flag set). The other sensors are “blocked” and enter instead in the
TOUCH state.
Note: A particular care must be taken when designing sensors that are shared between multiple
DXS groups. The sensor that will be assigned in the DETECT state depends on the sensors
position in the DXS groups and also on the order of the DXS groups processing. See the
examples 1 and 2 for more detail.
The figure below illustrates the difference in behavior for a group of 3 sensors (touchkeys)
when the DXS is OFF and ON. The three touchkeys are part of the same DXS group.
Note: The touchkeys can be replaced by a linear or a rotary sensor.
WLPH
WLPH
7.H\KDVWKHSULRULW\ 7.H\WDNHV 7.H\LVDOVR 7.H\WDNHV
7.H\LV³EORFNHG´
7NH\LV³EORFNHG´ WKHSULRULW\ ³EORFNHG´ WKHSULRULW\
06Y9
We can see in the step DXS5 that the sensor 2 (s2) goes in DETECT state instead of the
sensor 3 (s3). This is simply because s2 is placed first in the group2.
6
6 6 6 6 6
5(/($6( 5(/($6( 728&+ 728&+ '(7(&7
6 6 6 6 6
5(/($6( 5(/($6( 5(/($6( '(7(&7 728&+
WLPH
06Y9
6 6
'(7(&7 5(/($6(
JURXS JURXS
6 6 6 6
728&+ '(7(&7 '(7(&7 728&+
6 6
'(7(&7 728&+
';6 ';6
WLPH
06Y9
2.14.2 Resources
The DXS functions are provided in the files:
• tsl_dxs.c
• tsl_dxs.h
The functions to use are:
• TSL_dxs_FirstObj()
2.14.3 Parameters
• TSLPRM_USE_DXS
The DXS processing is performed on a group of sensors defined by the user. Different
groups of DXS can be created.
It's up to the user to decide the best partitioning for his application.
Example:
int main(void) {
while (1) {
...
TSL_obj_GroupProcess(&MyObjGroup1);
TSL_obj_GroupProcess(&MyObjGroup2);
TSL_dxs_FirstObj(&MyObjGroup1);
TSL_dxs_FirstObj(&MyObjGroup2);
...
}
}
2.15.1 Principle
The Detection Time Out (DTO) introduces a simple way to cope with water film and any
obstacle that may come in contact with a sensor. It introduces a maximum duration for the
'detected' state of any sensor called the Detection Time Out (DTO).
After this period of time, the sensor is automatically recalibrated. This allows to make the
sensor touch sensitive again, even if the obstacle or the liquid film is still present on the
board.
This feature is application dependent and the time out must be tuned according to the user
interface specifications.
The DTO is applied on the PROX, DETECT and TOUCH states and can be disabled.
2.15.2 Resources
The DTO functions are provided in the files:
• tsl_touchkey.c
• tsl_touchkey.h
• tsl_linrot.c
• tsl_linrot.h
The functions used by the DTO are:
• TSL_tkey_DTOGetTime()
• TSL_linrot_DTOGetTime()
• TSL_tim_CheckDelay_sec()
Note: The user doesn't need to call these functions to perform the DTO.
2.15.3 Parameters
• TSLPRM_DTO
2.15.4 Usage
The DTO is automatically performed inside the sensor state machine. The user doesn't
need to call any function in the application code.
The DTO is disabled by writing zero in the TSLPRM_DTO parameter.
2.16.1 Principle
The STMTouch driver has been designed to facilitate the implementation of different noise
filters. These filters can be used for many purpose and can range from very simple design to
very complicated.
2.16.2 Resources
The filters are defined in the files:
• tsl_filter.c
• tsl_filter.h
Each filter is described by a function:
• TSL_filt_MeasFilter(): filter on measurement values
• TSL_filt_DeltaFilter(): filter on delta values
2.16.3 Parameters
There is no parameter for the filter module.
2.16.4 Usage
The filter functions can be called at anytime in the main application. In order to speed-up the
execution time and to gain RAM space, the measure and delta filters are called by the
TSL_acq_BankGetResult() function.
Examples:
// Apply a filter on the measures only
TSL_acq_BankGetResult(0, TSL_filt_MeasFilter, 0);
// Get the measures without applying any filter
TSL_acq_BankGetResult(0, 0, 0);
Note: The user can also create its own filter functions.
2.17.1 Principle
The STMTouch driver needs an internal clock (“timing”), in particular for the ECS and DTO
processings. This timing can be also used by the application layer for any purpose (LEDs
blinking for example).
The timing process consists in incrementing a global variable at a regular interval. Different
functions are then used to compare the current “time” and to check if a certain delay has
elapsed.
2.17.2 Resources
The common timing routines are described in the files:
• tsl_time.c
• tsl_time.h
The initialization of the timing is made using hardware timer, systick, etc... and is
implemented differently on each device. This is described in the files:
• tsl_time_<mcu>.c
• tsl_time_<mcu>.h
Functions:
• TSL_tim_ProcessIT()
• TSL_tim_CheckDelay_ms()
• TSL_tim_CheckDelay_sec()
2.17.3 Parameters
• TSLPRM_TICK_FREQ
2.17.4 Usage
The timing is started when the function TSL_Init() is called.
The function TSL_tim_CheckDelay_ms() can be used in the main application code to
execute some code (for example the ECS) at a regular interval.
Example:
TSL_tTick_ms_T time_ECS_tick;
TSL_tTick_ms_T time_LED_tick;
int main(void) {
TSL_Init(MyBanks); // The timing starts...
while (1) {
...
// Launch the ECS every 100 ms
if (TSL_tim_CheckDelay_ms(100, &time_ECS_tick) == TSL_STATUS_OK)
{
TSL_ecs_Process(&MyObjGroup);
}
// Toggle LED every 500 ms
if (TSL_tim_CheckDelay_ms(500, &time_LED_tick) == TSL_STATUS_OK)
{
ToggleLED();
}
...
}
}
2.18 Parameters
All the parameters are described in the tsl_conf_<mcu>.h file.
Note: The tsl_conf_<mcu>.h_TOADAPT file present in the STMTouch_Driver/inc folder must be
copied in the application project (inc folder) and adapted to your application.
The structure TSL_Params_T is used to hold certain parameters that are common to all
sensors. These parameters can be changed by the user while the application is running.
Parameters checking
All common parameters are verified (presence and value range) in the file:
• tsl_check_config.h
All device specific parameters are verified in the tsl_check_config_<mcu>.h file.
2.19.1 Acquisition
The STM8L1xx devices hardware acquisition mode (using two timers) is done in the files:
• tsl_acq_stm8l_hw.c
• tsl_acq_stm8l_hw.h
2.19.2 Timings
The STM8L1xx devices timing management is done in the files:
• tsl_time_stm8l.c
• tsl_time_stm8l.h
The TIM4 is used to generate a timebase for the ECS and DTO modules.
Functions used:
• TSL_tim_Init()
2.19.3 Parameters
The parameters specific to the STM8L1xx devices are described in the file:
• tsl_conf_stm8l.h
and are checked in the file:
• tsl_check_config_stm8l.h
Conditions
• Cosmic STM8 C compiler 32K version v4.3.6
• Compiler options: +modsl0 -pxp +compact +split -pp
• Cosmic library not counted
• STMTouch driver default options: ECS=ON, DTO=OFF, PROX=OFF
• Each sensor has its own parameters, all parameters placed in RAM
The following tables summarize the memory footprint taken by the STMTouch driver with
different STM8L devices, acquisition mode and sensors:
ZONE=OFF
3 2 3 TKeys ~5.3 ~160
DXS=ON
1. The content of this table is provided for information purposes only.
ZONE=OFF
1 1 1 TKey ~5.2 ~140
DXS=OFF
ZONE=ON
10 2 10 TKeys ~5.4 ~300
DXS=ON
10 TKeys
ZONE=ON
16 2 1 Linear-3ch ~7.4 ~450
DXS=ON
1 Rotary-3ch
1. The content of this table is provided for information purposes only.
ZONE=OFF
1 1 1 TKey ~4.6 ~130
DXS=OFF
ZONE=OFF
10 2 10 TKeys ~4.8 ~280
DXS=ON
10 TKeys
ZONE=OFF
16 2 1 Linear-3ch ~6.9 ~430
DXS=ON
1 Rotary-3ch
1. The content of this table is provided for information purposes only.
GPIOs Acquisition
TIM4 Time base for ECS and DTO
TIM2, TIM3 Acquisition
Routing interface Acquisition
GPIOs Acquisition
TIM4 Time base for ECS and DTO
Routing interface Acquisition
STMTouch driver
Table 11. Available touch-sensing channels for STM8L101
Subfamily STM8L101
STM8L101F[23]U
Part numbers STM8L101G[23]U STM8L101K3[UT]
STM8L101F[23]P
G1_IO1 PB0 10 7 12 13
2 channels 3 channels 3 channels
G1_IO2 PB1 11 8 with 1 13 with 1 14 with 1
Group1 3 4 4
G1_IO3 PD0 9 6 sampling 8 sampling 9 sampling
capacitor capacitor capacitor
UM1606 Rev 6
G1_IO4 PD1 - - 9 10
G2_IO1 PB2 12 9 14 15
1 channel 3 channels 3 channels
G2_IO2 PB3 13 10 with 1 15 with 1 16 with 1
Group2 2 4 4
G2_IO3 PD2 - - sampling 10 sampling 11 sampling
capacitor capacitor capacitor
G2_IO4 PD3 - - 11 12
Maximum number of channels 3 with 2 sampling capacitors 6 with 2 sampling capacitors 6 with 2 sampling capacitors
UM1606
UM1606
Table 12. Available touch-sensing channels for STM8L15x / STM8L16x (table 1/2)
Subfamily STM8L151F STM8L151G STM8L151K
STM8L151F[23]U(1) STM8L151G[346]U(1)
(UFQFPN) (UFQFPN)
Part numbers STM8L152K[46][UT]
STM8L151F[23]P(1) STM8L151G[46]Y
(TSSOP) (WLCSP)
G1_IO1 PA6 - - - - 6
UM1606 Rev 6
STMTouch driver
cannot be used 1 channel with 2 channels with
Group 4 G4_IO2 PD4 - - 1 for 20 C1 2 1 sampling 21 3 1 sampling
touch sensing capacitor capacitor
G4_IO3 PB7 14 17 19 E1 20
55/10
Table 12. Available touch-sensing channels for STM8L15x / STM8L16x (table 1/2) (continued)
56/10
STMTouch driver
Subfamily STM8L151F STM8L151G STM8L151K
STM8L151F[23]U(1) STM8L151G[346]U(1)
(UFQFPN) (UFQFPN)
Part numbers STM8L152K[46][UT]
STM8L151F[23]P(1) STM8L151G[46]Y
(TSSOP) (WLCSP)
G5_IO1 PB6 13 16 18 F1 19
2 channels 2 channels with 2 channels with
Group 5 G5_IO2 PB5 12 15 3 with1 sampling 17 D1 3 1 sampling 18 3 1 sampling
UM1606 Rev 6
UM1606
2 sampling capacitors 7 sampling capacitors 7 sampling capacitors
1. The product has an hardware acceleration cell for touch sensing.
UM1606
Table 13. Available touch-sensing channels for STM8L15x / STM8L16x (table 2/2)
STM8L151C medium/medium+/high density
STM8L151R/M
Subfamily STM8L151K STM8L151C low density
STM8L152C/R/M
STM8L162R/M
STM8L151C[468][UT]
STM8L152C[468][UT]
(48 pins)
STM8L151R[68]T
(1) STM8L152R[68]T
STM8L151K3U
Part numbers STM8L162R8T STM8L151C3T(1)
STM8L151K[46][UT]
(64 pins)
UM1606 Rev 6
STM8L151M8T
STM8L152M8T
STM8L162M8T
(80 pins)
G1_IO1 PA6 6 7 7 11 7
G1_IO2 PA5 5 2 channels with 6 6 10 2 channels with 6 3 channels with
Group 1 3 1 sampling 3 1 sampling 4 1 sampling
G1_IO3 PA4 4 capacitor 5 5 9 capacitor 5 capacitor
(2) (2) (2)
G1_IO4 PA7 - 8
STMTouch driver
G2_IO1 PC7 - 46 62 74 46
G2_IO2 PC4 29 1 channel with 43 59 71 2 channels with 43 3 channels with
Group 2 2 1 sampling 3 1 sampling 4 1 sampling
G2_IO3 PC3 28 capacitor 42 58 70 capacitor 42 capacitor
(2) (2) (2)
G2_IO4 PE7 - 48
57/10
Table 13. Available touch-sensing channels for STM8L15x / STM8L16x (table 2/2) (continued)
58/10
STMTouch driver
STM8L151C medium/medium+/high density
STM8L151R/M
Subfamily STM8L151K STM8L151C low density
STM8L152C/R/M
STM8L162R/M
STM8L151C[468][UT]
STM8L152C[468][UT]
(48 pins)
STM8L151R[68]T
(1) STM8L152R[68]T
STM8L151K3U
Part numbers STM8L162R8T STM8L151C3T(1)
STM8L151K[46][UT]
(64 pins)
STM8L151M8T
UM1606 Rev 6
STM8L152M8T
STM8L162M8T
(80 pins)
G3_IO1 PC2 27 41 57 69 41
2 channels with 2 channels with 1 channel with
Group 3 G3_IO2 PD7 24 3 1 sampling 36 48 60 3 1 sampling 36 3 1 sampling
capacitor capacitor capacitor
G3_IO3 PD6 23 35 47 59 35
G4_IO1 PD5 22 34 46 58 34
2 channels with 2 channels with 2 channels with
Group 4 G4_IO2 PD4 21 3 1 sampling 33 45 57 3 1 sampling 33 3 1 sampling
capacitor capacitor capacitor
G4_IO3 PB7 20 31 38 46 31
G5_IO1 PB6 19 30 37 45 30
2 channels with 2 channels with 2 channels with
Group 5 G5_IO2 PB5 18 3 1 sampling 29 36 44 3 1 sampling 29 3 1 sampling
UM1606
capacitor capacitor capacitor
G5_IO3 PB4 17 28 35 43 28
Table 13. Available touch-sensing channels for STM8L15x / STM8L16x (table 2/2) (continued)
UM1606
STM8L151C medium/medium+/high density
STM8L151R/M
Subfamily STM8L151K STM8L151C low density
STM8L152C/R/M
STM8L162R/M
STM8L151C[468][UT]
STM8L152C[468][UT]
(48 pins)
STM8L151R[68]T
(1) STM8L152R[68]T
STM8L151K3U
Part numbers STM8L162R8T STM8L151C3T(1)
STM8L151K[46][UT]
(64 pins)
STM8L151M8T
UM1606 Rev 6
STM8L152M8T
STM8L162M8T
(80 pins)
G6_IO1 PB3 16 27 34 42 27
2 channels with 2 channels with 2 channels with
Group 6 G6_IO2 PB2 15 3 1 sampling 26 33 41 3 1 sampling 26 3 1 sampling
capacitor capacitor capacitor
G6_IO3 PB1 14 25 32 40 25
G7_IO1 PB0 13 24 31 39 24
G7_IO2 PD3 12 2 channels with 23 28 32 2 channels with 23 3 channels with
STMTouch driver
Group 7 3 1 sampling 3 1 sampling 4 1 sampling
G7_IO3 PD2 11 capacitor 22 27 31 capacitor 22 capacitor
(2) (2) (2)
G7_IO4 PE3 - 17
59/10
Table 13. Available touch-sensing channels for STM8L15x / STM8L16x (table 2/2) (continued)
60/10
STMTouch driver
STM8L151C medium/medium+/high density
STM8L151R/M
Subfamily STM8L151K STM8L151C low density
STM8L152C/R/M
STM8L162R/M
STM8L151C[468][UT]
STM8L152C[468][UT]
(48 pins)
STM8L151R[68]T
(1) STM8L152R[68]T
STM8L151K3U
Part numbers STM8L162R8T STM8L151C3T(1)
STM8L151K[46][UT]
(64 pins)
STM8L151M8T
UM1606 Rev 6
STM8L152M8T
STM8L162M8T
(80 pins)
G8_IO1 PD1 10 21 26 30 21
G8_IO2 PD0 9 1 channel with 20 25 29 2 channels with 20 3 channels with
Group 8 2 1 sampling 3 1 sampling 4 1 sampling
G8_IO3 PE5 - capacitor 19 24 28 capacitor 19 capacitor
G8_IO4 PE4 - (2) (2) (2)
18
Maximum number of 14 channels with 16 channels with 20 channels with
channels 8 sampling capacitors 8 sampling capacitors 8 sampling capacitors
1. The product has an hardware acceleration cell for touch sensing.
2. This IO does not belong to the analog IO group.
UM1606
UM1606 STMTouch driver
STMTouch driver
1 2 3 4
R17
MCU_VDD 0R_0603/DNF
U2 W1 VDD C1
1 5 CN1
100nF_X7R_0603
Vin Vout
MCU_VDD PC3
1µF_X5R_0603
GND
1 2
3 4 JUMPER 4.7µF_X5R_0603 PC2 PC1
CE NC 3 4
C6 C7 C2 PC0
A R1 5 6 A
LP2980ABM3.3-TR
7 8
2
10K_1%_0603
9 10
100nF_X7R_0603 PA1 R2
11 12
820R_1%_0603 13 14
C3 PD7
100nF_X7R_0603 15 16
M5V PD5 PD6
17 18
7
CN2 PD4
19 20
G2 PB7 MCU_VDD
VDD
VSS
GND 21 22
4 PA0 32 24 PD7
RST PA0-SWIM-BEEP-IR_TIMER PD7 23 24
3 PB6 PB5
GND 25 26
2 PA1 1 23 PD6 PB4
SWIM PA1-NRST PD6 27 28
1
VDD MCU_VDD 29 30
G1 PA2 2 22 PD5
GND PA2 PD5 31 32
33 34
SWIM PA3 3 21 PD4 GND
PA3 PD4 35 36
PA4 4 12 Header 18X2 on the right
PA4-TIM1_BKIN PD3-CMP2_CH4
C4
PA5 5 11
B PA5-TIM2_BKIN PD2-CMP2_CH3 B
PB0 R3
0R_1%_0603 PA6 6 10 4.7nF_COG_1206
PA6-CMP_VREF PD1-TIM2_TRIG-CMP1_CH4
PB1 R4 C5 CN4
0R_1%_0603 9 PC4
PD0-TIM2_CH2-TIM_IR-CMP1_CH3 1 2
PC5 PC6
3 4
R5 13
UM1606 Rev 6
47nF_COG_1206
PB0-TIM1_CH1-CMP1_CH1 5 6
10K_1%_0603 7 8
R6 14 31 PC6 PA0
PB1-TIM2_CH1-CMP1_CH2 PC6 9 10
10K_1%_0603 R7 PD0 PA1 PA2
11 12
15 30 PC5 0R_1%_0603 PA3
PB2-TIM1_CH2-CMP2_CH1 PC5 13 14
R16 PD2
15 16
1
19 20
PB4 17 28 PC3 PA6
PB4-SPI_NSS PC3-USART_TX 21 22
0 Position
23 24
PB5 18 27 PC2 PD0
PB5-SPI_SCK PC2-USART_RX 25 26
PD2 PD1
27 28
4 PB6 19 26 PC1 PD3
K PB6-SPI_MOSI PC1-I2C SCL 29 30
C 31 32 C
PB7 20 25 PC0 PB0 PB1
PB7-SPI_MISO PC0-I2C SDA 33 34
3 2 PB2 PB3
B A 35 36
U1 Header 18X2 on the left
PD1 R10 STM8L103K
ROT1 0R_1%_0603
WHEEL ELECTRODE
R9
10K_1%_0603
K1
1 R11 R12 PB2
K2 10K_1%_0603 0R_1%_0603
1 R13 R14 PB3
K3 10K_1%_0603 0R_1%_0603
1 R15 R8 PD3
10K_1%_0603 0R_1%_0603
D D
STMicroelectronics
Title: STM8L101K-TS1 Daughter Board
6
5
4
3
2
1
UM1606
UM1606 STMTouch driver
2.20.1 Acquisition
The STM8TL5x devices acquisition is done in the files:
• tsl_acq_stm8tl5x.c
• tsl_acq_stm8tl5x.h
Functions used by the application layer and that are device dependent:
• TSL_acq_BankConfig()
• TSL_acq_BankStartAcq()
• TSL_acq_BankWaitEOC()
• TSL_acq_GetMeas()
The other functions in this file are for internal use and the user doesn't need to call them
directly.
2.20.2 Timings
The STM8TL5x devices timing management is done in the files:
• tsl_time_stm8tl5x.c
• tsl_time_stm8tl5x.h
The TIM4 is used to generate a timebase for the ECS and DTO modules.
Functions used
• TSL_tim_Init()
• TSL_Timer_ISR()
2.20.3 Parameters
The parameters specific to the STM8TL5x devices are described in the file:
• tsl_conf_stm8tl5x.h
and are checked in the file:
• tsl_check_config_stm8tl5x.h
Conditions
• Cosmic STM8 C compiler 32K version v4.3.6
• Compiler options: +modsl0 -pxp +compact +split -pp
• Cosmic library not counted
• STMTouch driver default options: ECS=ON, DTO=ON, ZONE=OFF, DXS=ON
(excepted if only one sensor is used)
• Each sensor has its own parameters, all parameters placed in RAM
The following tables summarize the memory footprint with different configurations:
W
5XQ $FWLYHKDOW 5XQ $FWLYHKDOW
,QLWLDOL]DWLRQRIDEDQNDFTXLVLWLRQ
+DUGZDUHDFTXLVLWLRQWKH&38FDQHQWHULQORZSRZHUPRGH:),:)(DFWLYHKDOW
0HDVXUHPHQWVWRULQJIRUHDFKHQDEOHGUHFHLYHUVRIWKHEDQNMXVWDFTXLUHG
6HQVRUSURFHVVLQJFDQEHVSOLWLQGLIIHUHQWIXQFWLRQVWRXFKNH\VOLQHDURUURWDU\VHQVRUV«
(&6SURFHVVLQJQRWSHUIRUPHGDIWHUHDFKVHWRIDFTXLVLWLRQVEXWH[HFXWHGVHTXHQWLDOO\DIWHUDGHOD\HODSVHG
06Y9
Conditions
• Cosmic STM8 C compiler 32K version v4.3.6
• Compiler options: +modsl0 -pxp +split -pp
• STMTouch driver default options: ECS=ON, DTO=ON, DXS=ON (excepted if one
channel is used)
• Each sensor has its own parameters, all parameters placed in RAM
The following table summarizes the timings measured for the different acquisition
sequences:
3 receivers 81
TSL_acq_BankGet 5 receivers 135
Measurement storing
Result()
by enabled
~27
receiver
GPIOs Acquisition
8-bit timer (TIM 4) Time base for ECS and DTO
ProxSense (PXS) Acquisition
STM8TL52F4P STM8TL52G4U
Part numbers STM8TL53C4U
STM8TL53F4P STM8TL53G4U
PXS function GPIO Pin Pin Usage Pin Pin Usage Pin Usage
RX0a - 11 11 10 10 13
RX1a - 12 12 11 11 15
RX2a - 13 13 12 12 17
RX3a - - - 13 13 19
RX6a - 14 14 16 16 25
RX7a - 15 15 17 17 27
RX8a - - - - - 29
RX9a - - - - - 31
RX0b - - - - - 14
RX1b - - - - - 16
RX2b - - - - - 18
RX3b - - - - - 20
RX6b - - - - - 26
RX7b - - - - - 28
RX8b - - - - - 30
RX9b - - - - - 32
STM8TL52F4P STM8TL52G4U
Part numbers STM8TL53C4U
STM8TL53F4P STM8TL53G4U
PXS function GPIO Pin Pin Usage Pin Pin Usage Pin Usage
TX0 PD0 16 16 18 18 33
TX1 PD1 17 17 19 19 34
(2)
TX2 PD2 - - 20 20 35
(2)
TX3 PD3 - - 21 21 36
TX4 PD4 18(2) 18 22(2) 22 39
TX5 PD5 19(2) 19 23(2) 23 40
STM8TL52F4P: STM8TL52G4U:
TX6 PD6 20(2) 20 2 Transmitters 24(2) 24 2 Transmitters 41
(2)
Transmitter TX7 PD7 - - 27 27 42 15 Transmitters
STM8TL53F4P: (2) STM8TL53G4U:
TX8 PB0 - - 28 28 43
5 Transmitters 9 Transmitters
TX9 PB1 - - - - 44
TX10 PB2 - - - - 45
TX11 PB3 - - - - 46
TX12 PB4 - - - - 47
TX13 PB5 - - - - 48
TX14 PB6 - - - - 1
STM8TL52F4P: 12 channels STM8TL52G4U: 25 channels
with a 4RX*3TX matrix with a 5RX*5TX matrix
Maximum number 300 channels with a
of channels 20RX*15TX matrix
STM8TL53F4P: 25 channels STM8TL53G4U: 72 channels
with a 5RX*5TX matrix with a 8RX*9TX matrix
1. The receivers can also be used as transmitters. This is used to define the square matrix to address the maximum number of
channels (please refer to product datasheet for further information).
2. On STM8TL52 devices, this GPIO is present but does not support the PXS alternate function.
UM1606
1 2 3 4
VDD
A
CN1 Touchkeys A
1
VDD K1 K2 K3 K4 K5
2 SWIM U1
SWIM
3 2 13 R1 1K KEY_Row1 1 2 1 2 1 2 1 2 1 2
GND PA0/SWIM PXS_RX0a
4 RESET 10 15 R2 1K KEY_Row2
RST PA5/NRST PXS_RX1a
17 R3 1K KEY_Row3
C1 PXS_RX2a Sensor Sensor Sensor Sensor Sensor
SPI_NSS 3 19 R4 1K KEY_Row4
10nF_X7R PA1/SPI_NSS PXS_RX3a
TSM-104-01-L-SH-A SPI_SCK 4 21 R5 1K KEY_Row5
PA2/SPI_SCK PXS_RX4a K6 K7 K8 K9 K10
SPI_MISO 5 23
SWIM connector SPI_MOSI 6
PA3/SPI_MISO/I2C_SDA
PA4/SPI_MOSI/I2C_SCL
PXS_RX5a
PXS_RX6a
25 1 2 1 2 1 2 1 2 1 2
27
PXS_RX7a
11 29
PA6/PXS_TRIG PXS_RX8a Sensor Sensor Sensor Sensor Sensor
12 31
PA7/PXS_RFIN PXS_RX9a
VDD VDD
K11 K12 K13 K14 K15
14
PXS_RX0b
7 16 1 2 1 2 1 2 1 2 1 2
VDD PXS_RX1b
38 18
B VDDIO PXS_RX2b B
9 20
PXS_VREG PXS_RX3b Sensor Sensor Sensor Sensor Sensor
22
PXS_RX4b
24
C2 C3 C4 C5 PXS_RX5b K16 K17 K18 K19 K20
26
100nF_X7R 100nF_X7R 1uF_X5R PXS_RX6b
100pF_X7R 28 1 2 1 2 1 2 1 2 1 2
PXS_RX7b
8 30
UM1606 Rev 6
VSS PXS_RX8b
37 32
VSSIO PXS_RX9b Sensor Sensor Sensor Sensor Sensor
PB6/PXS_TX14
PB5/PXS_TX13
PB4/PXS_TX12
PB3/PXS_TX11
PB2/PXS_TX10
K21 K22 K23 K24 K25
PD7/PXS_TX7
PD6/PXS_TX6
PD5/PXS_TX5
PD4/PXS_TX4
PD3/PXS_TX3
PD2/PXS_TX2
PD1/PXS_TX1
PD0/PXS_TX0
PB1/PXS_TX9
PB0/PXS_TX8
1 2 1 2 1 2 1 2 1 2
42
41
40
39
36
35
34
33
STM8TL53C4U6
C C
R6 1K KEY_Col1
R7 1K KEY_Col2
R8 1K KEY_Col3
R9 1K KEY_Col4
R10 1K KEY_Col5
NOTES:
1. ESD serial resistors (R1 to R10) must be placed closed to U1.
2. C4 equivalent serial resistor must be equal or lower than 0.2 Ohms at 1 MHz.
D D
STMTouch driver
STMicroelectronics
Title: STM8TL53 Reference Schematic
Microcontrollers Division
Size: A4 Reference: * Revision: B-00 190, avenue Célestin COQ
13106 ROUSSET Cedex
Date: 20-FEB-12 Sheet: 1 of 1 FRANCE £
1 2 3 4
71/10
STMTouch driver UM1606
2.21.1 Acquisition
The STM32F0xx devices acquisition is done in the files:
• tsl_acq_stm32f0xx.c
• tsl_acq_stm32f0xx.h
Functions used by the application layer and that are device dependent:
• TSL_acq_BankConfig()
• TSL_acq_BankStartAcq()
• TSL_acq_BankWaitEOC()
• TSL_acq_GetMeas()
The other functions in this file are for internal use and the user doesn't need to call them
directly.
2.21.2 Timings
The STM32F0xx devices timing management is done in the files:
• tsl_time_stm32f0xx.c
• tsl_time_stm32f0xx.h
The systick is used to generate a timebase for the ECS and DTO modules.
Functions used:
• TSL_tim_Init()
2.21.3 Parameters
The parameters specific to the STM32F0xx devices are described in the file:
• tsl_conf_stm32f0xx.h
and are checked in the file:
• tsl_check_config_stm32f0xx.h
Conditions
• IAR ANSI C/C++ Compiler V6.40.1 for Arm®
• Compiler options: optimization high-balanced
• IAR library not counted
• STMTouch driver default options: ECS=ON, DTO=ON, ZONE=OFF, DXS=ON
(excepted if only one sensor is used)
• Each sensor has its own parameters, all parameters placed in RAM
The following tables summarize the memory footprint with different configurations:
GPIOs Acquisition
Systick Time base for ECS and DTO
Touch sense controller (TSC) Acquisition
STMTouch driver
Table 22. Available touch sensing channels for STM32F042
Subfamily STM32F042
G1_IO1 PA0 6 6 6 6 F6 10 4 3
3 3 channels
3 channels 3 channels
G1_IO2 PA1 7 channels 7 7 7 D4 channels 11 with 1
with 1 with 1
Group 1 4 with 1 4 4 4 with 1 sampling
sampling sampling 12
G1_IO3 PA2 8 sampling 8 8 8 E4 sampling capacitor
capacitor capacitor
capacitor capacitor
UM1606 Rev 6
G1_IO4 PA3 9 9 9 9 F5 13
G2_IO1 PA4(1) 10 10 10 10 C3 14 4 3
3 3 channels
3 channels 3 channels
G2_IO2 PA5(1) 11 channels 11 11 11 D3 channels 15 with 1
with 1 with 1
Group 2 4 with 1 4 4 4 with 1 sampling
sampling sampling
G2_IO3 PA6 12 sampling 12 12 12 E3 sampling 16 capacitor
capacitor capacitor
capacitor capacitor
G2_IO4 PA7 13 13 13 13 F4 17
G3_IO1 - - - - - - - 3 2
1/2 channels
Cannot be 1 channel 2channel
G3_IO2 PB0 - 14 14 14 channels F3 18 with 1
used for with 1 s with 1
Group 3 1 2 2/3 with 1 3 sampling
touch sampling sampling
G3_IO3 PB1 14 15 15 15 sampling F2 19 capacitor
sensing capacitor capacitor
capacitor
G3_IO4 PB2 - - - 16 C2 20
UM1606
Table 22. Available touch sensing channels for STM32F042 (continued)
UM1606
Subfamily STM32F042
G5_IO1 PB3 - 24 26 26 B3 39 4 3
3 channels
Cannot be 3 channels 3 channels
G5_IO2 PB4 - 25 27 27 A3 channels 40 with 1
used for with 1 with 1
Group 5 0 4 4 4 with 1 sampling
touch sampling sampling 42
G5_IO3 PB6 - 27 29 29 C4 sampling capacitor
sensing capacitor capacitor
capacitor
G5_IO4 PB7 - 28 30 30 A4 43
UM1606 Rev 6
- - - - - -
Cannot be Cannot be Cannot be Cannot be Cannot be
- - - - - -
used for used for used for used for used for
Group 6 0 0 0 0 0
touch Touch Touch Touch Touch
- - - - - -
sensing sensing sensing sensing sensing
- - - - - -
- - - - - -
Cannot be Cannot be Cannot be Cannot be Cannot be
- - - - - -
used for used for used for used for used for
Group 7 not available 0 0 0 0 0
- Touch - Touch - - Touch - Touch - Touch
sensing sensing sensing sensing sensing
- - - - - -
- - - - - -
Cannot be Cannot be Cannot be Cannot be Cannot be
- - - - - -
used for used for used for used for used for
Group 8 0 0 0 0 0
Touch Touch Touch Touch Touch
- - - - - -
sensing sensing sensing sensing sensing
- - - - - -
STMTouch driver
Maximum number of 14 with 5 sampling
7 with 3 sampling capacitors 11 with 5 sampling capacitors 13/14 with 5 sampling capacitors 14 with 5 sampling capacitors
channels capacitors
1. This GPIO offers a reduced touch sensing sensitivity. It is thus recommended to use it as sampling capacitor I/O.
2. Pin pair PA11/PA12 can be remapped instead of pin pair PA9/PA10 using SYS_CTRL register.
75/10
76/10
STMTouch driver
Table 23. Available touch sensing channels for STM32F051 and STM32F072
Subfamily STM32F051/STM32F072
G1_IO1 PA0 6 6 10 14 23
3 channels 3 channels 3 channels 3 channels
G1_IO2 PA1 7 7 11 15 24
with 1 with 1 with 1 with 1
Group 1 4 4 4 4
sampling sampling sampling sampling
G1_IO3 PA2 8 8 12 16 25
capacitor capacitor capacitor capacitor
G1_IO4 PA3 9 9 13 17 26
UM1606 Rev 6
G2_IO1 PA4(1) 10 10 14 20 29
3 channels 3 channels 3 channels 3 channels
G2_IO2 PA5(1) 11 11 15 21 30
with 1 with 1 with 1 with 1
Group 2 4 4 4 4
G2_IO3 PA6 12 12 sampling 16 sampling 22 sampling 31 sampling
capacitor capacitor capacitor capacitor
G2_IO4 PA7 13 13 17 23 32
G3_IO1 PC5 - - - 25 34
1/2 channels 2 channels 3 channels 3 channels
G3_IO2 PB0 14 14 18 26 35
with 1 with 1 with 1 with 1
Group 3 2/3 3 4 4
sampling sampling sampling sampling
G3_IO3 PB1 15 15 19 27 36
capacitor capacitor capacitor capacitor
G3_IO4 PB2 - 16 20 28 37
G4_IO1 PA9 19 19 30 42 68
3 channels 3 channels 3 channels 3 channels
G4_IO2 PA10 20 20 31 43 69
with 1 with 1 with 1 with 1
Group 4 4 4 4 4
sampling sampling sampling sampling
G4_IO3 PA11 21 21 32 44 70
capacitor capacitor capacitor capacitor
G4_IO4 PA12 22 22 33 45 71
G5_IO1 PB3 26 26 39 55 89
3 channels 3 channels 3 channels 3 channels
G5_IO2 PB4 27 27 40 56 90
with 1 with 1 with 1 with 1
Group 5 4 4 4 4
sampling sampling sampling sampling
G5_IO3 PB6 29 29 42 58 92
capacitor capacitor capacitor capacitor
UM1606
G5_IO4 PB7 30 30 43 59 93
Table 23. Available touch sensing channels for STM32F051 and STM32F072 (continued)
UM1606
Subfamily STM32F051/STM32F072
G6_IO1 PB11 - - 22 30 48
Cannot be 3 channels 3 channels 3 channels
G6_IO2 PB12 - - used for 25 with 1 33 with 1 51 with 1
Group 6 0 4 4 4
touch sampling sampling sampling
G6_IO3 PB13 - - 26 34 52
sensing capacitor capacitor capacitor
G6_IO4 PB14 - - 27 35 53
G7_IO1 PE2 - - - - 1
UM1606 Rev 6
G8_IO1 PD12 - - - - 59
Cannot be Cannot be 3 channels
G8_IO2 PD13 - - - - Cannot be 60
used for used for with 1
Group 8 0 0 0 used for 4
Touch Touch sampling
G8_IO3 PD14 - - - - Touch sensing 61
sensing sensing capacitor
G8_IO4 PD15 - - - - 62
Maximum number of channels 13/14 with 5 sampling capacitors 17 with 6 sampling capacitors 18 with 6 sampling capacitors 24 with 8 sampling capacitors
1. This GPIO offers a reduced touch sensing sensitivity. It is thus recommended to use it as sampling capacitor I/O.
STMTouch driver
77/10
STMTouch driver UM1606
UM1606
1 2 3 4
100nF_X7R_0603
100nF_X7R_0603
1µF_X5R_0603
1µF_X5R_0603
C1 C2 3 INH
C3 C4
GND BYPASS G1_IO4 1
A A
4
K1
G4_IO4
G4_IO3
G4_IO2
G4_IO1
G6_IO4
G6_IO3
G6_IO2
C5
G2_IO4 1
10nF_X7R_0603
10K_5%_0603
K2
VDD
R1
R2
R3
R4
R5
R6
SWDIO
G3_IO4 1
C6 C7 C8 C9
K3
100nF_X7R_0603
U2 G4_IO2 1
48
47
46
45
44
43
42
41
40
39
38
37
36
35
34
33
STM32F051R8
VDD
K4
PF7
PF6
PA9
PA8
PC9
PC8
PC7
PC6
PA13
PA12
PA11
PA10
PB15
PB14
PB13
PB12
SWCLK 49 32
PA14 VDD_2
50 31 G4_IO3 1
B PA15 VSS_2 B
51 30 G6_IO1
PC10 PB11
52 29
PC11 PB10 K5
53 28 R7 G3_IO4
PC12 PB2
54 27 R8 G3_IO3
PD2 PB1
G5_IO1 55 26 R9 G3_IO2 G4_IO4 1
PB3 PB0
G5_IO2 R10 56 25 G3_IO1
UM1606 Rev 6
PB4 PC5
57 24
PB5 PC4 K6
58 23 R11 G2_IO4
PB6 PA7
59 22 R12 G2_IO3
PB7 PA6
60 21 R13 G2_IO2 G6_IO2 1
BOOT0 PA5
61 20 G2_IO1
PF1/OSC_OUT
PB8 PA4
62 19
PF0/OSC_IN
PB9 PF5 K7
63 18
VSS_1 PF4
64 17 R14 G1_IO4
VDD VDD_1 PA3
VDDA
VBAT
NRST
VSSA
G6_IO3 1
PC13
PC14
PC15
10K_5%_0603
PA0
PA1
PA2
PC0
PC1
PC2
PC3
SHIELD
K8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
G5_IO2 Shield R15
C 10K_5%_0603 C
G6_IO4 1
R16
R17
10K_5%_0603
K9
VDD VDD
SAMPLING CAPACITOR
G1_IO1
G1_IO2
G1_IO3
G1_IO1
G2_IO1
G3_IO1 RTS1
G4_IO1
G5_IO1 VDD LTS1
G6_IO1 G1_IO2 1 G1_IO3 2
1 A
Y1 G2_IO3 3
R18 B
1 2 G2_IO2 2 G3_IO3 1
NC 10K_5%_0603 2 C
4
47nF_COG_1206
47nF_COG_1206
47nF_COG_1206
15nF_COG_1206
15nF_COG_1206
K
1µF_X5R_0603
4 3 G3_IO2 3
NC 3
22pF_COG_0603 C10
C11 C12 C13 C14 C15 C16 Quartz 8MHz 10nF_X7R_0603 Linear touch sensor Rotary touch sensor
D D
STMTouch driver
C17 C18
22pF_COG_0603
STMicroelectronics
Title: STM32F0xx CT Reference Design
Microcontrollers Division
Size: A4 Reference: Revision: A-00 190, avenue Célestin COQ
13106 ROUSSET Cedex
Date: 01 APR 2012 Sheet: 1 of 1 FRANCE £
1 2 3 4
79/10
STMTouch driver UM1606
2.22.1 Acquisition
The STM32F3xx devices acquisition is done in the files:
• tsl_acq_stm32f3xx.c
• tsl_acq_stm32f3xx.h
Functions used by the application layer and that are device dependent:
• TSL_acq_BankConfig()
• TSL_acq_BankStartAcq()
• TSL_acq_BankWaitEOC()
• TSL_acq_GetMeas()
The other functions in this file are for internal use and the user doesn't need to call them
directly.
2.22.2 Timings
The STM32F3xx devices timing management is done in the files:
• tsl_time_stm32f3xx.c
• tsl_time_stm32f3xx.h
The systick is used to generate a timebase for the ECS and DTO modules.
Functions used:
• TSL_tim_Init()
2.22.3 Parameters
The parameters specific to the STM32F3xx devices are described in the file:
• tsl_conf_stm32f3xx.h
and are checked in the file:
• tsl_check_config_stm32f3xx.h
Conditions
• IAR ANSI C/C++ Compiler V6.40.1 for Arm®
• Compiler options: optimization high-balanced
• IAR library not counted
• STMTouch driver default options: ECS=ON, DTO=ON, PROX=OFF, ZONE=OFF,
DXS=OFF
• Each sensor has its own parameters, all parameters placed in RAM
The following tables summarize the memory footprint with different configurations:
GPIOs Acquisition
Systick Time base for ECS and DTO
Touch sense controller (TSC) Acquisition
STMTouch driver
Table 27. Available touch sensing channels for STM32F30x
Subfamily STM32F30x
G1_IO1 PA0 7 10 14 23
G1_IO2 PA1 8 11 15 24
3 channels with 3 channels with 3 channels with 3 channels with
UM1606 Rev 6
Group 1 4 4 4 4
1 sampling capacitor 1 sampling capacitor 1 sampling capacitor 1 sampling capacitor
G1_IO3 PA2 9 12 16 25
G1_IO4 PA3 10 13 17 26
G2_IO1 PA4(1) 11 14 20 29
G2_IO2 PA5(1) 12 15 21 30
3 channels with 3 channels with 3 channels with 3 channels with
Group 2 4 4 4 4
G2_IO3 PA6 13 1 sampling capacitor 16 1 sampling capacitor 22 1 sampling capacitor 31 1 sampling capacitor
G2_IO4 PA7 14 17 23 32
G3_IO1 PC5 - - 25 34
G3_IO4 PB2 - 20 28 37
G4_IO1 PA9 19 30 42 68
G4_IO2 PA10 20 31 43 69
3 channels with 3 channels with 3 channels with 3 channels with
Group 4 4 4 4 4
1 sampling capacitor 1 sampling capacitor 1 sampling capacitor 1 sampling capacitor
G4_IO3 PA13 23 34 46 72
G4_IO4 PA14 24 37 49 76
UM1606
Table 27. Available touch sensing channels for STM32F30x (continued)
UM1606
Subfamily STM32F30x
G5_IO1 PB3 26 39 55 89
G5_IO2 PB4 27 3 channels with 40 3 channels with 56 3 channels with 90 3 channels with
Group 5 4 4 4 4
1 sampling capacitor 1 sampling capacitor 1 sampling capacitor 1 sampling capacitor
G5_IO3 PB6 29 42 58 92
UM1606 Rev 6
G5_IO4 PB7 30 43 59 93
G6_IO1 PB11 - 22 30 48
G6_IO4 PB14 - 27 35 53
G7_IO1 PE2 - - - 1
G7_IO2 PE3 - Cannot be used for - Cannot be used for - Cannot be used for 2
3 channels with
Group 7 0 0 0 4
touch sensing touch sensing touch sensing 1 sampling capacitor
G7_IO3 PE4 - - - 3
G7_IO4 PE5 - - - 4
G8_IO1 PD12 - - - 59
G8_IO2 PD13 - Cannot be used for - Cannot be used for - Cannot be used for 60
3 channels with
Group 8 0 0 0 4
touch sensing touch sensing touch sensing 1 sampling capacitor
STMTouch driver
G8_IO3 PD14 - - - 61
G8_IO4 PD15 - - - 62
Maximum number
12 with 4 sampling capacitors 17 with 6 sampling capacitors 18 with 6 sampling capacitors 24 with 8 sampling capacitors
of channels
1. This GPIO offers a reduced touch sensing sensitivity. It is thus recommended to use it as sampling capacitor I/O.
83/10
.
STMTouch driver
Subfamily STM32F37x
G1_IO1 PA0 10 14 23 L2
G1_IO4 PA3 13 18 26 L3
(1)
G2_IO1 PA4 14 20 29 M3
G2_IO4 PA7 - 23 32 M4
G3_IO1 PC4 - 24 33 K5
G3_IO4 PB1 19 27 36 M6
UM1606
G4_IO3 PA13 34 1 sampling capacitor 46 1 sampling capacitor 72 A11 1 sampling capacitor
UM1606
Subfamily STM32F37x
G5_IO1 PB3 39 55 89 A8
G5_IO4 PB7 43 59 93 B4
G6_IO4 PD9 - - 56 K8
G7_IO1 PE2 - - 1 B2
G7_IO2 PE3 - Cannot be used for - Cannot be used for 2 A1 3 channels with
Group 7 0 0 4
G7_IO3 PE4 - touch sensing - touch sensing 3 B1 1 sampling capacitor
STMTouch driver
G7_IO4 PE5 - - 4 C2
85/10
Table 28. Available touch sensing channels for STM32F37x (continued)
86/10
STMTouch driver
Subfamily STM32F37x
G8_IO2 PD13 - Cannot be used for - Cannot be used for 60 H12 3 channels with
Group 8 0 0 4
G8_IO3 PD14 - touch sensing - touch sensing 61 H11 1 sampling capacitor
Maximum number
14 with 6 sampling capacitors 17 with 6 sampling capacitors 24 with 8 sampling capacitors
of channels
1. This GPIO offers a reduced touch sensing sensitivity. It is thus recommended to use it as sampling capacitor I/O.
UM1606
UM1606 STMTouch driver
STMTouch driver
1 2 3 4
100nF_X7R_0603
100nF_X7R_0603
1µF_X5R_0603
1µF_X5R_0603
C1 C2 3 INH
C3 C4
GND BYPASS G1_IO4 1
A A
4
K1
G4_IO2
G4_IO1
G6_IO3
G6_IO2
G6_IO1
C5
G2_IO4 1
10nF_X7R_0603
10K_5%_0603
K2
VDD
R1
R2
R3
SWDIO
VDD
G3_IO4 1
48
47
46
45
44
43
42
41
40
39
38
37
36
35
34
33
STM32F372RxT6
K4
PF7
PF6
PA9
PA8
PC9
PC8
PC7
PC6
PD8
PA13
PA12
PA11
PA10
PB15
PB14
VREFSD+
SWCLK 49 32
PA14 VDDSD
50 31 G5_IO2 1
B PA15 VSSSD B
51 30
PC10 PE9
52 29
PC11 PE8 K5
53 28
PC12 PB2
54 27 R4 G3_IO4
PD2 PB1
G5_IO1 55 26 R5 G3_IO3 G6_IO2 1
PB3 PB0
UM1606 Rev 6
G5_IO2 R6 56 25 R7 G3_IO2
PB4 PC5
57 24 G3_IO1
PB5 PC4 K6
G5_IO3 R8 58 23 R9 G2_IO4
PB6 PA7
G5_IO4 R10 59 22 R11 G2_IO3
PB7 PA6
60 21 R12 G2_IO2 G5_IO3 1
BOOT0 PA5
61 20 G2_IO1
PF1/OSC_OUT
PB8 PA4
62 19
PF0/OSC_IN
PB9 VDD_2 K7
63 18 R13 G1_IO4
VSS_1 PA3
64 17 10K_5%_0603
VDD VDD_1 VREF+
VDDA
VBAT
NRST
VSSA
G6_IO3 1
PC13
PC14
PC15
PA0
PA1
PA2
PC0
PC1
PC2
PC3
K8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
R14
C 10K_5%_0603 C
G5_IO4 1
R15
R16
10K_5%_0603
K9
VDD VDD
SAMPLING CAPACITOR
G1_IO1
G1_IO2
G1_IO3
G1_IO1
G2_IO1
G3_IO1 RTS1
G4_IO1
G5_IO1 VDD LTS1
G6_IO1 G1_IO2 1 G1_IO3 2
1 A
Y1 G2_IO3 3
R17 B
1 2 G2_IO2 2 G3_IO3 1
NC 10K_5%_0603 2 C
4
47nF_COG_1206
47nF_COG_1206
47nF_COG_1206
15nF_COG_1206
15nF_COG_1206
15nF_COG_1206
K
4 3 22pF_COG_0603 G3_IO2 3
NC 3
C13 C14 C15 C16 C17 C18 Quartz 8MHz Linear touch sensor Rotary touch sensor
D C19 D
C20 C21
22pF_COG_0603 100nF_X7R_0603
STMicroelectronics
Title: STM32F3xx CT Reference Design
Microcontrollers Division
Size: A4 Reference: Revision: A-00 190, avenue Célestin COQ
13106 ROUSSET Cedex
Date: 01 FEB 2013 Sheet: 1 of 1 FRANCE £
UM1606
1 2 3 4
UM1606 STMTouch driver
2.23.1 Acquisition
The STM32L1xx devices hardware acquisition mode (using two timers) is done in the
files:
• tsl_acq_stm32l1xx_hw.c
• tsl_acq_stm32l1xx_hw.h
2.23.2 Timings
The STM32L1xx devices timing management is done in the files:
• tsl_time_stm32l1xx.c
• tsl_time_stm32l1xx.h
The systick is used to generate a timebase for the ECS and DTO modules.
Functions used:
• TSL_tim_Init()
2.23.3 Parameters
The parameters specific to the STM32L1xx devices are described in the file:
• tsl_conf_stm32l1xx.h
and are checked in the file:
• tsl_check_config_stm32l1xx.h
Conditions
• IAR ANSI C/C++ Compiler V6.30.1 for Arm®
• Compiler options: optimization high-balanced
• IAR library not counted
• STMTouch driver default options: ECS=ON, DTO=ON, ZONE=OFF, DXS=ON
(excepted if only one sensor is used)
• Each sensor has its own parameters, all parameters placed in RAM
The following tables summarize the memory footprint taken by the STMTouch driver using
the hardware acquisition mode (using Timers) on STM32L1xx High-density devices:
The following tables summarize the memory footprint taken by the STMTouch driver using
the software acquisition mode on STM32L1xx Medium-density Plus devices:
The following tables summarize the memory footprint taken by the STMTouch driver using
the software acquisition mode on STM32L1xx Medium-density devices:
GPIOs Acquisition
Systick Time base for ECS and DTO
2 Timers (TIM9, TIM11) Acquisition
Routing interface Acquisition
GPIOs Acquisition
Systick Time base for ECS and DTO
Routing interface Acquisition
G1_IO1 PA0 14 3 23 K9 3 L2 3 34 3
channels channels channels channels
G1_IO2 PA1 15 24 L9 M2 35
with with with with
Group 1 4 4 4 4
G1_IO3 PA2 16 1 25 J8 1 K3 1 36 1
UM1606 Rev 6
STMTouch driver
capacitor capacitor capacitor capacitor
G3_IO5 PF12 - - - J7 50
93/10
Table 37. Available touch sensing channels for STM32L1xx 512K (continued)
94/10
STMTouch driver
Subfamily STM32L1xx 512K
UM1606
Table 37. Available touch sensing channels for STM32L1xx 512K (continued)
UM1606
Subfamily STM32L1xx 512K
STMTouch driver
G9_IO3 PF13 - 1 - - 1 K7 1 53 1
sampling sampling sampling sampling
G9_IO4 PF14 - capacitor - - capacitor J8 capacitor 54 capacitor
95/10
Table 37. Available touch sensing channels for STM32L1xx 512K (continued)
96/10
STMTouch driver
Subfamily STM32L1xx 512K
UM1606
Table 38. Available touch sensing channels for STM32L1xx 384K
UM1606
Subfamily STM32L1xx 384K
G1_IO1 PA0 14 F6 3 23 3 L2 3 34 3
channels channels channels channels
G1_IO2 PA1 15 E6 24 M2 35
with with with with
Group 1 4 4 4 4
G1_IO3 PA2 16 H8 1 25 1 K3 1 36 1
sampling sampling sampling sampling
UM1606 Rev 6
STMTouch driver
G3_IO5 PF12 - - - J7 50
97/10
Table 38. Available touch sensing channels for STM32L1xx 384K (continued)
98/10
STMTouch driver
Subfamily STM32L1xx 384K
UM1606
Table 38. Available touch sensing channels for STM32L1xx 384K (continued)
UM1606
Subfamily STM32L1xx 384K
STMTouch driver
sampling sampling sampling sampling
G9_IO4 PF14 - - capacitor - capacitor J8 capacitor 54 capacitor
99/10
Table 38. Available touch sensing channels for STM32L1xx 384K (continued)
100/10
STMTouch driver
Subfamily STM32L1xx 384K
UM1606
Table 39. Available touch sensing channels for STM32L1xx 256K (table 1/2)
UM1606
Subfamily STM32L1xx 256K
STM32L151RC
Part numbers STM32L152CC STM32L151UC STM32L152RC
STM32L162RC
G1_IO1 PA0 10 E4 14 F6
G1_IO2 PA1 11 3 channels with G5 3 channels with 15 E6 3 channels with
Group 1 4 1 sampling 4 1 sampling 4 1 sampling
G1_IO3 PA2 12 capacitor H6 capacitor 16 H8 capacitor
UM1606 Rev 6
(1)
G1_IO4 PA3 13 J7 17 G7
G2_IO1 PA6 16 G4 22 G5
G2_IO2 PA7 17 J5 23 G4
1 channel with 1 channel with 1 channel with
Group 2 G2_IO3 PF15 - 2 1 sampling - 2 1 sampling - - 2 1 sampling
capacitor capacitor capacitor
G2_IO4 PG0(2) - - - -
G2_IO5 PG1(2) - - - -
(1)
G3_IO1 PB0 18 J3 26 H4
G3_IO2 PB1 19 H3 27 F4
2 channels with 2 channels with 2 channels with
Group 3 G3_IO3 PB2 20 3 1 sampling G3 3 1 sampling 28 H3 3 1 sampling
capacitor capacitor capacitor
G3_IO4 PF11 - - - -
G3_IO5 PF12 - - - -
STMTouch driver
G4_IO1 PA8 29 E3 41 E4
2 channels with 2 channels with 2 channels with
Group 4 G4_IO2 PA9 30 3 1 sampling C1 3 1 sampling 42 D2 3 1 sampling
capacitor capacitor capacitor
G4_IO3 PA10 31 D2 43 D3
101/10
Table 39. Available touch sensing channels for STM32L1xx 256K (table 1/2) (continued)
102/10
STMTouch driver
Subfamily STM32L1xx 256K
STM32L151RC
Part numbers STM32L152CC STM32L151UC STM32L152RC
STM32L162RC
G5_IO1 PA13 34 C2 46 D4
2 channels with 2 channels with 2 channels with
Group 5 G5_IO2 PA14 37 3 1 sampling C3 3 1 sampling 49 B2 3 1 sampling
capacitor capacitor capacitor
G5_IO3 PA15 38 A2 50 C3
UM1606 Rev 6
G6_IO1 PB4 40 D4 56 B4
G6_IO2 PB5 41 3 channels with A5 3 channels with 57 A5 3 channels with
Group 6 4 1 sampling 4 1 sampling 4 1 sampling
G6_IO3 PB6 42 capacitor B5 capacitor 58 B5 capacitor
G6_IO4 PB7 43 C5 59 C5
G7_IO1 PB12 25 G2 33 G2
G7_IO2 PB13 26 G1 34 G1
G7_IO3 PB14 27 F3 35 F2
3 channels with 3 channels with 3 channels with
Group 7 G7_IO4 PB15 28 4 1 sampling F2 4 1 sampling 36 F1 4 1 sampling
capacitor capacitor capacitor
G7_IO5 PG2(2) - - - -
G7_IO6 PG3(2) - - - -
(2)
G7_IO7 PG4 - - - -
UM1606
Table 39. Available touch sensing channels for STM32L1xx 256K (table 1/2) (continued)
UM1606
Subfamily STM32L1xx 256K
STM32L151RC
Part numbers STM32L152CC STM32L151UC STM32L152RC
STM32L162RC
G8_IO1 PC0 - E6 8 E8
G8_IO2 PC1 - E5 3 channels with 9 F8 3 channels with
Group 8 0 4 1 sampling 4 1 sampling
G8_IO3 PC2 - G7 capacitor 10 D6 capacitor
UM1606 Rev 6
G8_IO4 PC3 - G6 11 F7
G9_IO1 PC4 - F4 24 H6
G9_IO2 PC5 - J4 1 channel with 25 H5 1 channel with
Group 9 0 2 1 sampling 2 1 sampling
G9_IO3 PF13 - - capacitor - - capacitor
G9_IO4 PF14 - - - -
Cannot be used for
G10_IO1 PC6 - F1 37 E1
touch sensing
G10_IO2 PC7 - E1 3 channels with 38 E2 3 channels with
Group 10 0 4 1 sampling 4 1 sampling
G10_IO3 PC8 - D1 capacitor 39 E3 capacitor
G10_IO4 PC9 - E2 40 D1
G11_IO1 PF6 - - - -
G11_IO2 PF7 - - - -
STMTouch driver
Cannot be used Cannot be used
Group11 G11_IO3 PF8 - 0 - 0 for - - 0 for
touch sensing touch sensing
G11_IO4 PF9 - - - -
G11_IO5 PF10 - - - -
103/10
Table 39. Available touch sensing channels for STM32L1xx 256K (table 1/2) (continued)
104/10
STMTouch driver
Subfamily STM32L1xx 256K
STM32L151RC
Part numbers STM32L152CC STM32L151UC STM32L152RC
STM32L162RC
UM1606
Table 40. Available touch sensing channels for STM32L1xx 256K (table 2/2)
UM1606
Subfamily STM32L1xx 256K
Number Number
Number of
Analog LQFP BGA of BGA LQFP of
Gx_IOy GPIO Usage available Usage Usage
I/O group pin ball available ball pin available
pins
pins pins
G1_IO1 PA0 23 L2 L2 34
G1_IO2 PA1 24 M2 3 channels with M2 3 channels with 35 3 channels with
Group 1 4 1 sampling 4 1 sampling 4 1 sampling
G1_IO3 PA2 25 K3 capacitor K3 capacitor 36 capacitor
UM1606 Rev 6
G1_IO4 PA3(1) 26 L3 L3 37
G2_IO1 PA6 31 L4 L4 42
G2_IO2 PA7 32 M4 J5 43
1 channel with 3 channels with 3 channels with
Group 2 G2_IO3 PF15 - - 2 1 sampling J9 4(2) 1 sampling 55 4(2) 1 sampling
capacitor capacitor capacitor
G2_IO4 PG0(3) - - H9 56
G2_IO5 PG1(3) - - G9 57
(1)
G3_IO1 PB0 35 M5 M5 46
G3_IO2 PB1 36 M6 M6 47
2 channels with 4 channels with 4 channels with
Group 3 G3_IO3 PB2 37 L6 3 1 sampling L6 5 1 sampling 48 5 1 sampling
capacitor capacitor capacitor
G3_IO4 PF11 - - K6 49
G3_IO5 PF12 - - J7 50
STMTouch driver
G4_IO1 PA8 67 D11 D11 100
2 channels with 2 channels with 2 channels with
Group 4 G4_IO2 PA9 68 D10 3 1 sampling D10 3 1 sampling 101 3 1 sampling
capacitor capacitor capacitor
G4_IO3 PA10 69 C12 C12 102
105/10
Table 40. Available touch sensing channels for STM32L1xx 256K (table 2/2) (continued)
106/10
STMTouch driver
Subfamily STM32L1xx 256K
Number Number
Number of
Analog LQFP BGA of BGA LQFP of
Gx_IOy GPIO Usage available Usage Usage
I/O group pin ball available ball pin available
pins
pins pins
UM1606
G8_IO3 PC2 17 J3 capacitor J3 capacitor 28 capacitor
G8_IO4 PC3 18 K2 K2(3) 29(3)
Table 40. Available touch sensing channels for STM32L1xx 256K (table 2/2) (continued)
UM1606
Subfamily STM32L1xx 256K
Number Number
Number of
Analog LQFP BGA of BGA LQFP of
Gx_IOy GPIO Usage available Usage Usage
I/O group pin ball available ball pin available
pins
pins pins
G9_IO1 PC4 33 K5 K5 44
G9_IO2 PC5 34 L5 1 channel with L5 3 channels with 45 3 channels with
Group 9 2 1 sampling 4 1 sampling 4 1 sampling
G9_IO3 PF13 - - capacitor K7 capacitor 53 capacitor
UM1606 Rev 6
G9_IO4 PF14 - - J8 54
G10_IO1 PC6 63 E12 E12 96
G10_IO2 PC7 64 E11 3 channels with E11 3 channels with 97 3 channels with
Group 10 4 1 sampling 4 1 sampling 4 1 sampling
G10_IO3 PC8 65 E10 capacitor E10 capacitor 98 capacitor
G10_IO4 PC9 66 D12 D12 99
G11_IO1 PF6 - - G3 18
G11_IO2 PF7 - - G4 19
Cannot be used 3 channels with 4 channels with
Group11 G11_IO3 PF8 - - 0 for H4 4 1 sampling 20 5 1 sampling
touch sensing capacitor capacitor
G11_IO4 PF9 - - J6 21
G11_IO5 PF10 - - - 22
23 channels with 10 33 channels with 11 34 channels with 11
STMTouch driver
Maximum number of channels
sampling capacitors sampling capacitors sampling capacitors
1. This GPIO offers a reduced touch sensing sensitivity. It is thus recommended to use it as sampling capacitor I/O.
2. Not all the pins are available simultaneously on this group.
3. This GPIO can only be configured as sampling capacitor I/O when using HW acquisition mode and as channel I/O when using SW acquisition mode.
107/10
Table 41. Available touch sensing channels for STM32L15x 32K to 128K
108/10
STMTouch driver
Subfamily STM32L15x 32K to 128K
STM32L151C6 STM32L151R6
STM32L151C8 STM32L151R8 STM32L151V8
STM32L151CB STM32L151RB STM32L151VB
Part numbers
STM32L152C6 STM32L152R6 STM32L152V8
STM32L152C8 STM32L152R8 STM32L152VB
STM32L152CB STM32L152RB
G1_IO1 PA0 10 14 G2 23 L2
UM1606 Rev 6
UM1606
G5_IO3 PA15 38 50 A6 77 A9
Table 41. Available touch sensing channels for STM32L15x 32K to 128K (continued)
UM1606
Subfamily STM32L15x 32K to 128K
STM32L151C6 STM32L151R6
STM32L151C8 STM32L151R8 STM32L151V8
STM32L151CB STM32L151RB STM32L151VB
Part numbers
STM32L152C6 STM32L152R6 STM32L152V8
STM32L152C8 STM32L152R8 STM32L152VB
STM32L152CB STM32L152RB
STMTouch driver
109/10
Table 41. Available touch sensing channels for STM32L15x 32K to 128K (continued)
110/10
STMTouch driver
Subfamily STM32L15x 32K to 128K
STM32L151C6 STM32L151R6
STM32L151C8 STM32L151R8 STM32L151V8
STM32L151CB STM32L151RB STM32L151VB
Part numbers
STM32L152C6 STM32L152R6 STM32L152V8
STM32L152C8 STM32L152R8 STM32L152VB
STM32L152CB STM32L152RB
G8_IO1 PC0 - 8 E3 15 H1
UM1606 Rev 6
UM1606
UM1606 STMTouch driver
STMTouch driver
1 2 3 4
+5V U1 VDD
LD3985M33R
1 Vin Vout 5 Notes:
1. ESD serial resistors and sampling capacitors must be placed as close as possible to MCU device.
100nF_X7R_0603
100nF_X7R_0603
2. Sampling capacitors must be COG type or better.
1µF_X5R_0603
1µF_X5R_0603
C1 C2 3 INH
C3 C4 G1_IO4 1
GND BYPASS 3. A dedicated low drop voltage regulator powering the touch controller is recommended.
4. Sampling capacitors must be connected to the same IO number of each analog IO group.
A K1 A
4
C5 G3_IO2 1
K2
10nF_X7R_0603
G6_IO2 G6_IO2 1
59 10K_5%_0603
56 10K_5%_0603
K3
VDD
VDD G6_IO1 G7_IO4 1
60 R1
57 R2
C6 C7 C8 C9 C10 K4
U2
64
63
62
61
58
55
54
53
52
51
50
49
STM32L15x G9_IO2 1
100nF_X7R_0603 VDD
PB9
PB8
PB7
PB6
PB5
PB4
PB3
PD2
PC12
PC11
PC10
PA15
PA14
VDD_3
VSS_3
BOOT0
C11 K5
VDD
1 48 G10_IO2 1
VLCD VDD_2
2
VDD 22pF_COG_0603 2 47
B Y1 PC13 VSS_2 B
3 46
XTAL/8Mhz PC14 PA13 K6
C12 4 45
PC15 PA12
1
R3 5 44 G10_IO3 1
10K_5%_0603 PH0 PA11
6 43 R4 G4_IO3
PH1 PA10
22pF_COG_0603 7 42 R5 G4_IO2
NRST PA9 K7
G8_IO1 8 41 10K_5%_0603 G4_IO1
UM1606 Rev 6
PC0 PA8
G8_IO2 R6 9 40 R7 G10_IO4 G10_IO4 1
C13 PC1 PC9
10 39 R9 G10_IO3
10nF_X7R_0603 PC2 PC8
11 38 R11 G10_IO2
PC3 PC7 K8
12 37 10K_5%_0603 G10_IO1
VSSA PC6
13 36 R12 G7_IO4
VDD VDDA PB15
G1_IO1 14 35 R13 G7_IO3
PA0 PB14
G1_IO2 R14 15 34 R15 G7_IO2
PA1 PB13
G1_IO3 R16 16 33 10K_5%_0603 G7_IO1
PA2 PB12
10K_5%_0603 SHIELD
VDD_4
VDD_1
VSS_4
VSS_1
PB10
PB11
PA3
PA4
PA5
PA6
PA7
PC4
PC5
PB0
PB1
PB2
G8_IO2 Shield
C C
17
18
19
20
21
22
23
24
25
10K_5%_0603 26
27
10K_5%_0603 28
29
30
31
32
G1_IO4 R17
10K_5%_0603
VDD VDD
R18
R19
SAMP_CAP_CH
G1_IO1
G9_IO1
G9_IO2
G3_IO1
G3_IO2
G3_IO1
G4_IO1 RTS1 LTS1
G6_IO1 G1_IO3 1
1
G7_IO1
G8_IO1 G1_IO2 2 G4_IO3 2
A 2
G9_IO1 G4_IO2 3
B
G10_IO1 G7_IO2 1 G7_IO3 3
C 3
4
47nF_COG_1206
15nF_COG_1206
47nF_COG_1206
15nF_COG_1206
47nF_COG_1206
15nF_COG_1206
15nF_COG_1206
K
1µF_X5R_0603
C14 C15 C16 C17 C18 C19 C20 C21 Rotary touch sensor
D D
STMicroelectronics
Title: STM32L CT Reference Design
Microcontrollers Division
Size: A4 Reference: Revision: C-00 190, avenue Célestin COQ
13106 ROUSSET Cedex
Date: 01 MAY 2012 Sheet: 1 of 1 FRANCE £
1 2 3 4
UM1606
UM1606 Getting started
3 Getting started
3UHGHWHFWLRQ
6HQVRUSURF 'HERXQFH!
1RGHWHFWLRQ 3UHGHWHFWLRQ
$FT 'HOWDWKUHVKROG 'HWHFWLRQ
UHSRUWHG
W
5XQ
/RQJ$:8SHULRG 6KRUW$:8SHULRG
$FWLYHKDOWSHULRGH[LWHGE\$:8 %DQNDFTXLVLWLRQ
6HQVRUSURFHVVLQJ )XOODFTXLVLWLRQSURFHVVLQJ
7RXFKHYHQW
8VHUDSSOLFDWLRQ
06Y9
This approach allows to save power consumption without increasing the response time. The
maximum response time is obtained when a touch occurs during the sensor processing. It
can be expressed as followed:
Max Response Time = long AWU period + (n) x short AWU period + (n+2) x full
acquisition processing - bank acquisition
with n being the debounce value.
3.4.1 Files
Previous Library
• Files are prefixed with “stm8_tsl_” or “stm32_tsl_” or “<mcu>_tsl_”.
• Copy <mcu>_tsl_conf_CT_TOADAPT.h or <mcu>_tsl_conf_RC_TOADAPT.h in your
project and rename it in <mcu>_tsl_conf.h
• Include <mcu>_tsl_api.h in main.h
STMTouch Library
• All files are prefixed with “tsl” or “tsl_”. There is no more “stm8” nor “stm32” prefix.
• Copy tsl_conf_<mcu>.h_TOADAPT in your project and rename it in
tsl_conf_<mcu>.h
• Include tsl.h in tsl_user.h
Previous Library
• Done in stm8_tsl_conf.h
• Limited number of channels, banks and sensors.
• SCKeys (= single channel keys) and MCKeys (multi-channels keys) sensors.
STMTouch library
• Done in the application (tsl_user.c and tsl_user.h).
• No limitation in the number of Cchannels, banks and sensors.
• Touchkey and LinRot sensors with extended and basic types.
Previous library
• Done in stm8_tsl_conf.h
• No common prefix for the parameters.
• Thresholds are on 7 bits (signed).
• No thresholds for proximity.
• Fixed calibration samples.
• Debounce counters common to all sensors and states.
• Fixed timer tick frequency.
STMTouch Library
• Done in tsl_conf_<mcu>.h
• All parameters are prefixed with “TSLPRM_”.
• Thresholds are on 8 bits (unsigned) and multiplier coefficient can be applied on them.
• Thresholds for proximity.
• Programmable calibration samples and delay.
• Debounce counters different for each sensor and each state.
• Programmable timer tick frequency.
3.4.4 Usage
Previous Library
• Initialization by calling TSL_Init() function.
• Execution by calling TSL_Action() continuously.
• Main state machine and sensors state machine are in the TS driver layer.
• ECS and DXS process are called by the TS driver layer.
• Test of the main state machine value using TSLState variable:
if (TSLState == TSL_IDLE_STATE) {
...
}
if ((TSLState == TSL_SCKEY_P1_ACQ_STATE) ||
(TSLState == TSL_SCKEY_P2_ACQ_STATE) ||
(TSLState == TSL_MCKEY1_ACQ_STATE) ||
(TSLState == TSL_MCKEY2_ACQ_STATE)) {
...
}
– Test of sensor state using TSL_GlobalSetting, sSCKeyInfo and sMCKeyInfo
variables:
if (TSL_GlobalSetting.b.CHANGED) {
TSL_GlobalSetting.b.CHANGED = 0;
if (sSCKeyInfo[0].Setting.b.DETECTED) {...}
STMTouch library
• Initialization by calling TSL_obj_GroupInit() and TSL_Init() functions.
• Execution by calling TSL_Action() continuously.
• Main state machine and sensors state machine are in the application layer and so can
be changed easily.
• ECS and DXS process are called by the application layer.
• The test of the main state machine value is not needed as the main state machine is
managed by the application layer.
• Test of sensor state using StateId variable:
if ((MyTKeys[0].p_Data->StateId == TSL_STATEID_DETECT)||
(MyTKeys[0].p_Data->StateId == TSL_STATEID_DEB_RELEASE_DETECT)) {...}
Previous library
• The sSCKeyInfo, sMCKeyInfo and sAcqBankInfo structures contain all informations
related to touchkey and linear/rotary sensors: reference, last measure, thresholds,
state, position, EPCC, ..
STMTouch library
• The array of TSL_ChannelData_T structure contains the reference, measure and delta
values of ALL channels used by the application:
• The array of TSL_LinRotData_T contains the linear and rotary sensors state and
position:
Note: The library allows to define a linear or a rotary touch sensor with channels belonging to
different banks. A such configuration induces a loss of sensitivity and a higher noise level.
Moreover, depending on the acquisition time, it is also possible to observe a position change
when removing the finger from the sensor.
For optimum performance of a linear or rotary sensor, all channels of such a sensor must be
acquired simultaneously.Therefore all channels must belong to the same bank, which
means the I/Os must be selected from different analog I/O groups. Please refer to datasheet
for more information regarding I/O groups and available capacitive sensing GPIOs.
4 Revision history
STMicroelectronics NV and its subsidiaries (“ST”) reserve the right to make changes, corrections, enhancements, modifications, and
improvements to ST products and/or to this document at any time without notice. Purchasers should obtain the latest relevant information on
ST products before placing orders. ST products are sold pursuant to ST’s terms and conditions of sale in place at the time of order
acknowledgement.
Purchasers are solely responsible for the choice, selection, and use of ST products and ST assumes no liability for application assistance or
the design of Purchasers’ products.
Resale of ST products with provisions different from the information set forth herein shall void any warranty granted by ST for such product.
ST and the ST logo are trademarks of ST. All other product or service names are the property of their respective owners.
Information in this document supersedes and replaces information previously supplied in any prior versions of this document.