Home

STMTouch driver user manual

image

Contents

1. 123 3 0 IO Default state parameter 123 Revision history 124 DoclD024201 Rev 4 Ly UM1606 List of tables List of tables Table 1 Terms and AI WS zx vae sch don goo AAA IIIA NA LG AA IAA 9 Table 2 MISRA C 2004 rules notfollowed 12 Table 3 Supported linearandrotarySensors 31 Table 4 Detailed sensors states 1 2 40 Table 5 Detailed sensors states 2 2 41 Table 6 STM8L101 memory footprint with software acquisition 53 Table 7 STM8L15x memory footprint with hardware acguisition 53 Table 8 STM8L15x memory footprint with software acguisition 53 Table 9 MCU resources used on STM8L1xx with hardware acguisition 54 Table 10 MCU resources used on STM8L1xx with software acguisition 54 Table 11 Available touch sensing channels for STM8L1O1 55 Table 12 Available touch sensing channels for STM8L15x STM8L16x table 1 2 56 Table 13 Available touch sensing channels for STM8L15x STM8L16x table 2 2 58 Table 14 STM8TLbx memory footprint without prokimity
2. 113 Figure 22 STMStudiosnapshot 116 Figure 23 Low powerstrategy 117 Figure 24 Debug of TSL ChannelData Tstructure 120 Figure 25 Debug of TSL TouchKeyData Tstructure 121 Figure 26 Debug of TSL LinRotData T structure 121 Figure 27 Debug of TSL TouchKeyParam T 121 Figure 28 Debug of TSL LinRotParam Tstructures 122 8 125 DoclD024201 Rev 4 Ly UM1606 1 1 3 Coding rules and conventions Coding rules and conventions Glossary The table below summarizes all the terms and acronyms used inside this user manual Table 1 Terms and Acronyms O NE NN A group of channels acquired simultaneously Cs Charge Transfer sampling capacitor or capacitance Delta Difference between the Measure and the Reference for PXS acquisition Multi channels sensor with the electrodes Linear sensor ma positioned in a linear way LinRot sensor A linear or rotary touch sensor Measure or Meas Current signal measured on a channel PXS ProxSense acquisition peripheral used in STM8TL5x devices Reference or Ref Measure of reference initialized during calibration and then regularly updated by the ECS Multi channels sensor with the electrodes
3. 66 2 20 6 MCUresources 67 2 20 7 STM8TLbx available touch sensing channels 68 2 20 8 Hardware implementation example 71 2 21 SIM32FOkdevices 13 2 21 1 ACQUISITION sur rk 240820 eho Roy daw deduced a duce Ra Roe a 73 2Al2 JIMINOS A CP 73 2 21 3 Parameters 73 2 21 4 Memory footprint 73 2 21 5 MCU resources 74 2 21 6 STM32FO0xx available touch sensing channels 14 2 21 Hardware implementation example 79 2 22 STM32F3xx devices 81 2221 ACQUISMON 3 022 2 0 3 2 9283 8 peed E 2 HIE EE ee bed RURSUS Int itu n arid d 81 2222 UA IA III AKI IA AA rae S 81 2223 PUMU IIIA SAAD AB KALII 81 2 22 4 Memory footprint 81 2 22 0 MCUTESOUKCES oua scu mare 52 nce ohne gernttauen done oo eeanreesd 82 2 22 6 STM32F3xx available touch sensing channels 82 2 22 Hardware implementation example 88 2 29 DIMIZLIXKOENICES 90 2 25 ACQUISMION pacman pawan AALIHI LINE a 90 2232 UNGA seereis ea arre LAON KWA 90 2 23 3
4. 18 Figure 5 Acquisition and processing layers 19 Figure 6 Header files inclusion 20 Figure 7 Channelsarrangement 22 Figure 8 Electrodes designs 30 Figure 9 POSINONS O AN0 Z205 62645 9 Sr S hanes Bees GE OS E E SG V PERF EE LEE SE 31 Figure 10 Mainstatemachine 35 Figure 11 Example of main state machine 36 Figure 12 Simplified sensorsstatemachine 37 Foure 19 DAS PIINCIPIE 2 oda cued vom drum ste Bes be ra see ake h wos EG be SoHE IIIA 46 Figure 14 DKSerample1 47 Foure 15 DAS CXAMPIC 2 5 x dcm eub ow RR RES KAA LAAL n 8 Rae eee La y KANA nG NG 47 Figure 16 STM8L101 hardware implementation example 63 Figure 17 Simplified acguisitionseguencing 66 Figure 18 STM8TLbx hardware implementation example 72 Figure 19 STM32FOxx hardware implementationekample 80 Figure 20 STM32F3xx hardware implementationekample 89 Figure 21 STM32L1xx hardware implementationekample
5. The content of this table is provided for information purposes only Table 7 STM8L15x memory footprint with hardware acquisition ROM RAM Specific Channels i Kbytes bytes options ZONE OFF 1 1 1 TK SD 14 ZONE ON 10 2 10 TK 5 4 5s 10 TK pine ZONE ON 1 Linear 3ch TA 450 DXS ON 1 Rotary 3ch The content of this table is provided for information purposes only Table 8 STM8L15x memory footprint with software acquisition ROM RAM Specific Channels Kbytes bytes options ZONE OFF 1 1 1 TK 4 6 130 ZONE OFF 10 2 10 TK 4 8 280 10 TK MA ZONE OFF 1 Linear 3ch 430 DXS ON 1 Rotary 3ch The content of this table is provided for information purposes only DoclD024201 Rev 4 93 125 STMTouch driver UM1606 2 19 5 2 19 6 Note1 Note2 54 125 MCU resources The tables below show the peripherals that are used by the STMTouch driver on STM8L1xx devices Care must be taken when using them to avoid any unwanted behavior Table 9 MCU resources used on STM8L1xx with hardware acquisition TIMA Time base for ECS and DTO Table 10 MCU resources used on STM8L1xx with software acquisition TIMA Time base for ECS and DTO STM8L available touch sensing channels The tables below provide an overview of the available touch sensing channels for the STM8L 1xx devices The following tables are not restrictive in term of part numbers supported by the STMTouch driver The STMTouch driver can
6. else 6 1 TSL_STATEMASK PROX 7 TSL STATEMASK DEB PROX 8 1 TSL STATEMASK DEB PROX DETECT 9 TSL STATEMASK DEB PROX TOUCH endif DETECT states 10 f 1 TSL STATEMASK DETECT 11 TSL STATEMASK DEB DETECT TOUCH state 12 7 t TSL STATEMASK TOUCH ERROR states 13 7 4 TSL STATEMASK ERROR 14 TSL STATEMASK DEB ERROR CALIB a 15 TSL_STATEMASK_DEB_ERROR_RELEASE hy 16 TSL STATEMASK DEB ERROR PROX Ja 17 TSL_STATEMASK_DEB_ERROR_DETECT Ja 18 TSL_STATEMASK_DEB_ERROR_TOUCH Ja Other states 19 TSL STATEMASK OFF ps UM1606 TSL tkey ProxStateProcess j TSL tkey DebProxStateProcess O O O oco ww uu YH ww TSL tkey DetectStateProcess TSL tkey DebDetectStateProcess TSL tkey TouchStateProcess MyTKeys ErrorStateProcess TSL tkey DebErrorStateProcess TSL tkey DebErrorStateProcess TSL tkey DebErrorStateProcess TSL tkey DebErrorStateProcess TSL tkey DebErrorStateProcess MyTKeys OffStateProcess The STM Touch 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 DoclD024201 Rev 4 Ey UM1606 Note 3 STMTouch driver 0 TSL STATEMASK CALIB MyTkeys CalibrationStateProcess The two functions used to manage the ERROR and OFF states are
7. 14 2 1 2 Development tools 15 2 2 Package description 15 2 3 Main features 16 2 4 hes iia bee ee TAGUM KATE AA oe ee ARR 17 2 4 1 OvervieW 17 2 4 2 STMTouch driver layers 17 2 4 3 Acquisition and processing layers 18 2 4 4 Headerfilesinclusion 20 2 5 Gae AAA AA 20 2 5 1 milile e cesuras Egk ree ce gee bh AA 20 2 5 2 acce 21 2 9 9 Parameters 21 2 54 Usage example 21 2 6 Bank coahen baa AG WANG AA mGA eee hbadbeeepavaraba nega en As 22 2 6 1 PACD sone AA 22 2 6 2 ReSOUrceS 23 2 6 3 aui IAEA AA HEH ORE EIA 23 2 6 4 Usage example 23 2 125 DoclD024201 Rev 4 Ly UM1606 Contents 2 7 LONG IAA IA PE NG GWN AAA WA AA 24 2 1 1 mile APR AA 94 050 AT 24 2 1 2 Resources 24 21 3 Parameters 25 2 1 4 Usage example 25 2 8 Objects 25 2 8 1 axlneo crm 25 2
8. After reset the initialization method of each object is called This method initializes the sensor parameters and then goes in the calibration state After the calibration is done the sensor goes in the RELEASE state or ERROR state except if an error occurred Related functions e TSL tkey CalibrationStateProcess e TSL linrot CalibrationStateProcess e TSL tkey SetStateCalibration e TSL linrot SetStateCalibration 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 RELEASE state Corresponds to the idle state of the sensor when no presence is detected Related functions e TSL tkey ReleaseStateProcess e TSL_linrot_ReleaseStateProcess Proximity state This state is optional and is enabled or disabled using the TSLPRM USE PROX parameter Related functions e TSL_tkey_ProxStateProcess e TSL_linrot_ProxStateProcess DETECT state It is the normal state when the sensor is touched Related functions e SL tkey DetectStateProcess e TSL linrot DetectStateProcess
9. 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 Figure 13 DXS principle TK1 and TK2 TK2 and TK3 All Tkeys TK1 and TK2 are touched together TK1 is released are touched together are touched are released maan Bae a Boe Bases MEOS BECOME Baise a go M Base a Bae TOUCH Bete PIGS A AN WTO Eme au MPG time TKey1 is also TKey3 takes blocked the priority TKey1 has the priority TKey2 takes Tkey2 is blocked the priority TKey3 is blocked MSv31738V1 Example 1 3 sensors with one shared between two groups In this example the group1 is composed of the two sensors s1 and s2 in this order and the group2 of the two sensors s2 and s3 in this order The DXS groups are processed in this order group1 first and then group2 y 46 125 DoclD024201 Rev 4 UM1606 STMTouch driver We can see in the step DXS5 that the sensor 2 s2 goes in DETECT state instead of the sensor 3 s3 This is s
10. This GPIO offers a reduced touch sensing sensitivity It is thus recommended to use it as sampling capacitor I O 19A11p YONOLWLS 909LINN Table 28 Available touch sensing channels for STM32F37x 4 Subfamily STM32F37x LQFP48 LQFP64 LQFP100 UFBGA100 Flash memory size 8 64K B 128K C 256K STM32F373C 8BC STM32F373R 8BC STM32F373V 8BC 4 3 channels with 3 channels with 3 channels with 1 sampling capacitor 1 sampling capacitor 1 sampling capacitor Group 1 z G2 101 PA4 PA5C a 2 channels with 4 3 channels with i 3 channels with 16 e Ea KI y NIY LOTYZOG FOG G2 103 PAe 1 sampling capacitor 1 sampling capacitor 1 sampling capacitor 2 1 Ganang MIU 4 3 ehanngie ui 4 3 evans nu G3 103 1 sampling capacitor 1 sampling capacitor 1 sampling capacitor GCL S8 Number Number Number of of LQFP BGA of available available Pin Pin available 909LINN JOALIP YINOLWIS GZL 98 y NIY LOcvcOdl9 0d Subfamily Packages Flash memory size Part numbers Gx_lOy G4 IO 1 G4 102 G4 103 G4 104 G5 IO 1 G5 102 G5 103 G5 lO4 G6 IO G6 IO G6 IO G6 IO o Ze PA10 PA13 ET PA14 PB4 PB6 PB7 PB14 126 PB15 PD8 Pps N Q OIOI NN OO NP Table 28 Available touch sensing channels for STM32F37x continued STM32F373C 8BC Number of available pins 3 channels with 1 sampling capacitor 3 channels with 1 sampling capacitor 2 channels with 1 s
11. y DoclD024201 Rev 4 UM1606 2 12 8 2 12 9 2 12 10 2 12 11 2 12 12 2 12 13 Note 3 STMTouch driver TOUCH state Same as DETECT state excepted that it is entered only by the DXS processing If the DXS is not used this state is never entered Related functions e TSL_tkey_TouchStateProcess e TSL_linrot_TouchStateProcess ERROR state It is used to catch all acquisition errors detected in the other states The management of this state must be performed at application level OFF state It is used to inform the acquisition module to stop the burst and or acquisition on the sensor s channels The management of this state must be performed at application level Debounce states The debounce is optional and is enabled disabled using the different debounce counters parameters TSLPRM_DEBOUNCE PROX TSLPRM DEBOUNCE DETECT TSLPRM_DEBOUNCE RELEASE TSLPRM_DEBOUNCE CALIB TSLPRM_DEBOUNCE ERROR The debounce is off if the corresponding parameter is equal to zero Reading the current state The current state can be obtained by using the functions For touchkey sensor e TSL_tkey_GetStateld e SL tkey GetStateMask For linear and rotary sensor e TSL linrot GetStateld e TSL linrot GetStateMask The functions TSL tkey IsChanged or TSL linrot IsChanged allows to check if a sensor state has changed You can also directly read the state inside the sensor data structure if MyTKeys 0 p_
12. 88 125 Hardware implementation example Figure 20 shows an example of hardware implementation on STM32F3xx devices Recommendations to increase the noise immunity on the PCB To ensure a correct operation in noisy environment the floating nets must be avoided tracks copper elements conductive frames etc As a consequence e All unused touch controller l Os must be either configured to output push pull low or externally tied to GND e The parameter TSLPRM TSC IODEF should also be configured to the output push pull low state e We recommend to drive the sampling capacitor common node using a standard I O of the touch controller configured in output push pull low mode e t may also be required to add a capacitor input filter pi filter on each channel line y DoclD024201 Rev 4 G7 1 68 y NIY LOcvcodriod Figure 20 STM32F3xx hardware implementation example 1 2 3 4 5V Ul VDD Notes LD3985M33R 1 ESD serial resistors and sampling capacitors must be placed as close as possible to MCU device 2 Sampling capacitors must be COG type or better o o 3 A dedicated low drop voltage regulator powering the touch controller is recommended S S z oe G1 104 1 aa Si Hy r KI ox o G2 104 1 10nF_X7R_0603 VDD d K2 G3 IO4 1 K3 100nF_X7R_0603 G4 102 1 K4 G5 IO2 1 K5 G5 IOI G6 102 1 G5 102 G5 103 E G5 104 G5 IO3 1 RI3 GI 104 ba BALE G6 103 R14
13. COLEA CO eS a Number of available pins 3 channels with 1 sampling capacitor 3 channels with 1 sampling capacitor 1 2 channels with 1 sampling capacitor 3 channels with 1 sampling capacitor STM32F051 STM32F072 Number of available pins 3 channels with 1 sampling capacitor 3 channels with 1 sampling capacitor 2 channels with 1 sampling capacitor 3 channels with 1 sampling capacitor Number of available 3 channels with 1 sampling capacitor 3 channels with 1 sampling capacitor 3 channels with 1 sampling capacitor 3 channels with 1 sampling capacitor Number of available STM32F051C 468B STM32F051R 468B STM32F051VB US SOS need STM32F072C 8B STM32F072R 8B STM32F052V 8B 3 channels with 1 sampling capacitor 3 channels with 1 sampling capacitor 3 channels with 1 sampling capacitor 3 channels with 1 sampling capacitor 909LINN JOALIP YINOLWIS Group 8 G8 101 G8 102 G8 103 G8 104 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 4 1 This GPIO offers a reduced touch sensing sensitivity It is thus recommended to use it as sampling capacitor I O Cannot be used for Touch sensing Cannot be used for Touch sensing Cannot be used for Touch sensing 3 channels with 1 sampling
14. Packages Part numbers Gx_lOy G4 101 G4 102 Group 4 G4 103 G5 101 G5 102 Group 5 G5 103 3 PA PA PA10 PA13 PA14 PA15 U O in 1 2 3 6 9 50 G6_101 PB4 56 G6 102 PB5 57 Group 6 G6_103 B 58 G6 104 PB7 Table 37 Available touch sensing channels for STM32L1xx 512K continued STM32L1xx 512K LQFP64 LQFP100 WLCSP104 UFBGA132 LQFP144 STM32L151RE STM32L151VE STM32L151QE STM32L151ZE STM32L152RE STM32L152VE STM32L152QE STM32L152ZE STM32L162RE STM32L162VE STM32L162QE STM32L162ZE Number Number LQFP of LQFP WLCSP of available Pin ball available pins 2 channels with 1 sampling capacitor 6 F3 F F2 72 E3 7 D B 7 1 3 2 channels with o 3 3 1 sampling 77 1 capacitor A 5 Number Number of of available i available 2 channels channels with with channels with 1 3 1 1 sampling C sampling sampling capacitor capacitor capacitor 3 12 z channels Ka channels channels 3 with 3 with with 1 1 1 sampling A9 sampling sampling capacitor capacitor capacitor p 4 4 4 4 4 3 ao a5 3 i channels channels channels channels with with n with with sampling sampling sampling sampling capacitor capacitor capacitor Ku KI E KI 56 KA KI capacitor 909LINN JOALIP YINOLWIS 3 Group 9 G8 101 G9 101 G9 102 G9 103 G9 104 G8 102 G8 103 G8 104 PCO PC1 PC PC PC4 PC PF13 Q ior PF1
15. e ANSI standard data types are used and defined in the ANSI C header file lt stdint h gt e No blocking code is present and all required waiting loops polling loops are controlled by a timeout Variable types opecific variable types are already defined with a fixed type and size e The types that are used by all modules are defined in the tsl types h file e Other variable types are defined in their corresponding module header file Peripheral registers The peripheral registers are accessed using the pointers described in the standard peripherals library mapping file Run time checking The STMTouch driver implements run time failure detection by checking the functions input parameters The run time checking is achieved using the assert param macro defined in the standard peripherals library configuration file It is enabled when the preprocessor constant USE FULL ASSERT is defined DoclD024201 Rev 4 Ly UM1606 1 5 1 5 1 1 5 2 3 Coding rules and conventions Because of the overhead it introduces it is recommended to use run time checking during application code development and debugging and to remove it from the final application to improve code size and speed However if you want to keep this functionality in your final application reuse the assert param macro defined in the standard peripherals library to test the parameter values before calling the STMTouch driver functions Please see the standard periph
16. 65 Table 15 STM8TLbx memory footprint with prokimity 65 Table 16 STM8TLbx acquisition timings 66 Table 17 STM8TLbx MCUresourcesused 67 Table 18 Available touch sensing channels for STM8TLD5K 69 Table 19 STM32FO0xx memory footprint without prokimity 74 Table 20 STM32FO0xx memory footprint with proximity 14 Table 21 STM32F0xx MCUresourcesused 74 Table 22 Available touch sensing channels for STM32F042 75 Table 23 Available touch sensing channels for STM32F051 and STM32F072 77 Table 24 STM32F30x memory footprint 82 Table 25 STM32F37x memory footprint 82 Table 26 STM32F3xx MCUresourcesused 82 Table 27 Available touch sensing channels for STM32F30K 83 Table 28 Available touch sensing channels for STM32F37K 85 Table 29 STM32L1xx HD memory footprint without proximity 91 Table 30 STM32L1xx HD memory footprint with prokimity 91 Table 31 STM32L1xx MDP memory footprint without
17. Acquisition layer Standard peripherals library MSv31729V1 The STMTouch driver is composed of three main layers e The acquisition layer e The processing layer e The configuration layer The configuration layer corresponds to what the user needs to write in its application code in order to use correctly the STMTouch driver This includes all the channels and sensors declaration the parameters etc The acquisition and processing layers are described more in detail below Acquisition and processing layers The following figure details the acquisition and processing layers and the different elements used in each layer 3 DoclD024201 Rev 4 UM1606 a STMTouch driver Figure 5 Acquisition and processing layers Acquisition J channel layer Channel data layer sensors ECS DKS Processing Ly touchkey linear rotary DTO layer Filters Timing MSv31730V1 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 i
18. CHANNEL 3 SRC CHANNEL 3 IO MSK CHANNEL 3 GRP MSK Bank 2 CHANNEL 4 SRC CHANNEL 4 IO MSK CHANNEL 4 GRP MSK CHANNEL 5 SRC CHANNEL 5 IO MSK CHANNEL 5 GRP MSK CHANNEL 6 SRC CHANNEL 6 IO MSK CHANNEL 6 GRP MSK Bank Principle A bank is a group of channels that are acquired simultaneously The number of channels in the bank is variable DoclD024201 Rev 4 Ly UM1606 2 6 2 2 6 3 2 6 4 3 STMTouch driver Resources The bank data are held by only one structure e SL Bank T e The bank depends also on the acquisition technology These structures are declared in each acquisition header files tsl acq_ lt mcu gt 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 e TSL acq BankGetResult e TSL acq BankCalibrate Device dependent functions e TSL acq BankConfig e TSL acq BanksStartAcq e SL acq BankWaitEOC Parameters e TSLPRM TOTAL BANKS Usage example Example of 2 banks declaration for STM8TLbx devices Always placed in ROM const TSL Bank T MyBanks TSLPRM TOTAL BANKS Bank 0 sMyChannels Src 0 sMyChannels Dest 0 MyChannels Dat
19. CT UM1606 WI life augmented User manual STMTouch driver user manual Introduction The document covers the following touch sensing library product codes e STM8L TOUCH LIB e STM8TL TOUCH LIB e 32L1 TOUCH LIB e 32F0 TOUCH LIB e 32F3 TOUCH LIB The STM Touch driver includes e A complete register address mapping with all bits bitfields and registers declared in C This avoids a cumbersome task and more importantly it brings the benefits of a bug free reference mapping file soeeding up the early project phase e A collection of routines and data structures covering all functions to manage the touch sensing technology The STMTouch driver source code is developed using the ANSI C standard It is fully documented and is MISRA C 2004 compliant Writing the whole library in Strict ANSI C makes it independent from the development tools Only the start up files depend on the development tools Run time failure detection is also implemented by checking the input values for all library functions Such dynamic checking contributes towards enhancing the robustness of the firmware Run time detection is suitable for user application development and debugging It adds an overhead which can be removed from the final application code to minimize code size and execution speed For more details refer to Section 1 4 Run time checking Since the STMTouch driver is generic and covers many functionalities and devices the size and or ex
20. Rotary m l positioned in a circular way Sensor or Object Any touch sensor touchkey linear rotary Acquisition using two timers and PWM signals Timer acquisition mode Also called hardware acquisition mode Available on STM32L1xx devices Touchkey or TKey sensor Single channel sensor DoclD024201 Rev 4 9 125 Coding rules and conventions UM1606 1 2 1 3 1 3 1 1 3 2 1 3 3 1 4 10 125 Naming conventions The following naming conventions are used in the STMTouch driver source files e Source and header files are in lower case and preceded by tsl or tsl_ e The microcontroller family is added at the end of the file name if needed e Functions globals typedefs and defines are preceded by TSL e Constants are written in upper case and preceded by TSLPRM e Constants used in one file are defined within this file only e Constants used in more than one file are defined in a header file e Typedef names are suffixed with T e Enum typedefs are suffixed with enum T e Functions are preceded TSL module function module abbreviation of the file acq tim dxs etc function the first letter in each word is in upper case Coding rules This section describes the coding rules used in the STMTouch driver source files General e Source code complies with ANSI C standard e No warning after compilation Any warnings that cannot be eliminated are commented in the source code
21. 20 125 DoclD024201 Rev 4 UM1606 2 5 2 2 5 3 2 54 3 STMTouch driver Resources A channel is defined by 3 data structures e TSL ChannelSrc T contains all information about the source measurement index of the register containing the measurement masks e TSL ChannelDest T contains all information about the measurement destination index in the channel data array e 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 e tsl acq stm8l hw h for STM8L devices using hardware acquisition mode e tsl acq stm8l sw h for STM8L devices using software acquisition mode e tsli acq stm tl5x h for STM8TL5x devices e tsl acq stm32l1xx hw h for STM32L1xx devices using the hardware acquisition mode e tsl acq stm32l1xx sw h for STM32L 1xx devices using the software acquisition mode e tsl acq stm32f0xx h for STM32FO0xx devices e 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 Parameters e TSLPRM TOTAL CHANNELS Usage example The 3 channels structures must be
22. G3 103 PDE 23 G4 101 7 4 3 3 2 l 2 channels with 2 channels with Group 4 G4_102 1 3 1 sampling 1 sampling 0 capacitor capacitor 9 8 3 7 1 channel with 1 sampling capacitor 2 channels with 2 channels with 1 sampling 1 sampling capacitor capacitor 2 channels with 1 sampling capacitor G4 103 G5 101 G5 102 G5 103 2 channels with 1 sampling capacitor 2 channels with 2 channels with 1 sampling 1 sampling Capacitor Capacitor N N Ws 0 wy I O O O a Od OPP NO GCL 6S 909 LINN JOALIP YONOLIWLS 2 Table 13 Available touch sensing channels for STM8L15x STM8L16x table 2 2 continued o STM8L151C medium medium high density f STM8L151R M Subfamily STM8L151K STM8L151C low density STM8L152C R M STM8L162R M UFQFPN32 LQFP32 UF QFPN48 LQFP48 LQFP64 LQFP80 LQFP48 STM8L151C 468 UT STM8L152C 468 UT 48 pins STM8L151R 68 T STM8L152R 68 T STM8L151K3U a Part numbers STM8L151K 46 UT STM8L162R8T STM8L151C3T 64 pins U 8 STM8L151M8T 3 STM8L152M8T iN STM8L162M8T C 80 pins TI D lt I Number Number Number of f of of XI available Cin Pim En available available pins moi dene 2 channels with 2 channels with 2 channels with Group 6 G6 102 PB2 1 sampling 3 1 sampling 1 sampling B G6 IO3 PB1 capacitor capacitor capacitor G7 102 3 2 channels with 2 channels with 3 channels with Group 7 3 1 sampling 3 1 sampling 4 1 sampli
23. STMTouch driver UM1606 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 Figure 11 Example of main state machine MSv31736V1 Ly 2 12 Sensors state machine 2 12 1 Overview The state machine is managed in the files e tsl touchkey c and tsl touchkey h for the touchkey sensors e tsl linrot c and tsl linrot h for the linear and rotary sensors 36 125 DoclD024201 Rev 4 UM1606 2 12 2 a STMTouch driver There is a total of 20 states defined in the TSL Stateld enum T structure The following figure shows the simplified state machine used by any sensor for clarity not all the connections between states are shown Figure 12 Simplified sensors state machine deb BELEN EE deb RELEASE D 9p R
24. externally tied to GND e The parameter TSLPRM_TSC_IODEF should also be configured to the output push pull low state e We recommend to drive the sampling capacitor common node using a standard I O of the touch controller configured in output push pull low mode e t may also be required to add a capacitor input filter pi filter on each channel line DoclD024201 Rev 4 19 125 GZL 08 y NIY LOcvcodiod Figure 19 STM32F0xx hardware implementation example 1 2 3 4 EN Ul VDD Notes l LD3985M33R 1 ESD serial resistors and sampling capacitors must be placed as close as possible to MCU device Ng 2 Sampling capacitors must be COG type or better o o 3 A dedicated low drop voltage regulator powering the touch controller is recommended S 3 3 S al z G1 104 1 pa Es Gas a a al a E 5 KAIN KI 3 s alae 6 5 5 G2 104 1 10nF_X7R_0603 K2 C6 C7 C8 C9 100nF_X7R_0603 LIL Eee eee G5 102 Shield SAMPLING CAPACITOR C16 XSR 0603 1pF IH 15nF COG 1206 iA iA iA iA G5 IOI G5 IO2 VDD R15 10K 590 0603 Quartz 8MHz C17 22pF COG 0603 C18 Ii COG 060P 22pF R18 Yo 0603 10K_5 _0603 C10 i lOnF X7R 0603 R14 10K 576 0603 G1 IO2 1 G2 IO2 2 G3 IO2 3 VDD LTS1 Linear touch sensor Q TI X Q E O NI Q K o G4 104 1 K6 G6 102 1 K7 G6 IO3 1 K8 G6 104 1 K9 RTSI Rot
25. CounterDebCalib CounterCDebProx CounterCDebDetect CounterDebRelease CounterlebError CounterDebDirecton Resolution QirChangeFos 15 10 oO 25 5 3 DoclD024201 Rev 4 Dx 200000064 O 20000065 Dx20000066 Dx20000067 Dx20000065 Dx20000063 Dx2000006A Dx2000006E O 2000006C Dx2000006D Dx200000bE Dx2000006F Dx20000070 uinte t uinta t uinta t uinte t uinta t uinta t uinta t uinte t uinta t uinta t uinte t uinta t uinta t y UM1606 3 9 3 5 1 Note 3 9 2 3 5 3 3 Getting started Tips and tricks Bank definition For optimum sensitivity and position reporting all the channels composing a linear or a rotary touch sensor must be acquired simultaneously This means that all the channels must belong to the same bank 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 Channel assignment It is recommended to assign GPIOs offering the same sensitivity level to all the channels composing a linear or a rotary touch sensor Moreover it is not recommended to use GPIOs offering a reduced sensitivity IO Default state parameter For optimum acquisition noise level it is recommended to set the TSLPRM TSC IODEF or TSLPRM_IODEF parameter to
26. G9 101 G9 102 G9 103 G9 104 G10 101 G10 102 G10 03 G10 104 G11 101 G11 102 G11 103 G11_104 G11 105 Table 39 Available touch sensing channels for STM32L1xx 256K table 1 2 continued LQFP64 WLCSP64 STM32L151RC STM32L152RC PC PC1 PC PC PC PC PF1 PF1 PC PC PC PC PF6 PF7 PF8 PF9 PF10 NIOJ A LQFP48 or UFQFPN48 STM32L152CC Number of available pins Cannot be used for touch sensing STM32L1xx 256K WLCSP63 STM32L151UC Number of WLCSP ball C m m m mM ojm n N available pins 3 channels with 1 sampling capacitor 1 sampling capacitor 1 sampling capacitor LQFP pin Ed STM32L162RC WLCSP ball 8 KAKA Number of available 3 channels with 1 sampling capacitor 1 channel with 1 sampling capacitor 3 channels with 1 sampling capacitor Cannot be used for touch sensing JOALIP YONOLWLS 909LINN y NIY LOCcvcodIi od GCL SOL Table 39 Available touch sensing channels for STM32L1xx 256K table 1 2 continued Subfamily STM32L1xx 256K LQFP48 or UFQFPN48 WLCSP63 LOFP64 WLCSP64 STM32L151RC Part numbers STM32L152CC STM32L151UC STM32L152RC STM32L162RC Number Number Number Gx IOy of WLCSP of LQFP WLCSP of available ball available pin ball available pins pins pins 16 channels with 7 23 channels with 10 23 channels with 10 Maximum number of channels sampling capacitors sampling capac
27. M2IH D With e nz number of channels e LIN linear sensor e ROT rotary sensor e M1 mono electrodes design with 0 255 position at extremities e M2 mono electrodes design e H half ended electrodes design e D dual electrodes design In order to gain memory space each table is only compiled if its corresponding parameter is set in the configuration file TSLPRM USE nCH LIN ROT M1 M2 H D Resources All the functions related to this sensor are described in the files e tsl linrot c e tsl linrot h Two types of linear and rotary sensor are available e basic defined by the TSL LinRotB T structure e 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 e TSL linrot Init e TSL linrot Process e TSL linrot CalcPos Parameters e TSLPRM TOTAL LINROTS Usage example The user must declared these methods in the application code One can also use its own initialization and process functions instead CONST TSL LinRotMethods T MyLinRots Methods TSL linrot Init TSL linrot Process TSL linrot CalcPos y DoclD024201 Rev 4 UM1606 a STMTouch driver The declaration of the linear and rotary sensor is done by the user in the application code in the same manner as for touchkey
28. RAM Channels Kbytes bytes 10 TKeys 1 Linear 3ch 9 1 630 1 Rotary 3ch See Section 3 1 1 Toolchain compiler preprocessor section for definition of STM32L1xx_HD 2 The content of this table is provided for information purposes only Table 30 STM32L1xx_ HD memory footprint with prey Channels bow enl 10 TKeys 1 Linear 3ch 1 Rotary 3ch 1 See Section 3 1 1 Toolchain compiler preprocessor section for definition of STM32L1xx HD 2 he content of this table is provided for information purposes only The following tables summarize the memory footprint taken by the STMTouch driver using the software acquisition mode on STM32L1xx Medium density Plus devices DoclD024201 Rev 4 91 125 STMTouch driver UM1606 Table 31 STM32L1xx MDP memory footprint without proximity 2 ROM RAM Channels Kbytes bytes 1 See Section 3 1 1 Toolchain compiler preprocessor section for definition of STM32L1xx MDP 2 The content of this table is provided for information purposes only Table 32 STM32L1xx MDP memory footprint with proximity ROM RAM Channels Kbytes bytes 2 2 1 See Section 3 1 1 Toolchain compiler preprocessor section for definition of STM32L1xx_MDP 2 The content of this table is provided for information purposes only The following tables summarize the memory footprint taken by the STMTouch driver using the software acquisition mode on STM32L1xx Medium density devices Table 3
29. 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 ST PRODUCTS ARE NOT DESIGNED OR AUTHORIZED FOR USE IN A SAFETY CRITICAL APPLICATIONS SUCH AS LIFE SUPPORTING ACTIVE IMPLANTED DEVICES OR SYSTEMS WITH PRODUCT FUNCTIONAL SAFETY REQUIREMENTS B AERONAUTIC APPLICATIONS C AUTOMOTIVE APPLICATIONS OR ENVIRONMENTS AND OR D AEROSPACE APPLICATIONS OR ENVIRONMENTS WHERE ST PRODUCTS ARE NOT DESIGNED FOR SUCH USE THE PURCHASER SHALL USE PRODUCTS AT PURCHASER S SOLE RISK EVEN IF ST HAS BEEN INFORMED IN WRITING OF SUCH USAGE UNLESS A PRODUCT IS EXPRESSLY DESIGNATED BY ST AS BEING INTENDED FOR AUTOMOTIVE AUTOMOTIVE SAFETY OR MEDICAL INDUSTRY DOMAINS ACCORDING TO ST PRODUCT DESIGN SPECIFICATIONS PRODUCTS FORMALLY ESCC QML OR JAN QUALIFIED ARE DEEMED SUITABLE FOR USE IN AEROSPACE BY THE CORRESPONDING GOVERNMENTAL AGENCY 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 th
30. STM32F042 TSSOP20 UFQFPN28 LQFP32 UFQFPN32 WLCSP36 LQFP48 UFQFPN48 4 16K 6 32K STM32F042F 46 STM32F042G 46 STM32F042K 46 STM32F042T 46 STM32F042C 46 Number of Pin available LQFP pins Number of available pins Cannot be used for Touch sensing Cannot be EI used for KY Touch sensing Cannot be used for Touch sensing This GPIO offers a reduced touch sensing sensitivity It is thus recommended to use it as sampling capacitor 1 0 2 Pin pair PA11 PA12 can be remapped instead of pin pair PA9 PA10 using SYS_CTRL register Number of available pins Cannot be used for Touch EN sensing Cannot be used for Touch sensing Cannot be used for Touch sensing Number of available pins Cannot be used for Touch sensing Cannot be used for Touch sensing Cannot be used for Touch sensing with 3 sampling capacitors 11 with 5 sampling capacitors 13 14 with 5 sampling capacitors 4 with 5 t win 5 sampling capac cpactrs 14 vit Ssampingcapactor 14 vitn 5 sampling capactors 14 with 5 ain 5 samping capaci capacitors J9AlJp YONOLWLS 909LINN a y NIY LOTYZOG 30G GCL LL Table 23 Available touch sensing channels for STM32F051 and STM32F072 Subfamily LOFP32 UFQFPN32 LQFP48 LQFP64 LQFP100 4 16K 6 32K 8 64K B 128K C 256K Flash NEZ numbers Group 1 Group 2 Group 3 memory size Pin m ze ni ES CIA aros pala a COLEEN woe
31. be used on any new device that may become available as part of ST microcontrollers portfolio Please contact your ST representative for support For n available pins in an I O group one pin is used as sampling capacitor and n 1 pins are used as channels The I O group cannot be used if the number of available pins in less or equal to one y DoclD024201 Rev 4 3 y NIY LOTYZOG FOG GC GG U o c c o s Ss Q o o T Part numbers Gx_lOy G1 102 G1 103 G1 104 G2 IO1 G2 102 G2 103 G2 lO4 Maximum number of channels Group1 PD PB2 PB3 Group2 Table 11 Available touch sensing channels for STM8L101 STM8L101F 23 U STM8L101F 23 P Number of available pins 2 channels with 1 sampling capacitor 1 channel with 1 sampling capacitor 3with 2 sampling capacitors with 2 3with 2 sampling capacitors capacitors STM8L101 STM8L101G 23 U Number of available 3 channels with 1 sampling Capacitor 3 channels with 1 sampling capacitor 6with 2 sampling capacitors with 2 6with 2 sampling capacitors Capacitors TSSOP20 UFQFPN20 UFQFPN28 UFQFPN32 LQFP32 STM8L101K3 UT Number of available 3 channels with 1 sampling capacitor 3 channels with 1 sampling capacitor G6 with 2 sampling capacitors with 2 G6 with 2 sampling capacitors Capacitors 909LINN JOALIP YINOLWIS GZL 9S y NIY LOCvcOdl90d G1_101 G1 102 Group 1 G1 I
32. 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 Resources The ECS functions are provided in the files e tsl ecs c e tsl ecs h The functions are e TSL ecs Process main function to be used by the user e TSL ecs CalcK additional function e TSL ecs ProcessK additional function y DoclD024201 Rev 4 UM1606 2 13 3 2 13 4 3 STMTouch driver Parameters e TSLPRM ECS K FAST e TSLPRM ECS K SLOW e TSLPRM ECS DELAY Usage example The ECS processing is usually performed in the main state machine at regular time intervals defined by the user But it can be done also in interrupt routines It must be performed after the sensors state machine is processed The ECS is activated only when all the sensors are in RELEASE ERROR or OFF states with at least one sensor in RELEASE state It can also be delayed from milli seconds to few seconds The ECS processing is performed on a group of sensors defined by the user Different groups can be created and ECS applied on these groups with different K coefficients It s up to the user to decide the best thing to do for its application The simplest way is to call the TSL ecs Process function in the main applicatio
33. capacitor J Table 23 Available touch sensing channels for STM32F051 and STM32F072 continued N Subfamily STM32F051 STM32F072 LQFP32 UFQFPN32 LQFP48 LQFP64 LQFP100 Flash memory size 4 16K 6 32K 8 64K B 128K C 256K STM32F051C 468B STM32F051R 468B STM32F051VB ak TOR STM32F072C 8B STM32F072R 8B STM32F052V 8B pamper Name Numberof Numberof Gx IO on ca or available available ay LQFP available available ing pins pins P G5 101 PB3 26 26 39 55 SM BN NE 3 channels Ea 3 channels 55 3 channels 3 channels n with 1 with d with with 1 U capacitor capacitor capacitor capacitor 8 G5 04 N Cannot be 3 channels 3 channels 3 channels ps G6 103 PB13 ps foe touch sampling sampling sampling 2 Seen capacitor capacitor capacitor Ni s6104 PB14 oo ee Cannot be Cannot be Cannot be 3 channels G7 102 PEB o used for m used for used for with 1 OD Touch Touch Touch i ZOC Ja MI e sensing sensing sensing capacitor ore ves a EN JOALIP YONOLWLS 909LINN UM1606 STMTouch driver 2 21 7 Hardware implementation example Figure 19 shows an example of hardware implementation on STM32FOxx devices Recommendations to increase the noise immunity on the PCB To ensure a correct operation in noisy environment the floating nets must be avoided tracks copper elements conductive frames etc As a consequence e All unused touch controller I Os must be either configured to output push pull low or
34. declared in the application code Example of channel source array declaration for STM32FOxx devices This structure must always be placed in ROM const TSL ChannelSrc T MyChannels Src TSLPRM TOTAL CHANNELS CHANNEL 0 SRC j CHANNEL 1 SRC CHANNEL 2 SRC 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 Jj CHANNEL 1 DEST CHANNEL 2 DEST DoclD024201 Rev 4 21 125 STMTouch driver UM1606 Note 2 6 2 6 1 22 125 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 Warning When several banks are present it is mandatory to declare all channels of each bank consecutively in the source and destination structures Example Figure 7 Channels arrangement Channel data layer MSv31732V1 Example of channel source array declaration for STM32FO0xx devices CONST TSL ChannelSrc T MyChannels Src TSLPRM TOTAL CHANNELS Bank 1 CHANNEL 0 SRC CHANNEL 0 IO MSK CHANNEL 0 GRP MSK CHANNEL 1 SRC CHANNEL 1 IO MSK CHANNEL 1 GRP MSK CHANNEL 2 SRC CHANNEL 2 IO MSK CHANNEL 2 GRP MSK
35. implementation example GZL ELL y NIY LOCcvcodi od 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 1 2 3 4 TIN WI VDD Notes 1 ESD serial resistors and sampling capacitors must be placed as close as possible to MCU device 2 Sampling capacitors must be COG type or better G1 104 1 EN Z 1 100nF X7R 0603 100nF X7R 0603 I Ww O N 5 N 10nF_X7R_0603 G6 102 j I an o N UI 1 RI 59 10K 5 0603 R2 56 10K 5 0603 I J pas C6 C7 C8 c9 C10 U2 STM32L15x 58 57 1 100nF X7R 0603 I NO o N Un R oe VDD 22pF COG 0603 CAY C17 XTAL 8Mhz ER R3 E 1 G4 103 G4 102 S S UI 10K 596 0603 22pF COG 0603 v oe 3 o o 4s o 7 N G8 IOI G4 101 G8 102 G10 104 G10 104 1 a C13 G10 103 10nF X7R 0603 G10 102 T 0603 G10 101 G7 104 XD CNOI vp G7 103 Gl 102 RI4 os G7 102 GI 103 RI6 0603 G7 IO1 10K_5 _0603 B SHIELD aaa G8 102 Shield Ko Lund Lese N GN is R o So s G1 104 RI7 EE TOK 5 0603 a RE o aKa AAA BANI TEC e cht ct asters cits ascend cet tah celebs Vi S G1 101 G3 101 alalala G4 101 alala RTSI LTS1 G6 101 Boos 103 1 G10 IO1 Linear touch sensor C14
36. 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 Resources This feature is optional and is enabled disabled using the TSLPRM USE ZONE parameter The zone data are held by only one structure e SL Zone T The zones are used mainly by the function e SL acq ZoneConfig y DoclD024201 Rev 4 UM1606 2 1 3 2 1 4 2 8 2 8 1 2 8 2 2 8 3 2 8 4 3 STMTouch driver Parameters e TSLPRM USE ZONE Usage example Example of a zone declaration containing 3 banks TSL tIndex T MyBankSorting TSLPRM TOTAL BANKS 2 O 1 3 4 5 TSL Zone T MyZone MyBankSorting 0 3 Number of Banks in the Zone 15 In this example the MyBankSorting array contains the list of the banks indexes to acquire And only the 3 first Banks will be acquired indexes 2 O and 1 Objects Principle The term object or sensor stands for any sensors type touchkeys linear and rotary touch sensors etc supported by the STMTouch driver Resources All processing that affect the sensors in general are defined in e tsl object c e tsl object h The functions are e TSL obj Grouplnit e TSL obj GroupProcess e TSL obj SetGlobalObj A sensor is described by the structures e TSL Object T e TSL ObjectGroup T Par
37. or sensors e Each sensor can have its own state machine e Simplified timing management e Run time checking of functions parameters e Management of error during acquisition 16 125 DoclD024201 Rev 4 UM1606 y UM1606 STMTouch driver 2 4 Architecture 2 4 1 Overview The following figure shows the interactions between the STMTouch driver and the other firmware layers Figure 3 STMTouch driver architecture overview Application User applications examples layer STMTouch driver Hardware abstraction layer 0 HAL Standard peripherals library Hardware layer MSv31728V1 The HAL is the hardware abstraction layer HAL which controls the device itself through hardware registers It is composed of different components e he STMTouch driver e The standard peripherals library e The CMSIS firmware for STM32 devices only e 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 2 4 2 STMTouch driver layers The following figure shows a more detailed view of the different STMTouch driver layers DoclD024201 Rev 4 17 125 a STMTouch driver UM1606 2 4 3 18 125 Figure 4 STMTouch driver detailed layers Application aNg STMTouch driver layer User application configuration Processing layer STMTouch driver Touchkey Linear and sensor rotary sensors
38. output push pull low However if your application is using a linear or a rotary touch sensor with channels belonging to different banks this parameter must be set to input floating This will ensure optimum sensitivity DoclD024201 Rev 4 123 125 Revision history 4 Revision history UM1606 Table 42 Document revision history e Ren Ohaus 19 Mar 2013 Initial release li i Updated document title Updated Section Introduction Updated Section 1 2 Naming conventions Updated Section 2 1 1 Supported devices Updated Section 2 3 Main features Updated Section 2 5 2 Resources Updated Section 2 5 4 Usage example Updated Section 2 6 2 Resources Added Section 2 19 STM8L 1xx devices Updated Table 22 Available touch sensing channels for S TM32F0xx Updated Section 3 1 1 Toolchain compiler preprocessor section Updated Table 28 Available touch sensing channels for STM32F37x Updated Table 35 MCU resources used on STM32L1xx with hardware acquisition Updated Table 36 MCU resources used on STM32L1xx with software acquisition Updated all channel tables of STM8L STM32L and STM32F0 products Added STM32L1xx 512K channel table Table 22 Available touch sensing channels for STM32F042 Added STM32L1xx 512K channel table Table 37 Available touch sensing channels for STM32L1xx 512K Added Chapter 3 5 Tips and tricks Updated Section 2 1 1 Updated Table 22 Updated Section 3 1 1
39. prokimity 92 Table 32 STM32L1xx MDP memory footprint with proximity 92 Table 33 STM32L1xx MD memory footprint without prokimity 92 Table 34 STM32L1xx MD memory footprint with proximity 92 Table 35 MCU resources used on STM32L1xx with hardware acquisition 93 Table 36 MCU resources used on STM32L1xx with software acguisition 93 Table 37 Available touch sensing channels for STM32L1xx 512K 94 Table 38 Available touch sensing channels for STM32L1xx 384K 98 Table 39 Available touch sensing channels for STM32L1xx 256K table 1 2 102 Table 40 Available touch sensing channels for STM32L1xx 256K table 2 2 106 Table 41 Available touch sensing channels for STM32L15x 32K to 128K 109 Table 42 Document revision history 124 Ly DoclD024201 Rev 4 7 125 List of figures UM1606 List of figures Figure 1 Installation folder 1 2 15 Figure 2 Installation folder 2 2 16 Figure 3 STMTouch driver architecture OvervieW 17 Figure 4 STMTouch driver detailed layers
40. the electrodes are duplicated and interlaced together in order to increase the touch area This design is used for linear and rotary sensors composed with at least 5 channels Abbreviation LIN D and ROT D Examples with 5 channels CH1 CH2 CH3 CH4 CH5 CH1 CH3 CH5 CH2 CH4 CH1 CH2 CH3 CH4 CH5 CH2 CH4 CH1 CH3 CH5 CH1 CH2 CH3 CH4 CH5 CH3 CH1 CH4 CH2 CH5 3 Half ended electrode design The first electrode is duplicated and the replica is placed at the end The size of the first and last electrode is half the size of the other electrodes This design is used for linear sensors only The 0 and 255 positions are obtained more easily compared to the Mono electrodes design Abbreviation LIN_H Examples ch1 CH2 CH3 chi ch1 CH2 CH3 CH4 chi ch1 CH2 CH3 CH4 CH5 ch1 The following figure summarizes the different electrodes designs we can have on linear and rotary sensors DoclD024201 Rev 4 29 125 STMTouch driver 30 125 UM1606 Figure 8 Electrodes designs a CIE RN Mono electrodes design Half ended electrodes design Dual electrodes design LIN M1 ROT M LIN M2 LIN H cm EE EZ ED EZ ETE EXE ETE EIE E CI ES EB EZ MSv31733V1 Positions 0 and 255 Special care must be taken for the 0 and 255 positions on linear sensors These positions are placed differently depending on the electrodes design used e LIN M1 the O and 255 positions are placed completely at the sensor s extremiti
41. touchkeys 30000 Calibration 4banks Acquisition Initialization icu a py oo be repeated for each 66 125 DoclD024201 Rev 4 y UM1606 STMTouch driver Table 16 STM8TL5x acquisition timings continued ee mao naawa Pro UP 1 PASS 1 Reference target set to 500 UP 1 PASS 2 whatever the number of enabled Hardware acquisition receivers UP 2 PASS 2 PXS CKCR1 0x70 i e HSI PXS UP 3 PASS 3 16 MHz PUN by enabled 97 receiver Touchkey processing TSL_obj_GroupProc 3 touchkeys 63 One object group ess0 19 touchkeys 460 Two object groups 3 touchkeys touchkeys Stouchkeys 302 Including hardware acquisition but Full processing TSL action without the ECS which is executed Sume 720 ECS processing TSL ecs Process aA sasmasakishioh 1 The content ofthis table is provided for information purposes only 2 20 6 MCU resources The table below shows the peripherals that are used by the STMTouch driver on STM8TL5x devices Care must be taken when using them to avoid any unwanted behavior Table 17 STM8TL5x MCU resources used GPIOs Acquisition 8 bit timer TIM 4 Time base for ECS and DTO ProSense PXS 3 DoclD024201 Rev 4 67 125 STMTouch driver UM1606 2 20 7 Note 68 125 STM8TL5x available touch sensing channels The table below provides an overview of the available touch sensing channels for the STM8TL5x devices The following table is not restrict
42. transfer acquisition principle managed by the touch sensing controller Up to 24 channels Up to 8 channels can be acquired simultaneously see Table 22 Table 23 Table 27 and Table 28 for more details Spread spectrum feature Programmable charge transfer frequency and max count value DoclD024201 Rev 4 Ly UM1606 STMTouch driver 2 1 2 2 2 3 Development tools The STM8 and STM32 microcontrollers are supported by a full range of development solutions from lead suppliers that deliver start to finish control of application development from a single integrated development environment The STMTouch driver has been developed with the following toolchains and compilers e STVD STMicroelectronics Raisonance and Cosmic compilers e EWSTM8 and EWARM IAR e MDK ARM Keil e Tasking Altium e TrueSTUDIO9 C Atollic e Ride7 RKit Arm Raisonance For more details about the compilers versions used please see the STMTouch driver release note present in the STMTouch Library installation folder Package description The STMTouch driver is not supplied by itself It is delivered instead inside each device STMTouch library STMTouch Driver folder present in the Libraries folder The following snapshots show an example of installation Figure 1 Installation folder 1 2 Se STM3a8F STMTouch Lib v1 00 Rp htmresc o Libraries Eq CMSIS Hy STM dPeriph_Driver STMTouch Driver f y src Helease Motes h
43. you want to use the software acquisition mode you must add the following constant in the toolchain compiler preprocessor e TSLPRM STM32L1XX SW ACQ Functions used by the application layer and that are device dependent e SL acq BankConfig e SL acq BankstartAcq e SL acq BankWaitEOC e SL acq GetMeas The other functions in this file are for internal use and the user doesn t need to call them directly Timings The STM32L 1xx devices timing management is done in the files e tsl time stm32l1xx c e tsl time stm32l1xx h The systick is used to generate a timebase for the ECS and DTO modules Functions used e TSL tim Init Parameters The parameters specific to the STM32L 1xx devices are described in the file e tsl conf stm32l1xx h and are checked in the file e tsl check config stm321l1xx h DoclD024201 Rev 4 Ly UM1606 STMTouch driver 2 23 4 Memory footprint Conditions e IAR ANSI C C Compiler V6 30 1 for ARM e Compiler options optimization high balanced e AR library not counted e SIMrTouch driver default options ECS ON DIO ON ZONE OFF DXS ON excepted if only one sensor is used e 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 Table 29 STM32L1xx_HD memory footprint without proximity ROM
44. 10K 5Yo 0603 G5 104 SAMPLING CAPACITOR reserexueneenextunmtacmuiten iie UR G1 IOl I3 47nF COG 1206 Q P 47nF COG 1206 IH 47nF COG 1206 2 HE 15nF COG 1206 15nF COG 1206 4 Quartz 8MHz C20 22pF COG 0603 C21 Ii COG d603 22pF R17 10K_5 0603 C19 100nF X7R 0603 G1 102 G2 102 G3 102 1 2 3 LTS1 Linear touch sensor RTS1 Rotary touch sensor Title STM32F3xx CT Reference Design STMicroelectronics Microcontrollers Division N KG AA Aa MA SUA ANNA ol CH Size A4 Reference Revision A 00 190 avenue Celestin COQ 13106 ROUSSET Cedex Date 01 FEB 2013 Sheet 1 of 1 FRANCE 1 2 3 4 1914p YONOLWLS 909LINN STMTouch driver UM1606 2 23 2 23 1 Note 2 23 2 2 23 3 90 125 STM32L1xx devices Acquisition The STM32L1xx devices hardware acquisition mode using two timers is done in the files e tsl_acq_stm32I1xx_hw c e tsl acq stm32l1xx hw h Warning This acquisition mode is available for the STM32L1xx High density and STM32L1xx Medium density Plus devices only The STM32L 1xx devices software acquisition mode is done in the files e tsl acq stm32l1xx sw c e tsl acq stm32l1xx sw h This acquisition is available for all STM32L 1xx devices The hardware acquisition mode is selected per default for the STM32L1xx High density and Medium density Plus devices If
45. 162ZD Number Number Number Gx 10 LQFP WLCSP of of of of y pin ball available i available available i available pins G1_101 PAO 14 F6 3 3 1101 Pao 14 Fe WW m m Rares Group 1 LE with with with with PA2 16 H8 1 1 1 1 1 Hg Mw sampling sampling sampling capacitor capacitor capacitor capacitor 3 3 channels channels with with 1 1 sampling mm sampling sampling capacitor capacitor capacitor G1 103 G1 104 PA3 G2 IO1 G2 102 PA7 Group 2 G2 103 PF15 G2 104 PGO G2 105 PG1 9 G3 101 PBO G3 102 PB1 Group 3 G3 103 PB2 G3 104 PF11 G3 105 PF12 PA6 NO NINI N NIA o xo WIN N G A oO Tc m1 Lt oo A DA NM 4 4 channels channels channels channels with with with 1 1 1 1 sampling EN sampling sampling sampling capacitor capacitor capacitor capacitor JOALIP YONOLWLS 909LINN Table 38 Available touch sensing channels for STM32L1xx 384K continued 4 Subfamily STM32L1xx 384K Packages LQFP64 WLCSP64 LQFP100 UFBGA132 LQFP144 STM32L151RD STM32L151VD STM32L151QD STM32L151ZD Part numbers STM32L152RD STM32L152VD STM32L152QD STM32L152ZD STM32L162RD STM32L162VD STM32L162QD STM32L162ZD Number Number Number Number Gx 10 LQFP WLCSP of of BGA of of ay pin ball available available ball available i available pins pins pins G4 101 PAB 4 2 Di G4 102 PA9 channels Group 4 Mu G4 103 PA10 G5 101 PA13 G5 IO2 PA14 Group 5 1 samp
46. 2 channels with 1 sampling capacitor 2 channels with 1 sampling capacitor oO JOALIP YONOLWLS 909LINN GZL OLL Subfamily LQFP48 VFQFPN48 LQFP64 BGA64 LQFP100 BGA100 Table 41 Available touch sensing channels for STM32L15x 32K to 128K continued STM32L151C6 STM32L151C8 STM32L151CB STM32L152C6 STM32L152C8 STM32L152CB STM32L15x 32K to 128K STM32L151R6 STM32L151R8 STM32L151RB STM32L152R6 STM32L152R8 STM32L152RB STM32L151V8 STM32L151VB STM32L152V8 STM32L152VB JOALIP YONOLWLS y NIY LOCcvcodi od Gx lOy G6 IO1 PB Group 6 G6 IO2 PB5 Group 7 ES G7_104 PB15 1 channel with 1 sampling Capacitor LQFP BGA LQFP BGA pin ball available pin ball available pins pins KIKI 1 channel with 56 LAG 1 channel with 1 sampling 2 1 sampling 2 capacitor capacitor 3 channels with 3 channels with 1 sampling 4 1 sampling capacitor capacitor 3 channels with 1 sampling capacitor 909LINN GZL LLL y NIY LOCcvcodi od Table 41 Available touch sensing channels for STM32L15x 32K to 128K continued Subfamily STM32L 15x 32K to 128K LQFP48 VFQFPN48 LQFP64 BGA64 LQFP100 BGA100 STM32L151C6 STM32L151R6 STM32L151C8 STM32L151R8 STM32L151V8 Bad number STM32L151CB STM32L151RB STM32L151VB STM32L152C6 STM32L152R6 STM32L152V8 STM32L152C8 STM32L152R8 STM32L152VB STM32L152CB STM32L152RB LQFP BGA available pin ball ESEJ Q ka d G8 101 G
47. 2L162ZE Number Number Number Number LQFP of LQFP WLCSP of BGA of of pin available Pin ball available ball available i available pins pins pins pins Gx_lOy G10 101 PC6 37 3 63 at 3 E12 3 channels 4 channels E11 channels channels G10 l02 PC 38 with G1 with En with with Group 10 4 4 sampling sampling sampling sampling G10 104 PC9 40 6o Fa capacitor D12 capacitor capacitor PF PF PF G11 IO1 G11 102 Group 11 G11 103 4 EMEN Cannot G4 channels channels be used with pe a for 4 touch G11_105 PF10 EN capacitor capacitor Maximum number of 23 channels with 10 23 channels with 10 33 channels with 11 34 channels with 11 channels sampling capacitors 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 Oo N NMEM 2 Notall 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 909 LINN JOALIP YONOLIWLS GZL 36 y NIY LOcvcOdl9 0d Table 38 Available touch sensing channels for STM32L1xx 384K Subfamily STM32L1xx 384K LQFP64 WLCSP64 LAFP100 UFBGA132 LOFP144 STM32L151RD STM32L151VD STM32L151QD STM32L151ZD Part numbers STM32L152RD STM32L152VD STM32L152QD STM32L152ZD STM32L162RD STM32L162VD STM32L162QD STM32L
48. 2fOxx h Functions used by the application layer and that are device dependent e SL acq BankConfig e SL acq BanksStartAcq e SL acq BankWaitEOC e SL acq GetMeas The other functions in this file are for internal use and the user doesn t need to call them directly Timings The STM32F0xx devices timing management is done in the files e tsl time stm32f0xx c e tsl time stm32fOxx h The systick is used to generate a timebase for the ECS and DTO modules Functions used e TSL tim Init Parameters The parameters specific to the STM32F0xx devices are described in the file e tsl conf stm32f0xx h and are checked in the file e tsl check config stm32f0xx h Memory footprint Conditions e IAR ANSI C C Compiler V6 40 1 for ARM e Compiler options optimization high balanced e AR library not counted e SIMTouch driver default options ECS ON DIO ON ZONE OFF DXS ON excepted if only one sensor is used e Each sensor has its own parameters all parameters placed in RAM The following tables summarize the memory footprint with different configurations DoclD024201 Rev 4 13 125 STMTouch driver UM1606 2 21 5 2 21 6 Note 1 Note2 74 125 Table 19 STM32F0xx memory footprint without proximity ROM RAM Channels Kbytes bytes 9 TKeys 1 Linear 3ch verf 350 1 Rotary 3ch The content of this table is provided for information purposes only Table 20 STM32F0xx memory footprint wi
49. 3 STM32L1xx_ Mp memory footprint without pormi Channels Ks Papal 10 TKeys 1 Linear 3ch 8 1 Rotary 3ch See Section 3 1 1 Toolchain compiler preprocessor section for definition of STM32L1xx_MD 2 The content of this table is provided for information purposes only Table 34 STM32L1xx MD memory footprint with proximity ROM RAM Channels Kbytes bytes 10 TKeys 1 Linear 3ch 10 4 730 1 Rotary 3ch See Section 3 1 1 Toolchain compiler preprocessor section for definition of STM32L1xx_MD 2 The content of this table is provided for information purposes only y 92 125 DoclD024201 Rev 4 UM1606 2 23 5 2 23 6 Note1 Note2 STMTouch driver MCU resources The tables below show the peripherals that are used by the STMTouch driver on STM32L1xx devices Care must be taken when using them to avoid any unwanted behavior Table 35 MCU resources used on STM32L1xx with hardware acquisition GPIOs Acquisition 000 Systick Time base ccc eee ECS and DTO Table 36 MCU resources used on STM32L1xx with software acquisition Systick Time base for ECS and DTO STM32L1xx available touch sensing channels The tables below provide an overview of the available touch sensing channels for the STM32L1xx devices The following tables are not restrictive in term of part numbers supported by the STMTouch driver The STMTouch driver can be used on any new device that may become available as part
50. 4 2 2 ING 5 channels with 1 sampling capacitor 1 channel with 1 sampling capacitor EC channels with 1 sampling capacitor channel with 1 sampling capacitor channels with 1 sampling capacitor channels with 1 sampling capacitor ES Table 37 Available touch sensing channels for STM32L1xx 512K continued N Subfamily STM32L1xx 512K LQFP64 LQFP100 WLCSP104 UFBGA132 LQFP144 STM32L151RE STM32L151VE STM32L151QE STM32L151ZE Part numbers STM32L152RE STM32L152VE STM32L152QE STM32L152ZE STM32L162RE STM32L162VE STM32L162QE STM32L162ZE Number Number Number Number Gx 10 LQFP of LQFP WLCSP of of of y pin available Pin ball available available available pins pins pins G7 102 PB13 34 K12 3 3 4 g G7 103 PB14 35 channels channels channels channels Q ith ith ith O Group7 G7 l04 PB15 36 4 p 5 2 p a S G7_105 PG20 o G10 mpira sampling capacitor capacitor capacitor 3 3 3 channels with 1 sampling capacitor 3 channels with 1 sampling capacitor JOALIP YONOLWLS 909LINN 3 y NIY LOCcvcoOdI od O GCL L6 Table 37 Available touch sensing channels for STM32L1xx 512K continued Subfamily STM32L1xx 512K Packages LQFP64 LQFP100 WLCSP104 UFBGA132 LQFP144 STM32L151QE STM32L151ZE STM32L152QE STM32L152ZE STM32L151RE STM32L151VE STM32L152RE STM32L152VE Part numbers STM32L162RE STM32L162VE STM32L162QE STM3
51. 48 LQFP64 LQFP80 LQFP48 STM8L151C 468 UT STM8L152C 468 UT 48 pins STM8L151R 68 T STM8L152R 68 T STM8L151K3U a Part numbers STM8L151K 46 UT STM8L162R8T STM8L151C3T 64 pins STM8L151M8T STM8L152M8T STM8L162M8T 80 pins Number Number Number Gx IO of of of ay available available available pins pins G1 101 G1 102 G1 103 G1 104 G2 101 G2 102 G2 103 G2 104 PA6 PA PA PA PC PC PC3 PE7 2 channels with 2 channels with 3 channels with 1 sampling 1 sampling 1 sampling capacitor capacitor capacitor c1 1 channel with 2 channels with 3 channels with N 1 sampling 1 sampling 1 sampling capacitor 42 capacitor capacitor NO NONI GREC CUE CES MG CORA SC MEME LIES JOALIP YONOLWLS 909LINN Table 13 Available touch sensing channels for STM8L15x STM8L16x table 2 2 continued 4 STM8L151C medium medium high density l STM8L151R M Subfamily STM8L151K STM8L151C low density STM8L152C R M STM8L162R M UFQFPN32 LQFP32 UFQFPN48 LQFP48 LQFP64 LQFP80 LQFP48 STM8L151C 468 UT STM8L152C 468 UT 48 pins STM8L151R 68 T STM8L152R 68 T STM8L162R8T STM8L151C3T 64 pins STM8L151K3U Parn numbers STM8L151K 46 UT STM8L151M8T STM8L152M8T STM8L162M8T 80 pins Number Number Number y NIY LOCcvcodIi od BI Pin Pin Pin 9f i DI available available available pins pins Gx_lOy G3 101 Group 3 G3 102
52. 8 2 Resources 25 2 8 3 PAM AAA IIIA eee ein 25 2 8 4 Usage example 25 2 9 Touchkey sensor 26 2 9 1 Hilie CA AP EN PA HR 26 2 9 2 Resources 26 2 9 3 Parameters sawaan AAA ae be Bo ew nee HAHAA 27 2 9 4 Usage example 27 2 10 Linearandrotarysensors 28 210 1 PA ad IIIA WA Pano hoes 28 2 10 2 Numberofchannels 28 2 10 3 Deltacoefficienttable 28 2 10 4 Electrodes placement 29 2 10 95 RESOURCES x cage neue BINA ERE SR quede Picea Sep dud I qnie ee KA 32 2 10 6 Parameters 32 2 10 7 Usage example 52e bw 9S X NGABA RU RUE bags esos vs 32 2 11 Main state machine 34 2 12 Sensorsstatemachine 36 2 12 1 Overview 36 2 12 2 States constant table 37 2 12 3 Statesdetail 40 2 12 4 Calibration state 42 2 129 RELEASE Sle Sosa Ehe E REPRE coed oe eee ee Fob os SE AD een Ss 42 2 12 6 Proxim
53. 8 IO2 PC1 G8 103 G8 104 G9 101 PC4 G9 102 G10 101 G10 102 3 channels with E11 3 channels with 1 sampling 1 sampling G10_I03 PC8 capacitor capacitor G10_104 PC9 12 96 D12 Maximum number of 13 channels with 7 20 19 channels with 10 20 channels with 10 channels sampling capacitors sampling capacitors sampling capacitors 3 2 channels with 3 channels with 1 sampling 4 1 sampling capacitor capacitor Group 8 Group 10 1 channel with 1 channel with 1 sampling 1 sampling capacitor capacitor Group 9 Ix JOALIP YONOLWLS 909LINN STMTouch driver UM1606 2 23 7 112 125 Hardware implementation example Figure 21 shows an example of hardware implementation on STM32L 1xx devices Recommendations to increase the noise immunity on the PCB To ensure a correct operation in noisy environment the floating nets must be avoided tracks copper elements conductive frames etc As a consequence e All unused touch controller l Os must be either configured to output push pull low or externally tied to GND e The parameter TSLPRM IODEF should also be configured to the output push pull low state e We recommend to drive the sampling capacitor common node using a standard I O of the touch controller configured in output push pull low mode e t may also be required to add a capacitor input filter pi filter on each channel line y DoclD024201 Rev 4 Figure 21 STM32L1xx hardware
54. A A CER p IA 49 lod UA Mr 49 NA ou a cue rur AI IA IAA AI AAA 49 Mia PA IIIA WA Ua AA WA Kaa 49 2410 2 USU IAA WAIUA s 49 216 3 Parameters 49 2 16 4 Usage 50 Timingmanagement 50 ZANE PODIO AA IAA PG AI AA AA S 50 21 2 IROSOURCES in KAA AKAA 50 2 17 3 Parameters o0 Ze Usage AIKA UH EROS eR SR E Dein cd oro o0 Parameters 51 STM8L1xx devices 51 2 19 1 Acquisition 2 22 4 220c0c60 40 065060446444 ALPA See eed beds 51 2194 TIMINGS ETT 52 2 19 3 Parameters 52 2 19 4 Memory footprint 53 2 19 5 MCU resources 54 2 19 6 STM8L available touch sensing channels 54 2 19 7 Hardware implementation example 62 DoclD024201 Rev 4 Ly UM1606 Contents 2 20 SIiM8lLbrkdevices 64 220 1 PCQUISWION iii KULE RENE 64 220 2 TIMINGS IIIA oe eque v vetere man eee b ee bo ee 64 2 20 3 Parameters 64 2 20 4 Memory footprint 65 2 20 5 Acquisition timings
55. ALIP YONOLIWLS ScL 90L y NIY LOCcvcodI od KAB 2 je je Oo O RIO Table 40 Available touch sensing channels for STM32L1xx 256K table 2 2 continued Subfamily STM32L1xx 256K LQFP100 UFBGA100 UFBGA132 LQFP144 STM32L151VC STM32L151QC STM32L151ZC STM32L152VC STM32L152QC STM32L152ZC STM32L162VC STM32L162QC STM32L162ZC Number BOA ol purs 1 e ball available K5 1 channel with 3 channels with 3 channels with 1 sampling 1 sampling 1 sampling capacitor capacitor capacitor Part numbers LQFP in Analog Gx IOy I O group G9 I01 G9 102 Group 9 G9 103 G9 104 p PC4 3 PC5 PF13 PF14 PC6 G10 102 PC7 PC PC G11 lO1 PF G11 lO2 PF7 Group11 G11 IO3 PF8 G11 lO4 PF9 G11105 PF10 23 channels with 10 33 channels with 11 34 channels with 11 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 r 3 channels with 3 channels with 3 channels with 1 sampling 1 sampling 1 sampling capacitor capacitor capacitor Group 10 Cannot be used 3 channels with 4 channels with for 1 sampling 1 sampling touch sensing capacitor capacitor D Oo O OO DO mm m m NIOJ gt N 2 Not all the pins are available simultaneously on this group a 3 This GPIO can only be configured as sampling capacitor I O when using HW acquisition mode and as channel I
56. C20 Rotary touch sensor XSR 0603 J9AlUp YONOLWLS 47nF COG 1206 m y iH 15nF_COG_1206 a 47nF COG 1206 Q 3 Far 15nF COG 1206 Co oo iH 15nF COG 1206 Q pan 15nF COG 1206 Fa IH i4 IH 13106 ROUSSET Cedex Date 01 MAY 2012 Sheet 1 of 1 FRANCE 1 2 3 4 STMicroelectronics Title STM32L CT Ref Bre Design Microcontrollers Division OUT HN ae WAN WA E A PA AA AA WA WAA AN OT Size A4 Reference Revision C 00 190 avenue C lestin COQ 909LINN Getting started UM1606 3 3 1 3 1 1 Note 114 125 Getting started Create your application Start with an example present in the STMTouch library of the device you intend to use Take an example that is close in term of number of channels sensors with your target application Copy and paste the example in the same parent folder and rename it according your target application Then modify the files as described below The following sections describe the necessary steps to create a new application project Toolchain compiler preprocessor section The device that you intend to use must be written in the toolchain compiler preprocessor section of your project These defines are the same as those for the standard peripherals library Please see the stm lt xxx gt h map file to have the list of the devices definition The hardware acquisition mode is selected per default for the STM8L15x Low density d
57. Copy mcu tsl conf CT TOADAPT h or lt mcu gt _tsl_ conf RC TOADAPT h in your project and rename it in mcu tsl conf h e Include mcu tsl api h in main h STMTouch Library e All files are prefixed with tsl or tsl There is no more stm8 nor stm32 prefix e Copy tsl conf mcu h TOADAPT in your project and rename it in ts conf mcu h e Include tsl h in tsl user h Channels banks and sensors configuration Previous Library e Donein stm8 tsl conf h e Limited number of channels banks and sensors e SCKeys single channel keys and MCKeys multi channels keys sensors STMTouch library e Done in the application tsl user c and tsl user h e No limitation in the number of Cchannels banks and sensors e Touchkey and LinRot sensors with extended and basic types Parameters configuration Previous library e Donein stm8 tsl conf h e No common prefix for the parameters e Thresholds are on 7 bits signed e No thresholds for proximity e Fixed calibration samples e Debounce counters common to all sensors and states e Fixed timer tick frequency DoclD024201 Rev 4 Ly UM1606 3 4 4 3 Getting started STMTouch Library e Doneintsl conf smcu h e All parameters are prefixed with TSLPRM_ e Thresholds are on 8 bits unsigned and multiplier coefficient can be applied on them e Thresholds for proximity e Programmable calibration samples and delay e Debounce counters di
58. D tick TSL STATUS OK ToggleLED Parameters All the parameters are described in the tsl conf mcu h file 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 e tsl check config h All device specific parameters are verified in the tsl check config lt mcu gt h file STM8L1xx devices Acquisition The STM8L1xx devices hardware acquisition mode using two timers is done in the files e tsl acq stm8l hw c e tsl acq stm8l hw h DoclD024201 Rev 4 91 125 STMTouch driver UM1606 Note 2 19 2 2 19 3 52 125 Warning This acquisition mode is available for the STM8L15x Low density devices only The STM8L1xx devices software acquisition mode is done in the files e tsl acq stm8l sw c e tsl acq stm8l sw h This acquisition is available for all STM8L 1xx devices The hardware acquisition mode is selected per default for the S TM8L 15x Low density and devices If you want to use the software acquisition mode you must add the following constant in the toolchain compiler preprocessor e TSLPRM STM8L1XX SW ACQ Functions used by th
59. D024201 Rev 4 Table 27 Available touch sensing channels for STM32F30x 3 Subfamily STM32F30x LQFP32 LQFP48 LaFP64 LAFP100 STM32F301K 468 STM32F301C 468 STM32F301R 468 STM32F302K 468 STM32F302C 468BC STM32F302R 468BC STM32F302V BC STM32F303K 468 STM32F303C 468BC STM32F303R 468BC STM32F303V BC STM32F333K 468 STM32F333C 468 STM32F333R 468 Part numbers Number of Analog l I O group SX available availabl available e pins G1 103 PA2 G1 lO4 10 G2 101 PA4 11 N amp 3 channels with 3 channels with 3 channels with 3 channels with 1 sampling capacitor 1 sampling capacitor 1 sampling capacitor 1 sampling capacitor Group 1 1 G2 102 PAS 12 3 channels with 3 channels with 3 channels with 3 channels with 1 sampling capacitor 1 sampling capacitor 1 sampling capacitor 1 sampling capacitor y NIY LOCcvcodIi od Group 2 G2 103 PA6 G2 lO4 14 G3 IO1 PC5 G3 102 19 Cannot be used for 2 channels with 3 channels with 3 channels with G3 103 touch sensing 1 sampling capacitor 1 sampling capacitor 1 sampling capacitor G3 104 PB2 G4 101 19 G4 102 20 G4 103 23 G4 104 24 Group 3 3 channels with 3 channels with 3 channels with 3 channels with Group 4 i 1 sampling capacitor 1 sampling capacitor 1 sampling capacitor 1 sampling capacitor GC L E8 909LINN JOALIP YINOLWIS Sc LV y NIY LOcvcodiod Table 27 Available touch sensing channels for STM32F30x continu
60. 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 amp MyObjGroup1 TSL obj GroupProcess amp MyObjGroup2 TSL dxs FirstObj amp MyObjGroup1 TSL dxs FirstObj amp MyObjGroup2 Detection Time Out DTO 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 DoclD024201 Rev 4 Ly UM1606 2 15 2 Note 2 15 3 2 15 4 2 16 2 16 1 2 16 2 2 16 3 STMTouch driver Resources The DTO functions are provided in the files e tsl touchkey c e tsl touchkey h e tsl linrot c e tsl linrot h The functions used by the DTO are e SL tkey DTOGetTime e TSL linrot DTOGetTime e SL tim CheckDelay sec The user doesn t need to
61. Data gt StateId TSL STATEID DETECT Accessing a specific state It is possible to enter directly in the calibration OFF and burst only states The burst only state consists in only bursting the electrode without performing acquisition on it It can be used in specific cases to improve the robustness against noise This feature is not available for STM8TL 5x devices DoclD024201 Rev 4 43 125 STMTouch driver UM1606 2 13 2 13 1 2 13 2 44 125 This is done by using the following functions For touchkey sensor e SL tkey SetStateCalibration e SL tkey SetStateOff e SL tkey SetStateBurstOnly For linear and rotary sensor e TSL linrot SetStateCalibration e TSL linrot SetStateOff e SL linrot SetStateBurstOnly Environment Change System ECS 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 Kx X n 1 K x Y n 1 with Y reference X 7 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
62. ELEASE MSv31737V1 States constant table Each state ID is associated to a mask and a function The association STATE ID mask function is made in the user application code using a constant table of the TSL State T type The name of this table is free and user can give any name he wants If no function is needed simply put a zero instead of the function name Here below an example of touchkey sensors state machine Touchkeys state machine const TSL State T MyTKeys StateMachine ID MASK FUNCTION eae ee eS cities Calibration states 0 TSL STATEMASK CALIB TSL tkey CalibrationStateProcess 1 TSL STATEMASK DEB CALIB TSL tkey DebCalibrationStateProcess RELEASE states 2 1 TSL STATEMASK RELEASE TSL tkey ReleaseStateProcess tif TSLPRM USE PROX gt 0 DoclD024201 Rev 4 37 125 STMTouch driver 38 125 3 TSL STATEMASK DEB RELEASE PROX TSL tkey DebReleaseProxStateProcess j else 3 TSL STATEMASK DEB RELEASE PROX endif 4 TSL STATEMASK DEB RELEASE DETECT TSL tkey DebReleaseDetectStateProcess 5 TSL STATEMASK DEB RELEASE TOUCH TSL tkey DebReleaseTouchStateProcess j tif TSLPRM USE PROX gt 0 Proximity states 1 TSL STATEMASK PROX 7 f TSL STATEMASK DEB PROX IE 8 TSL_STATEMASK_DEB_PROX_DETECT TSL tkey DebProxDetectStateProcess 9 TSL STATEMASK DEB PROX TOUCH TSL tkey DebProxTouchStateProcess
63. I IfCOG 100 n PEB uen in z ciim R6 14 31 PC6 PAO mt PB1 TIM2 CH1 CMP1 CH2 PC6 TOES V 9 10 TG uo 15 30 PCS OR 1 0603 Dp i PA3 PB2 TIMI CH2 CMP2 CHI pcs ahs i R16 PD2 E 16 29 PC4 PAA ee PB3 TIMI TRIG CMP2 CH2 PC4 USART CK CCO ui s TE NG o 19 20 E PB4 17 PBA SPI NSS PC3 USART Tx LEO ale Ee E PAG 0 Position 2 93 94 ks PBS 18 PBs sPI SCK PC2 USART RX PC EDU De E PD2 SE Tm gt PB6 19 pB6 SPI_MOSI geo o Sa EDS 29 30 2 RN 5 2 PB7 20 PB7 SPI MISO PCO DCsDA 3 PCO 33 34 B A 25 20 Ul Header 18X2 on the left PD1 R10 STM8L103K ROTI OR 196 0603 WHEEL ELECTRODE KI 1 R12 PB2 K2 EE 10K_1 0603 OR 196 0603 1 R13 R14 PB3 K3 10K 190 0603 OR 196 0603 1 R15 RS PD3 10K 196 0603 OR 1 0603 DOCCT Title STM8L101K TS1 Daughter Board SC DH i 190 avenue C lestin COQ Size A4 Reference MB782 Revision A 00 13106 ROUSSET Cedex CN3 FRANCE Header 6 Date 11 Sep 09 Sheet 1 of 1 1 2 3 4 JOALIP YONOLWLS 909LINN STMTouch driver UM1606 2 20 2 20 1 2 20 2 2 20 3 64 125 STM8TL5x devices Acquisition The STM8TL5x devices acquisition is done in the files e tsl acq stmeatl5x c e tsl acq stmeatl5x h Functions used by the application layer and that are device dependent e SL acq BankConfig e SL acq BanksStartAcq e SL acq BankWaitEOC e SL acq GetMeas The other functions in this file are for internal use and the user doesn t need t
64. O O UIJ CO Wl wi hh N NIN N Nf a o N oO aoao AJO JOALIP YONOLWLS 909LINN Table 40 Available touch sensing channels for STM32L1xx 256K table 2 2 continued Subfamily STM32L1xx 256K LQFP100 UFBGA100 UFBGA132 LOFP144 STM32L151VC STM32L151QC STM32L151ZC STM32L152VC STM32L152QC STM32L152ZC STM32L162VC STM32L162QC STM32L162ZC 3 Part numbers Number Number Analog 909LINN y NIY LOCcvcodIo od GCL LOL I O group Group 5 Group 7 O M O c Lo CO Number of Gx IOy pz Adi BORA d available pag pin ball available ins available pins P G5 101 PA13 G5 102 G5 103 G6 101 G6 102 G6 103 G6_104 G7_101 G7 102 G7 103 G7_104 G7_105 G7 106 G7 107 G8 101 G8 102 G8 103 G8 104 PA14 PA15 PB4 PB5 PB6 PB7 PB12 PB13 PB14 PB15 PG20 PG3 9 PG40 PCO PC1 PC2 PC3 Co 77 A9 01 O O CO Oi oO Mm D N gt QI A aa NIO Axel TI AAA La wlio 2 channels with 1 sampling capacitor 3 channels with 1 sampling capacitor 3 channels with 1 sampling capacitor 3 channels with 1 sampling capacitor 2 channels with 1 sampling capacitor 3 channels with 1 sampling capacitor 4 channels with 1 sampling capacitor 3 channels with 1 sampling capacitor 2 channels with 1 sampling capacitor 3 channels with 1 sampling capacitor 4 channels with 1 sampling capacitor 3 channels with 1 sampling capacitor JO
65. O DC SDA PXS RX5a r57 SWIM connector SPI MOS 6 PA4 SPL MOSUDC SCL PXS RX6a gt SG HG Si 11 PXS_RX7a 7 gt 51 PA6 PXS_TRIG PXS RX8a 57 Sensor VDD VDD gt lt PA7 PXS RFIN PXS RX9a 14 K11 K12 K13 K14 PXS RX0b VDD PXS RXIb DG m lt i E LGE pC 3 9 VDDIO PXS_RX2b 7 PXS VREG PXS RX3b 22 Sensor Lb PXS RX4b 55 C2 C3 C4 C5 KA aig K16 K17 K18 K19 100nF_X7R 100nF_X7R luF X5R nF nk ub E PXS RX7b A 1 b4 2 1 NG 2 1 NG 2 1 NG 2 NG VSS PXS_RX8b I3 VSSIO PXS RX9b Sensor TAN HO KERR RRR R RRS K21 K22 K23 K24 ESCAS EISE ENE NNMAN 1 2 1 2 1 2 1 2 WAWA WAWA WAWA WAKA WAWA WAWA WANAWA bai b 4 gt 4 bi bai PG pA PG pA p PAPA 0X PG NG PG pA GG PG Bee eee sacs m oead daa RAGARARA ensor ensor ensor ensor ensor AAALAAAA ALALA F N sss ss SF ai titit STM8TL53C4U6 KEY Coll KEY Col2 KEY Col3 KEY Col4 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 Title STM8TL53 Reference Schematic POIROT 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 J9AUp YONOLWLS 909LINN UM1606 2 21 2 21 1 2 21 2 2 21 3 2 21 4 STMTouch driver STM32F0xx devices Acquisition The STM32F0xx devices acquisition is done in the files e tsl acq stm32f0xx c e tsl acq stm3
66. O when using SW acquisition mode JOALIP YONOLWLS 909LINN GZL 60L y NIY LOCcvcodI od Table 41 Available touch sensing channels for STM32L15x 32K to 128K Subfamily LQFP48 VFQFPN48 LQFP64 BGA64 LQFP100 BGA100 STM32L151C6 STM32L151C8 STM32L151CB Part numbers STM32L152C6 STM32L152C8 STM32L152CB Gx_lOy G1 IO G1 IO G1 IO G1 IO G2 IO Zu 2 1 sampling capacitor Group 1 O 1 channel with 1 sampling capacitor Group 2 G2 IO NO 1 channel with 1 sampling capacitor DJ G3 IO G4 o1 TG G4 lo2 PA9 130 G4 103 PA10 G5 101 PA13 Group 3 CO amp NO 1 sampling capacitor Group 4 U De ey Wiel a C2 1 sampling capacitor Number of LQFP BGA available pin ball pins 3 channels with 2 channels with 2 channels with STM32L 15x 32K to 128K STM32L151R6 STM32L151R8 STM32L151RB STM32L152R6 STM32L152R8 STM32L152RB 3 channels with 1 sampling capacitor 1 channel with 1 sampling capacitor 1 channel with 1 sampling capacitor 2 2 channels with 1 sampling capacitor C2 2 channels with 1 sampling capacitor oO Number Number of LQFP BGA of available pin ball available pins pins STM32L151V8 STM32L151VB STM32L152V8 STM32L152VB KIKA e ou 3 channels with 1 sampling capacitor 1 channel with 1 sampling capacitor 1 channel with 1 sampling capacitor
67. O3 G1 lO4 G2 101 G2 102 PC4 Group 2 G2 103 PC3 G2 104 PE7 G3 _ 101 PC2 Group 3 G3 102 PD7 G3_103 G4 101 PD5 Group 4 G4 102 PD4 G4 103 PB7 Table 12 Available touch sensing channels for STM8L15x STM8L16x table 1 2 Subfamily STM8L151F STM8L151G STM8L151K Packages UFQFPN20 TSSOP20 UFQFPN28 WLCSP28 UFQFPN32 LQFP32 STM8L151F 23 U STM8L151G 346 U UFQFPN UFQFPN Part numbers STM8L152K 46 UT STM8L151F 23 P TSSOP STM8L151G 46 Y WLCSP Number Number Number of of of available available available pins Analog Gx IOy I O group PA6 PAS PA4 PA7 PC7 1 channel with 2 channels with 1 sampling 1 sampling capacitor capacitor cannot be used 5 p4 alas EXC touch sensing cannot be used 1 channel with 1 channel with for 2 1 sampling 1 sampling touch sensing capacitor capacitor S JA N cannot be used 2 channels with for 1 sampling touch sensing capacitor cannot be used fort touch sensing ERES cannot be used ERES touch sensing 1 channel with 2 channels with 1 sampling 1 sampling capacitor capacitor N N JOALIP YONOLWLS 909LINN y ed LOZtzodI og IKI GCL LS G6 _101 Group 6 G6 102 PB2 G6 103 PB1 G7 101 PBO G7 102 PD3 Group 7 G7 103 PD2 G7 104 PE3 G8 101 PD1 G8 102 Group 8 G8 103 PE5 G8 104 PE4 Table 12 Available touch sensing channels for STM8L15x STM8L16x table 1 2 continued Subfam
68. Parameters 90 2 23 4 Memory footprint 91 2 23 5 MCU resources 93 2 23 6 STM32L1xx available touch sensing channels 93 2 23 7 Hardware implementation example 112 GeO start d HAAA AA AA PAA 114 3 1 Create your application 114 3 1 1 Toolchain compiler preprocessor section 114 DoclD024201 Rev 4 5 125 Contents 6 125 UM1606 3 1 2 The tsl_conf file 114 3 1 3 The main file 114 3 1 4 IAEISL USEr NG cnc cae aeai aa eee NAG aar seed A GAD E 114 3 2 Debug with STM Studio 116 3 3 Low power Strategy 117 3 4 Main differences with previous library 118 3 4 1 m 118 3 4 2 Channels banks and sensors configuration 118 3 4 3 Parameters configuration 118 3 4 4 SAIS ii Gwe Eph oe wean Hates GAAN een e APs wo 119 3 4 5 Variables monitoring 120 3 5 IDS ANG WICKS iii ea O BG nw Gm ee ea Pew S eae dee SN dx 123 3 5 1 BANK GSININON acu ee eGo ed be ee ood II 123 3 5 2 Channel assignment
69. R ERROR ERROR ERROR ERROR ERROR ERROR deb ERROR deb ERROR RELEASE Or ERROR deb ERROR Or ERROR same same JOALIP YONOLWLS 909LINN y NIY LOCcvcodIi od GCL LV Table 5 Detailed sensors states 2 2 2 2p 6 10 Previous state 10p 8 2p 6 7 10p 12 12p E E M deb DETECT deb DETECT deb CALIB ERROR with PROX Delta deb same same DETECT Br or or en DETECT DETECT DETECT IN Th DTO DTO DETECT DETECT TOUCH TOUCH DTO DETECT TOUCH deb PROX PROX or RELEASE IE ma deb deb RELEASE deb RELEASE deb deb Current state RELEASE RELEASE RELEASE deb PROX PROX PROX DETECT TOUCH PROX DETECT TOUCH DETECT TOUCH with PROX with PROX PROX DTO a OUT RELEASE PROX DETECT PROX IN Th TOUCH CALIB PROX OUT Th same or CALIB Th RELEASE RELEASE same same or or RELEASE RELEASE RELEASE deb deb RELEASE same same RELEASE RELEASE or or DETECT TOUCH RELEASE RELEASE or or same RELEASE RELEASE ire ACQ LN PROX DETECT DETECT TOUCH TOUCH RELEASE DETECT TOUCH RELEASE RELEASE RELEASE ERROR 909 LINN JOALIP YONOLIWLS STMTouch driver UM1606 2 12 4 2 12 5 2 12 6 2 12 7 42 125 Calibration state It consists in calculating the reference for all the channels of a sensor An average of a certain number of measurements is done The number of measurement samples to use for the calibration is defined by the TSLPRM CALIB SAMPLES parameter
70. Removed Table 42 STM8L1xx acquisition selection Removed Table 43 STM32L1xx acquisition selection 22 Apr 2014 Added note 1 on Pa4 of Table 28 124 125 y DoclD024201 Rev 4 UM1606 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
71. SL TouchKeyMethods T e SL TouchKeyB T e TSL TouchKey T Create the Linear and Rotary touch sensors variables using the structures optional e SL LinRotData T e SL LinRotParam T e TSL State T e SL LinRotMethods T e SL LinRotB T e SL LinRot T Create the generic sensors objects variables using the structures mandatory e SL Object T e SL ObjectGroup T The TSL user Init function contains the initialization of the STMTouch driver Modify this function to take into account your bank array name and object groups names The TSL user Action function contains the main state machine Modify it also if you have several object groups to process or to change the ECS period etc DoclD024201 Rev 4 115 125 Getting started UM1606 3 2 Debug with STM Studio The STM Studio software is very useful to observe variables of the STMTouch driver Thanks to its powerful features you will be able to better understand how the sensors behave and to find the better parameters to apply This section does not intend to explain how to use this tool but give some advice to better understand and debug your application This is a non exhaustive list of the STMTouch driver variables to observe e The channels measure reference and delta These variables are present inside the TSL ChannelData T structure This is useful to adjust the thresholds parameters e The sensors state present in the TSL_TouchKeyData_T and TSL_LinRotData_T structu
72. a BANK 0 NBCHANNELS For STM8TL5x acquisition only BANK 0 MSK CHANNELS BIT MASK TX BANK 0 TX BANK 0 GROUP tif BANK O MSK TX lt 0x8000 a TX pin is used as transmitter BANK 0 MSK CHANNELS else a RX pin is used as transmitter BIT MASK RX BANK 0 TX BANK 0 MSK CHANNELS endif Bank 1 DoclD024201 Rev 4 23 125 STMTouch driver UM1606 2 7 2 7 1 2 1 2 24 125 amp MyChannels Src 4 amp 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 1 BANK 1 MSK TX lt 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 Hj The BANK x NBCHANNELS BANK x MSK CHANNELS BIT x MASK TX etc are defines and are used for readability These values are for STM8TLbx devices acquisition only Example of 3 banks declaration for STM32FOxx devices CONST TSL Bank T MyBanks TSLPRM TOTAL BANKS amp MyChannels Src 0 amp MyChannels Dest 0 MyChannels Data BANK 0 NBCHANNELS BANK 0 MSK CHANNELS BANK 0 MSK GROUPS amp MyChannels Src 1 amp MyChannels Dest 1 MyChannels Data BANK 1 NBCHANNELS BANK 1 MSK CHANNELS BANK 1 MSK GROUPS amp MyChannels Src 2 amp MyChannels Dest 2 MyChannels Data BANK 2 NBCHANNELS BANK 2 MSK CHANNELS BANK 2 MSK GROUPS p Zone Principle A zone
73. a 8RX 9TX matrix 1 Thereceivers 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 y 10 125 DoclD024201 Rev 4 UM1606 STMTouch driver 2 20 8 Hardware implementation example Figure 18 shows an example of hardware implementation on STM8TLbx devices Recommendations to increase the noise immunity on the PCB To ensure a correct operation in noisy environment the floating nets must be avoided tracks copper elements conductive frames etc As a consequence All unused touch controller I Os must be either configured to output push pull low or externally tied to GND The parameters TSLPRM PXS INACTIVE TX and TSLPRM PXS INACTIVE RA should also be configured to the Grounded state DoclD024201 Rev 4 71 125 3 GZL ZL y NIY LOcvcodiod Figure 18 STM8TL5x hardware implementation example 1 2 3 4 VDD CNI Touchkeys vpp gt SWIM 2 SWIM UI GND gt 2 PAO SWIM PXS RKOa RI mK KEY Row pa 3 BK 4 aaa 15 R2 IK KEY Row2 RST PAS NRST PXS RXla 17 R3 IK KEY Row3 a SPINSS 3 pa spy ngs PXS ROGa 1 RE IK KEY Rowd uas TSM 104 01 L SH A 10nF X7R it PA2 SPI SCK PXS RX4a z R5 IK KEY Row5 K6 KI K8 suna PA3 SPI MIS
74. ameters e TSLPRM TOTAL OBJECTS Usage example First all touchkeys linear and rotary touch sensors described after used in the application must be described first as generic sensor or object Example Mix of touchkeys and Linear touch sensors DoclD024201 Rev 4 25 125 STMTouch driver UM1606 2 9 2 9 1 2 9 2 26 125 const TSL Object T MyObjects TSLPRM TOTAL OBJECTS TKeys TSL OBJ TOUCHKEYB TSL ToucHRevB T amp MyTKeys 0 3 TSL OBJ TOUCHKEYB TSL TouchKeyB T amp MyTKeys 1 3 Linear touch sensors TSL_OBJ_LINEARB TSL LinRotB T amp MyLinRots 0 bat These objects must be placed in ROM memory Once this done it is necessary to create at least one group of sensors These groups will be used by the different processing routines ECS DXS etc These groups of objects must placed in RAM Example TSL ObjectGroup T My0bjGroup All MyObjects 3 0 TSL STATE NOT CHANGED Fi Then all the sensors must be initialized and processed This is done in the main function of the application int main void TSL_obj_GroupInit amp MyObjGroup A11 while 1 TSL obj GroupProcess amp MyObjGroup A11 Touchkey sensor 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 Resources All the functions related to this sensor are described in the files e tsl
75. ampling capacitor 35 C1 Q1 CO CI STM32F37x LQFP48 LQFP64 LQFP100 UFBGA100 8264K B 128K C 256K STM32F373R 8BC Number of available pins STM32F373V 8BC wow 3 channels with 69 C12 1 sampling capacitor mw 3 channels with 90 A7 1 sampling capacitor 2 channels with 1 sampling capacitor 3 channels with 1 sampling capacitor 3 channels with 1 sampling capacitor 3 channels with 1 sampling capacitor Number pi BGA Pin available 19A11p YONOLWLS 909LINN 671 18 y NIY LOcvcodiood Subfamily LQFP48 LQFP64 LQFP100 UFBGA100 Flash memory size Group 7 ka r Maximum numbe of channels Table 28 Available touch sensing channels for STM32F37x continued STM32F37x 8 64K B 128K C 256K STM32F373C 8BC STM32F373R 8BC Number Number of of available available pins Cannot be used for Cannot be used for EN touch sensing touch sensing Cannot be used for Cannot be used for touch sensing touch sensing 14 with 6 sampling capacitors 17 with 6 sampling capacitors 1 This GPIO offers a reduced touch sensing sensitivity It is thus recommended to use it as sampling capacitor 1 0 STM32F373V 8BC Number LQFP BGA Pin Pin available 4 3 channels with 1 sampling capacitor 60 H12 4 3 channels with 1 sampling capacitor 24 with 8 sampling capacitors JOALIP YONOLWLS 909LINN STMTouch driver UM1606 2 22 7
76. annels with 2 channels with 1 sampling capacitor 1 sampling capacitor 19A11p uono LIN LS 909LINN 3 y NIY LOCcvcodIo od GCL EOL Table 39 Available touch sensing channels for STM32L1xx 256K table 1 2 continued Subfamily STM32L1xx 256K LQFP48 or UFQFPN48 WLCSP63 LOFP64 WLCSP64 STM32L151RC Part numbers STM32L152CC STM32L151UC STM32L152RC STM32L162RC Number Number Number of WLCSP of LQFP WLCSP of available ball available pin ball available pins pins 2 channels with 2 channels with 1 sampling Capacitor Gx_lOy G5 O1 PA13 Group 5 G5 102 PA1 G5 103 PA15 G6 IO1 PB4 G6 102 PB5 Group 6 G6 103 PB6 G6_104 PB7 G7_101 PB12 G7 102 PB1 G7 103 PB1 Group 7 G7 104 PB15 G7 105 PG2 G7 106 PG3 2 G7 107 PG4 34 2 channels with 1 sampling capacitor I N O Co 1 sampling capacitor gt N 3 channels with 1 sampling 3 channels with 1 sampling capacitor 3 channels with 1 sampling capacitor gt O sal N N N NI N BI HR HR Bl Wy Ww CO Nf OD O N a O co capacitor P Q2 3 channels with 1 sampling capacitor 3 channels with 1 sampling capacitor 7 NO 1 sampling Capacitor Oo 909LINN JOALIP YINOLWIS GZL POL O o c c RE Ss O o lt y NIY LOCcvcodI od 3 Part numbers Group 8 Group 10 Group11 Gx_lOy G8 101 G8 102 G8 103 G8 104
77. ary touch sensor Title STM32F0xx CT Reference Design Size A4 Reference Revision A 00 Date 01 APR 2012 Sheet 1 of 1 ST Microelectronics Microcontrollers Division 190 avenue C lestin COQ 13106 ROUSSET Cedex FRANCE 3 1914p YONOLWLS 909LINN UM1606 2 22 2 22 1 2 22 2 2 22 3 2 22 4 STMTouch driver STM32F3xx devices Acquisition The STM32F3xx devices acquisition is done in the files e tsl acq stm32f3xx c e tsl acq stm32f3xx h Functions used by the application layer and that are device dependent e SL acq BankConfig e SL acq BanksStartAcq e SL acq BankWaitEOC e SL acq GetMeas The other functions in this file are for internal use and the user doesn t need to call them directly Timings The STM32F3xx devices timing management is done in the files e tsl time stm32f3xx c e tsl time stm32f3xx h The systick is used to generate a timebase for the ECS and DTO modules Functions used e TSL tim Init Parameters The parameters specific to the STM32F3xx devices are described in the file e tsl conf stm32f3xx h and are checked in the file e tsl check config stm32f3xx h Memory footprint Conditions e IAR ANSI C C Compiler V6 40 1 for ARM e Compiler options optimization high balanced e AR library not counted e SIMrTouch driver default options ECS ON DTO ON PROX OFF ZONE OFF DXS OFF e Each sensor has its ow
78. between During this delay the CPU can be in low power mode active halt for STM8 or STOP for STM32 This delay can be shortened or even removed between two consecutive acquisitions when the delta becomes greater than a detection threshold proximity or touch The long delay is restored if all the sensors return in RELEASE state Figure 23 Low_power strategy Pre detection Sensor proc Debounce gt 0 No detection Pre detection Delta threshold i Detection reported Long AWU period Short AWU period Active halt period exited by AWU Bank acquisition Sensor processing Full acquisition processing Touch event User application MSv31748V1 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 DoclD024201 Rev 4 117 125 a Getting started UM1606 3 4 3 4 1 3 4 2 3 4 3 118 125 Main differences with previous library This section describes the main differences between the previous touch sensing library named STMxxx_TouchSensing_Lib and this new STMTouch Library named STMxxx_STMTouch_Lib Files Previous Library e Files are prefixed with stm8 tsl or stm32 tsl or lt mcu gt _tsl_ e
79. call these functions to perform the DTO Parameters e TSLPRM DTO 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 Noise filters 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 Resources The filters are defined in the files e tsl filter c e tsl filter h Each filter is described by a function e TSL filt MeasFilter filter on measurement values e TSL filt DeltaFilter filter on delta values Parameters There is no parameter for the filter module DoclD024201 Rev 4 49 125 STMTouch driver UM1606 2 16 4 Note 2 17 2 17 1 2 17 2 2 17 3 2 17 4 50 125 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 O 0 The user can also create its own filter functions Timing management Principle The STMTouch driver needs an interna
80. e application layer and that are device dependent e SL acq BankConfig e SL acq BankStartAcq e SL acq BankWaitEOC e SL acq GetMeas The other functions in this file are for internal use and the user doesn t need to call them directly Timings The STM8L 1xx devices timing management is done in the files e sl time stm8l c e isl time stm8l h The TIM4 is used to generate a timebase for the ECS and DTO modules Warning The auto reload counter is calculated for a Fepy equal to 16 MHz If you use another Fcpu value in your application you must change the ARR value inside the TSL tim Init function Functions used e TSL tim Init Parameters The parameters specific to the STM8L1xx devices are described in the file e ts conf stm8l h and are checked in the file e tsl check config stm8l h y DoclD024201 Rev 4 UM1606 STMTouch driver 2 19 4 Memory footprint Conditions e Cosmic STM8 C compiler 32K version v4 3 6 e Compiler options modslO pxp compact split pp e Cosmic library not counted e SIMrTouch driver default options ECS ON DIO OFF PROX OFF e 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 Table 6 STM8L101 memory footprint with software acquisition ROM RAM Specific Channels Kbytes bytes options ZONE OFF TK ax
81. ecution speed of the application code may not be optimized For many applications the STMTouch driver may be used as is However for applications having tough constraints in terms of code size and or execution speed the STMTouch driver may need to be fine tuned Note Additional information on the STMTouch driver functions variables and parameters can be found in the CHM user manual present in the STMTouch Library installation folder April 2014 DoclD024201 Rev 4 1 125 www st com Contents UM1606 Contents 1 Coding rules and conventions 9 1 1 Glossary 9 1 2 Namingconventions 10 1 3 Sole qq P 10 1 3 1 General 10 1 3 2 Variabletypes 10 1 3 3 Peripheral registerS 10 1 4 Run time checking 10 139 MISRA C 2004 compliance 11 1 5 1 oenerallllBS 122 2124 9 2 3 949 ec Meee dene ohne d oe eso ded wo 11 1 5 2 Compliance matrix 11 2 SIMIOHCR driver 14 2 1 Supported devices and development tools 14 2 1 1 Supported devices
82. ed Subfamily STM32F30x LOFP32 LOFP48 LaFP64 LAFP100 STM32F301K 468 STM32F301C 468 STM32F301R 468 CRM STM32F302K 468 STM32F302C 468BC STM32F302R 468BC STM32F303K 468 STM32F303C 468BC STM32F303R 468BC STM32F333K 468 STM32F333C 468 STM32F333R 468 Analog I O group G5 101 3 PB G5 102 PB PB Number Number N mberot Gx IOy i of i o in available available availabl ae pins e pins p 3 channels with 3 channels with 3 channels with 1 sampling capacitor 1 sampling capacitor 1 sampling capacitor 2 2 Group 5 2 G5 103 G5 04 G6 101 G6 102 G6 103 G6 104 G7 01 G7 102 G7 103 G7 104 G8 101 G8 102 G8 103 G8 104 6 7 9 30 3 channels with 1 sampling capacitor Cannot be used for 3 channels with touch sensing 1 sampling capacitor Group 6 A d Q oo BR wo O Ka Cannot be used for touch sensing Cannot be used for Cannot be used for Group 7 touch sensing touch sensing Cannot be used for Cannot be used for Cannot be used for Group 8 touch sensing touch sensing touch sensing 6 62 KI CT STM32F302V BC STM32F303V BC Number of availabl 3 channels with 1 sampling capacitor 3 channels with 1 sampling capacitor 3 channels with 1 sampling capacitor 3 channels with 1 sampling capacitor ecd ead 12 with 4 sampling capacitors 17 with 6 sampling capacitors 18 with 6 sampling capacitors 24 with 8 sampling capacitors
83. en an application uses both touchkey sensor and linear and rotary sensor it is better to use touchkeys with a 1 channel linear touch sensor In this case the gain in memory size is important as the touchkey sensor state machine is not used Delta coefficient table The delta coefficient table is used to adjust each channel of the linear and rotary sensors Each value is a 16 bit integer The MSB is the integer part the LSB is the real part Examples To apply a factor of 1 10 e MSB equal 0x01 e LSB equal Ox1A 0 10 x 256 25 6 gt rounded to 26 Ox1A To apply a factor 1 00 e MSB equal 0x01 e LSB equal 0x00 To apply a factor 0 90 e MSB equal 0x00 e LSB equal OxE6 0 90 x 256 230 4 gt rounded to 230 OxE6 y DoclD024201 Rev 4 UM1606 2 10 4 STMTouch driver This results in the following delta coefficient table CONST uint16_t MyLinRot0 DeltaCoeff 3 0x011A 0x0100 0x00E6 The number of delta coefficient table is not limited The same delta coefficient table can be shared by several linear and rotary sensors Electrodes placement The placement design of the electrodes can be done in three different manners 1 Mono electrode design The number of electrodes is equivalent to the number of channels This design is used for linear and rotary sensors Abbreviations LIN M1 LIN M2 and ROT M Examples CH1 CH2 CH3 CH1 CH2 CH3 CH4 CH1 CH2 CH3 CH4 CH5 2 Dual electrode design All
84. erals library user manual for more informations MISRA C 2004 compliance 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 e Acompliance matrix has been completed which shows how compliance has been enforced e The whole STMTouch driver source code is compliant with MISRA C 2004 rules e 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 e 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
85. es These positions can be obtain with difficulty if the electrodes are too big or if they are separated by an important space e LIN M2 LIN Hand LIN D the O position is placed between the first and second electrodes The 255 position is placed between the last two electrodes e ROT Mand ROT D the 0 and 255 positions are always placed between the first and the last electrodes The following figures summarizes the different placements of the 0 and 255 positions with 4 channels sensors 3 DoclD024201 Rev 4 UM1606 a STMTouch driver Figure 9 Positions 0 and 255 255 LIN M2 0 255 LIN H LIN D MSv31734V1 The following table summarizes the different linear and rotary sensors electrodes designs supported by the STMTouch driver Table 3 Supported linear and rotary sensors Number of Channels Each supported electrode design is described by 3 fields in the TSL LinRot T or TSL LinRotB T structures e Position offset table e Sector computation parameter e Position correction parameter for linear sensor These 3 fields are defined in the tsl linrot c and tsl linrot h files and follow the naming convention Position offset table TSL POSOFF nCH LIN ROT M1 M2 H D DoclD024201 Rev 4 31 125 STMTouch driver UM1606 2 10 5 2 10 6 2 10 7 Note 32 125 Sector computation parameter TSL SCTCOMP nCH LIN ROT M1 M2 H D Position correction parameter for linear sensor TSL POSCORR nCH LIN M1
86. evices and STM32L1xx excepted Medium density devices If you want to use the software acquisition mode you must add the following constant in the toolchain compiler preprocessor e TSLPRM STM8L1XX SW ACQ e TSLPRM STM32L1XX SW ACQ The tsl conf file The tsl conf mcu h file contains all the STMTouch driver parameters The following edits must be done 1 Change the number of channels banks sensors according your application 2 Change the common parameters thresholds debounce ECS DTO etc 3 Change the parameters specific to the device The main file The main c and main h files contain the application code itself LEDs and LCD management etc and the call to the STMTouch driver initialization and action functions The tsl user file The tsl user c and tsl user h files contain the STMTouch driver configuration definition of channels banks zones sensors etc and the STMTouch driver initialization TSL user Init and action TSL user Action functions Create the channels variables using the structures mandatory e SL ChannelSrc T e SL ChannelDest T e SL ChannelData T Create the Banks variables using the structures mandatory e SL Bank T y DoclD024201 Rev 4 UM1606 3 Getting started Create the Zone variables using the structure optional e SL Zone T Create the touchkeys variables using the structures optional e TSL TouchKeyData T e TSL TouchKeyParam T e TSL State T e T
87. extended sensor Extended TouchKeys Always placed in ROM const TSL TouchKey T MyTKeys TSLPRM TOTAL TKEYS amp MyTKeys Data 0 amp MyTKeys Param 0 amp MyChannels Data 0 MyTKeys StateMachine amp MyTKeys Methods amp MyTKeys Data 1 amp MyTKeys Param 1 amp MyChannels Data 1 MyTKeys StateMachine amp MyTKeys Methods DoclD024201 Rev 4 27 125 STMTouch driver UM1606 2 10 2 10 1 2 10 2 Note 2 10 3 28 125 amp MyTKeys Data 2 amp MyTKeys Param 2 amp MyChannels Data 2 MyTKeys StateMachine amp MyTKeys Methods a Linear and rotary sensors 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 e Number of channels e Delta coefficient table e Position offset table e Sector computation parameter e Position correction parameter for linear sensor The last 3 fields are used to calculate the position Number of channels Only 1 3 4 5 and 6 channels are supported today by the STMTouch driver Additional number of channels can be added by the end user See the Position offset table bullet below for more detail A Linear sensor with 1 channel is equivalent to one touchkey sensor Wh
88. fferent for each sensor and each state e Programmable timer tick frequency Usage Previous Library e Initialization by calling TSL Init function e Execution by calling TSL Action continuously e Main state machine and sensors state machine are in the TS driver layer e ECS and DXS process are called by the TS driver layer e 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 sMCKeylnfo variables if TSL GlobalSetting b CHANGED TSL GlobalSetting b CHANGED 0 if sSCKeyInfo 0 Setting b DETECTED STMTouch library e Initialization by calling TSL obj Grouplnit and TSL Init functions e Execution by calling TSL Action continuously e Main state machine and sensors state machine are in the application layer and so can be changed easily e ECS and DXS process are called by the application layer e The test of the main state machine value is not needed as the main state machine is managed by the application layer e Test of sensor state using Stateld variable if MyTKeys 0 p_Data gt StateId TSL_STATEID_DETECT MyTKeys 0 p Data 5Stateld TSL STATEID DEB RELEASE DETECT DoclD024201 Rev 4 119 125 Gett
89. ily STM8L151F STM8L151G STM8L151K Packages UFQFPN20 TSSOP20 UFQFPN28 WLCSP28 UFQFPN32 LQFP32 STM8L151F 23 U STM8L151G 346 U UFQFPN UFQFPN Part numbers STM8L152K 46 UT STM8L151F 23 P TSSOP STM8L151G 46 Y WLCSP Number Number Number of of of available available available pins pins Analog Gx IOy I O group G5 101 PB6 Group 5 G5 102 PB5 G5 103 PB4 2 channels with 2 channels with 1 sampling 1 sampling capacitor Capacitor mk al aj a alala a la al OIlI gt INIOI RAI OIO diia 2 channels with I 2 channels with 1 sampling 1 sampling 1 sampling capacitor capacitor capacitor 12 cannot be used 2 channels with 2 channels with for 1 sampling 3 1 sampling touch sensing capacitor 11 capacitor cannot be used 1 channel with cannot be used for 1 sampling 1 for touch sensing capacitor H touch sensing 4 channels with 10 channels with 13 channels with Maximum number Maximum number of charnels channels l i 2 sampling capacitors 7 sampling capacitors 7 sampling capacitors The product has an hardware acceleration cell for touch sensing 909 LINN JOALIP YONOLIWLS GZL 3S y NIY LOcvcodiod iy 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 UFQFPN32 LQFP32 UFQFPN48 LQFP
90. imply because s2 is placed first in the group2 Figure 14 DXS example 1 group1 group1 group1 group1 group1 S1 DETECT DETECT DETECT S2 Gas TOUCH TOUCH DETECT S3 time MSv31739V1 Example 2 4 sensors with one share between three groups In this example the group1 is composed of the two sensors s1 and s2 in this order the group2 of the two sensors s2 and s3 in this order and the group3 of the two sensors s2 and s4 in this order The DXS groups are processed in this order group1 first then group2 and finally group3 We can see in the step DXS2 that the sensor 2 takes the priority over the sensors 3 and 4 To summarize the decision to be in DETECT state depends on the sensors placement inside the group and also on the order of the groups processing Figure 15 DXS example 2 group1 group1 MSv31740V1 2 14 2 Resources The DXS functions are provided in the files e tsl dxs c e tsl dxs h The functions to use are e TSL dxs FirstObj DoclD024201 Rev 4 47 125 a STMTouch driver UM1606 2 14 3 2 14 4 2 15 2 15 1 48 125 Parameters e TSLPRM USE DXS Usage example The DXS processing is performed usually in the main state machine but it can also be done in interrupt routines Warning The DXS must be absolutely performed after the sensors state machine is processed that is after the call to the TSL obj GroupProcess function see the main state machine for more details The
91. ing started UM1606 3 4 5 Variables monitoring Many variables can be monitored in order to debug your application The list below is not exhaustive but shows only the most important variables used in both libraries Previous library e The sSCKeylnfo sMCKeylnfo and sAcqBanklnfo structures contain all informations related to touchkey and linear rotary sensors reference last measure thresholds state position EPCC STMTouch library e The array of TSL ChannelData T structure contains the reference measure and delta values of ALL channels used by the application Figure 24 Debug of TSL ChannelData T structure Expression MyChannels Data Value array gt Struct gt Struct gt e414 208 e414 Struct gt Struct gt 2542 245 1 2543 Struct gt Struct gt 25834 46 1 5 Ed Location Dx 0000030 Dx2 0000050 x20000050 0x20000032 0x20000034 0x 0000036 0x20000038 0x20000034 Ix2000003A Dx2000003C Dx 000003E Dx20000040 Dxz20000047 Dxz 0000044 Dxz 0000044 Dx 0000046 Dx 0000045 Dxz 000004A Ix2000004C Type TSl_ChannelData_T 3 TSL Channelbiata T TSL ChannelHags T uintl b t uinta 1 Intl bt uintl bt TSL ChannelData T TSL ChannelHags T uinti e_t uinta t Intl bt uintl 5 t TSL Channelbiata T TSL ChannelHags T uintl 5 t uinta t intl bt uintl ot e The array of TSL_TouchKeyData_T contains mainly the touchkey sensors state 120 125 DoclD024201 Rev 4
92. is 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 2014 STMicroelectronics All rights reserved STMicroelectronics group of companies Australia Belgium Brazil Canada China Czech Republic Finland France Germany Hong Kong India Israel Italy Japan Malaysia Malta Morocco Philippines Singapore Spain Sweden Switzerland United Kingdom United States of America www st com Ly DoclD024201 Rev 4 125 125
93. ith 1 1 1 1 sampling sampling sampling sampling capacitor capacitor capacitor capacitor 3 channel channel channels channels with with with with 1 1 1 1 sampling sampling sampling sampling capacitor capacitor capacitor capacitor Tl m o Tl N NINI gt gt c1 AJ gt o L aE O O 3 JOALIP YONOLWLS 909LINN 3 y NIY LOCcvcodiood LQFP64 WLCSP64 LQFP100 UFBGA132 LQFP144 STM32L151RD STM32L152RD Part numbers Group 10 Group 11 n zn G10 101 G10 102 G10 103 G10 104 G11 101 G11 102 G11 103 G11 104 G11 IO5 PF10 Table 38 Available touch sensing channels for STM32L 1xx 384K continued LQFP IKA JE GE 7 al QN ER STM32L162RD WLCSP ball Number of available pins channels with 1 sampling capacitor STM32L1xx 384K STM32L151VD STM32L152VD STM32L162VD of available pins channels with 1 sampling capacitor Cannot be used for touch sensing Number of available pins STM32L151QD STM32L152QD STM32L162QD channels with 1 sampling capacitor channels with 1 sampling capacitor STM32L151ZD STM32L152ZD STM32L162ZD Number of available pins 3 channels with 1 sampling Capacitor A channels with 1 sampling Capacitor 909 LINN GCL LOL Maximum number of 23 channels with 10 23 channels with 10 33 channels with 11 34 channels with 11 channels sampling capacitors sampling capacitors sampling capaci
94. itors sampling capacitors This GPIO offers a reduced touch sensing sensitivity It is thus recommended to use it as sampling capacitor I O 2 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 909 LINN JOALIP YONOLIWLS S Table 40 Available touch sensing channels for STM32L1xx 256K table 2 2 gt Subfamily STM32L1xx 256K LQFP100 UFBGA100 UFBGA132 LQFP144 STM32L151VC STM32L151QC STM32L151ZC Part numbers STM32L152VC STM32L152QC STM32L152ZC STM32L162VC STM32L162QC STM32L162ZC Number Numberof Number Analog LQFP BGA of of Gx_lOy f available I O group pin available piis available G1 102 PA1 3 channels with 3 channels with Group 1 1 sampling 1 sampling 1 sampling S G1 103 capacitor capacitor capacitor J G1 104 PA3 NO I PAS ZU PAT 3 channels with 3 channels with lt PRIS 1 sampling 1 sampling 1 sampling D gt capacitor capacitor capacitor G2 01 PA6 G2 102 PA7 Group 2 G2 103 PF15 G2 104 PG0B G2 105 PG10 G3 101 PBO G3 102 PB1 Group 3 G3 103 PB2 G3 104 PF11 G3 105 PF12 G4 101 PA8 Group 4 G4 IO2 G4 103 d 2 channels with 4 channels with 4 channels with 1 sampling 1 sampling 1 sampling capacitor capacitor capacitor 2 2 a Al zir o 2 2 channels with 2 channels with 1 sampling 1 sampling 1 sampling capacitor capacitor capacitor ES O PA9 PA10 E N
95. ity state 42 2 12 7 DETECT state 42 2 12 8 TOUCH state 43 212 9 ERRORS Wi II IA doe sagan RS dr cd ca GRE 43 2 12 10 OFF SG 25 26 ia Bee va Qmd meee edad E TU eRe aa 43 2 12 11 Debounce states 43 Ly DoclD024201 Rev 4 3 125 Contents 4 125 2 13 2 14 2 15 2 16 2 17 2 18 2 19 UM1606 2 12 12 Reading the current state 43 2 12 13 Accessing a specific state 43 Environment Change System ECS 44 213 1 PNGP MEET 44 2 13 2 Resources 44 2 13 3 Parameters 45 2 13 4 Usage example 45 Detection Exclusion System DXS 46 2 14 31 JHBUCIDIG IAA GANG BANAAG PAN ridet NATH DAG ose MAKA 46 2 14 2 Resources 47 2 14 3 Parameters 48 2 14 4 Usage example 48 Detection Time Out DTO 48 215 1 Principle IIIA oes eheu on oe ee x 8 reba Be eee ed 48 2 15 2 Resources 49 245 9 PAA IIIA RU KA
96. ive in term of part numbers supported by the STMTouch driver The STMTouch driver can be used on any new device that may become available as part of ST microcontrollers portfolio Please contact your ST representative for support y DoclD024201 Rev 4 UM1606 STMTouch driver Table 18 Available touch sensing channels for STM8TL5x Subfamily STM8TL5x TSSOP20 UFQFPN28 UFQFPN48 STM8TL52F4P STM8TL52G4U Part numbers STM8TL53C4U STM8TL53F4P STM8TL53G4U KIND anng Re 107 paj maa xa Receiver Rwa 5 Receivers 8 Receivers 10 Receivers AC Xa o Transmitters Transmitters Transmitters me Wow O Receivers O Receivers 10 Receivers Transmitters Transmitters Transmitters Ly DoclD024201 Rev 4 69 125 STMTouch driver UM1606 Table 18 Available touch sensing channels for STM8TL5x continued Subfamily STM8TL5x TSSOP20 UFGFPN26 UFGFPNAG STM8TL52F4P STM8TL52G4U Part numbers STM8TL53C4U STM8TL53F4P STM8TL53G4U PXS function function KIA poe ga a Z mla ela e nos arn 25 piod Link STM8TL52G4U Transmitter m po 15 Transmitters STM8TL53G4U Txs Peo kambi WA 9 Transmitters mefe mao Pee mm a mew me me maa Peo STM8TL52F4P 12 channels STM8TL52G4U 25 channels with a 4RX 3TX matrix with a 5RX 5TX matrix Maximum number 300 channels with a 20RX 15TX matrix OE ADNE STM8TL53F4P 25 channels STM8TL53G4U 72 channels with a 5RX 5TX matrix with
97. l 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 Resources The common timing routines are described in the files e tsl time c e tsi 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 e tsl time mcu c e tsl time mcu h Functions e SL tim ProcessIT e TSL tim CheckDelay ms e SL tim CheckDelay sec Parameters e TSLPRM TICK FREQ 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 DoclD024201 Rev 4 Ly UM1606 2 18 Note 2 19 2 19 1 3 STMTouch driver 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 amp time_ECS tick TSL STATUS OK TSL ecs Process amp MyObjGroup Toggle LED every 500 ms if TSL tim CheckDelay ms 500 amp time LE
98. libration The main state machine principle is illustrated by the figure below y DoclD024201 Rev 4 UM1606 STMTouch driver Figure 10 Main state machine Channels banks zones sensors configuration Banks and sensors initialization Bank configuration Bank start acguisition Bank acguisition Bank wait end acquisition Sensors processing bw Bank get result ECS DXS lt MSv31735V1 The main state machine steps are 1 The channels banks zones and sensors configuration step are used to declare all the different elements This is done in the global declaration section in the main application file See the section associated to each element for more details 2 The banks and sensors initialization step is used to initialize the STMTouch driver modules The sensors parameters are initialized with their default value defined in the configuration files 3 The banks acquisition step is used to perform the acquisition of the banks It is composed of 4 sub steps Configuration used to configure all channels of the bank start acquisition used to launch the measurement on all channels of the bank wait end acquisition used to wait the end of acquisition of all channels of the bank get result used to read all the channels measurements and to store them in the channel data layer 4 The sensors processing step is used to execute the state machine of the sensors DoclD024201 Rev 4 35 125 a
99. ling sampling sampling 1 G6 IO2 PB5 57 AS Groupe Sr 2 channels channels with with 1 1 channels with 1 1 1 sampling sampling capacitor capacitor 1 sampling capacitor y NIY LOCcvcodIi od 1 C3 sampling A9 capacitor B4 3 3 3 channels channels C5 channels channels with with KI with B5 1 1 1 sampling sampling sampling capacitor capacitor capacitor sampling capacitor 1 1 sampling C12 capacitor capacitor capacitor capacitor 1 o channels channels channels channels 3 with with 3 with with GCL 66 909 LINN JOALIP YONOLIWLS Table 38 Available touch sensing channels for STM32L1xx 384K continued o Subfamily STM32L1xx 384K C1 LQFP64 WLCSP64 LOFP100 UFBGA132 LOFP144 STM32L151RD STM32L151VD STM32L151QD STM32L151ZD Part numbers STM32L152RD STM32L152VD STM32L152QD STM32L152ZD STM32L162RD STM32L162VD STM32L162QD STM32L162ZD Number Number Number Gx IOy LQFP WLCSP of of of of a pin ball available i available available i available pins pins pins pins G7 103 PB14 channels channels channels Group 7 G7_104 PB15 i wi wi sampling EN sampling sampling G7 105 PG2 G7 106 PG3 9 G7 107 PG4 G8 101 PCO G8 IO2 Pct Group 8 G8 103 PC2 G8 104 PC3 G9 101 PC4 G9 lo2 PC5 Group 9 So 103 PF13 G9 104 PF14 capacitor capacitor capacitor y NIY LOCcvcodI od 3 3 3 channels channels channels channels with with with w
100. measures have been taken Compliance matrix The compliance of the STMTouch driver with MISRA C 2004 has been checked in two Ways e using PC lint tool for C C NT vers 8 00v copyright gimpel software 1985 2006 e performing regular code reviews The following table lists the MISRA C 2004 rules that are frequently violated in the code DoclD024201 Rev 4 11 125 Coding rules and conventions UM1606 Table 2 MISRA C 2004 rules not followed MISRA C 2004 Required Summary Reason of deviance Compilers extensions are enabled rule number advisory Comments starting with I symbol for code 1 1 12 Required readability 54 Required A tag name shall bea_ Due to the usage of l q unique identifier objects methods No prototype seen Functions shall always 8 1 Required 10 1 Required 10 2 have prototype Required All code shall conform to ISO 9899 1990 standard C with no extensions permitted This rule is violated as there is no functions prototypes for the objects methods declarations and the prototype shall be visible at both the function definition The value of an expression of integer floating type shall not be implicitly converted to a different underlying type Code complexity The value of a complex expression of integer type may only be cast to a type that is narrower and of the same signedness as the underlying type of the expression Code complexity If the bitwise
101. modes e Support of STM8L1xx devices Surface charge transfer acquisition principle managed by Two timers routing interface hardware acquisition mode supported only by STM8L15x low density devices GPIOs routing interface software acquisition mode supported by all STM8L devices Up to 6 channels with up to 2 channels acquired simultaneously for the STM8L 101 devices see Table 17 for more details Up to 20 channels with up to 8 channels acquired simultaneously for the STM8L15x 16x devices see Table 12 and Table 13 for more details e STM8TL5x devices using the embedded ProxSense patented acquisition technology Projected ProxSense acquisition principle Up to 300 channels Up to 10 channels can be acquired simultaneously see Table 18 for more details Integrated sampling capacitor Electrode parasitic capacitance compensation EPCC On chip integrated voltage regulator e Support of STM32L1xx devices Surface charge transfer acquisition principle managed by Two timers routing interface hardware acquisition mode This mode is not supported on Medium density devices GPIOS routing interface software acquisition mode This mode is supported by all devices Up to 34 channels Up to 11 channels can be acquired simultaneously see Table 37 Table 38 Table 39 Table 40 and Table 47 for more details e STM32F0xx and STM32F3xx devices using the embedded touch sensing controller IP TSC Surface charge
102. mpling with 1 sampling ping capacitor capacitor sampling capacitor PAS PA PA1 Capacitor 3 channels with 1 sampling Capacitor Cannot be used for touch sensing 1 channel with 1 sampling Capacitor 3 channels with 1 sampling Capacitor 1 channel with 1 sampling Capacitor 1 channel with 1 sampling Capacitor 3 channels with 1 sampling capacitor 1 2 channels with 1 sampling Capacitor 3 channels with 1 sampling Capacitor Capacitor 3 channels with 1 sampling Capacitor 2channels with 1 sampling Capacitor 3 channels with 1 sampling Capacitor 3 channels with 1 sampling capacitor 2 channels with 1 sampling Capacitor 3 channels with 1 sampling Capacitor PA1 PA2 PA3 1 1 PA6 PA7 PBO PB2 PA9 10 1 2 B4 Cannot be 3 channels 3 channels hapaa 3 channels used for with 1 with 1 witha with 1 d a c sampling et ndi ES ES EN Group 3 EN Hg EN E ES Group 5 GCL GL JOALIP YONOLIWLS Sc 1 94 y NIY LOcvcodriod Group 6 touch sensing Table 22 Available touch sensing channels for STM32F042 continued Subfamily Flash memory size Number of availabl Cannotbe used for Cannotbe used for sensing Cannotbe used for n Group 7 not available Touch sensing ps9 Maximum number of channels Cannot be used for Touch sensing Cannot be used for Touch sensing Cannot be used for Touch sensing
103. n loop using the default K coefficients defined in the configuration file TSL ecs Process 4My0bjGroup To call this functions at regular time intervals you can use the provide timing routine TSL tim CheckDelay ms Example with ECS executed every 100ms TSI tTick ms T time ECS tick int main void while 1 ECS every 100 ms if TSL tim CheckDelay ms 100 amp time_ECS tick TSL STATUS OK TSL ecs Process 4My0bjGroup The TSL ecs ProcessK function allows to use a K coefficient different than the default value if TSL tim CheckDelay ms 100 amp time ECS tick TSL STATUS OK if MyObjGroup gt StateMask amp TSL STATE RELEASE BIT MASK amp amp MyObjGroup gt StateMask amp TSL_STATEMASK_ACTIVE TSL ecs ProcessK amp MyObjGroup 120 DoclD024201 Rev 4 45 125 STMTouch driver UM1606 2 14 Detection Exclusion System DXS 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
104. n parameters all parameters placed in RAM The following tables summarize the memory footprint with different configurations DoclD024201 Rev 4 81 125 STMTouch driver UM1606 2 22 5 2 22 6 Note 1 Note2 82 125 Table 24 STM32F30x memory footprint ROM RAM Channels Kbytes bytes 1 The content of this table is provided for information purposes only Table 25 STM32F37x memory footprint ROM RAM Channels Kbytes bytes 1 The content of this table is provided for information purposes only MCU resources The table below shows the peripherals that are used by the STMTouch driver on STM32F3xx devices Care must be taken when using them to avoid any unwanted behavior Table 26 STM32F3xx MCU resources used GPlOSs 7 Acquisition Uo Time base AA ECS and DTO STM32F3xx available touch sensing channels The tables below provide an overview of the available touch sensing channels for the STM32F30x and STM32F37x devices The following tables are not restrictive in term of part numbers supported by the STMTouch driver The STMTouch driver can be used on any new device that may become available as part of ST microcontrollers portfolio Please contact your ST representative for support For n available pins in an I O group one pin is used as sampling capacitor and n 1 pins are used as channels The I O group cannot be used if the number of available pins in less or equal to one y Docl
105. nformations 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 DoclD024201 Rev 4 19 125 STMTouch driver UM1606 2 4 4 Header files inclusion The figure below provides a global view of the STMTouch driver usage and the interaction between the different header files Note To simplify the drawing only the most important links are shown For example the ts globals h file is also included in different files Figure 6 Header files inclusion Application layer STMTouch driver tsl types h 4 ts globals h Standard peripheral lt mcu gt h mapping file library MSv31731V1 2 5 Channel 2 5 1 Principle A channel is the basic element that is used to store several information like e where the source measurement can be found after the acquisition is performed i e RX registers for STM8TL5x devices or TSC IOGxCR registers for STM32F0Oxx STM32F 3xx devices e where are stored the measure the reference the delta flags etc 3
106. ng G7 103 G7 104 P PD PD2 capacitor capacitor capacitor REN 3 JOALIP YONOLWLS 909LINN GZL L9 y NIY LOcvcodiod 3 Table 13 Available touch sensing channels for STM8L 15x STM8L16x table 2 2 continued STM8L151C medium medium high density STM8L151R M Subfamily STM8L151K STM8L151C low density STM8L152C R M STM8L162R M UFQFPN32 LQFP32 UFQFPN48 LQFP48 LQFP64 LQFP80 LQFP48 STM8L151C 468 UT STM8L152C 468 UT 48 pins STM8L151R 68 T STM8L152R 68 T STM8L151K3U a Part numbers STM8L151K 46 UT STM8L162R8T STM8L151C3T 64 pins STM8L151M8T STM8L152M8T STM8L162M8T 80 pins Number Number Number or Pin Pin Pin 9f DI available available available pins pins 3 channels with 1 sampling capacitor KO 1 channel with 2 channels with 1 sampling 3 1 sampling 4 capacitor capacitor 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 JOALIP YONOLWLS 909LINN STMTouch driver UM1606 2 19 7 62 125 Hardware implementation example Figure 16 shows an example of hardware implementation on STM8L 1xx devices Recommendations to increase the noise immunity on the PCB To ensure a correct operation in noisy en
107. 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 DoclD024201 Rev 4 39 125 GZL OV y NIY LOCvcOdl90d 2 12 3 Previous state States detail The two tables below show the detail of how each state is entered following the thresholds measured Table 4 Detailed sensors states 1 2 2p 10p 12p 3 4p 5p 7 8 9 all excepted all excepted 13 13 RELEASE DETECT TOUCH Current state RELEASE i PROX DETECT TOUCH i CALIB with PROX with PROX with PROX Delta 2 2p 6 10 10p 12 12p 0 14 18 ERROR deb DETECT deb DETECT deb DETECT or or or DETECT IN Th DETECT DTO DETECT DTO DETECT DTO DETECT OUT Th PROX IN Th CALIB if DTO CALIB if DTO CALIB if DTO CALIB if DTO deb PROX or PROX DTO same or CALIB if DTO deb PROX TOUCH deb PROX DETECT or or PROX DTO PROX DTO deb RELEASE deb RELEASE DETECT TOUCH PROX OUT Th or or RELEASE RELEASE deb RELEASE deb RELEASE PROX DETECT CALIB Th or or deb RELEASE TOUCH or or or CBO AENG RELEASE RELEASE RELEASE deb CALIB deb ERROR deb ERROR deb ERROR deb ERROR deb ERROR if or or or or or a 4 aan ak bah ERRO
108. o call them directly Timings The STM8TLbx devices timing management is done in the files e tsl time stmeatl5x c e tsl time stmeatl5x h The TIM4 is used to generate a timebase for the ECS and DTO modules Warning The auto reload counter is calculated for a Fepy equal to 16 MHz If you use another Fcpy value in your application you must change the ARR value inside the TSL tim Init function Functions used e SL tim Init e TSL Timer ISR Parameters The parameters specific to the STM8TL5x devices are described in the file e tsl conf stm8tibx h and are checked in the file e tsl check config stmatl5x h DoclD024201 Rev 4 Ly UM1606 2 20 4 3 STMTouch driver Memory footprint Conditions e Cosmic STM8 C compiler 32K version v4 3 6 e Compiler options modslO pxp compact split pp e Cosmic library not counted e SIMrTouch driver default options ECS ON DIO ON ZONE OFF DXS ON excepted if only one sensor is used e Each sensor has its own parameters all parameters placed in RAM The following tables summarize the memory footprint with different configurations Table 14 STM8TL5x memory footprint without proximity ROM RAM Channels Kbytes bytes 16 Seale 1ch 1o Ha 57 The content of this table is provided for information purposes only Table 15 STM8TL5x memory footprint with proximity ROM RAM Channels Kbytes bytes 16 cubilia 1ch 7 1G uj 62 The content
109. of ST microcontrollers portfolio Please contact your ST representative for support For n available pins in an I O group one pin is used as sampling capacitor and n 1 pins are used as channels The I O group cannot be used if the number of available pins in less or equal to one DoclD024201 Rev 4 93 125 KO D gt Table 37 Available touch sensing channels for STM32L1xx 512K o Subfamily STM32L1xx 512K LQFP64 LQFP100 WLCSP104 UFBGA132 LQFP144 STM32L151RE STM32L151VE STM32L151QE STM32L151ZE Part numbers STM32L152RE STM32L152VE STM32L152QE STM32L152ZE STM32L162RE STM32L162VE STM32L162QE STM32L162ZE Number Number Number Number Gx 10 LQFP of LQFP WLCSP of BGA of LQFP of y pin available Pin ball available ball available pin available pins i pins pins G1_101 PAO 14 3 EYE 3 34 3 G1 102 Pat 15 WALI channels channels channels Og Group 1 with with with 3 G1103 Paz 16 C a sampling sampling sampling sampling N G1 104 17 capacitor capacitor capacitor 3 3 ZU 2 channel channels channels A with with with 1 sampling capacitor 1 1 sampling sampling capacitor capacitor G2 101 G2 102 Group 2 G2 103 G2 104 d G2 105 PG1 G3_101 PBO 2 G3 102 LAE Group 3 G3 103 G3 104 G3 105 O N 4 channels with 1 sampling capacitor channels channels with with 1 1 sampling sampling capacitor capacitor 3 J9AlJp YONOLWLS 909LINN 3 y NIY LOTYZOG FOG GCL S6 Subfamily
110. of this table is provided for information purposes only DoclD024201 Rev 4 65 125 STMTouch driver UM1606 2 20 5 Acquisition timings The following figure shows the simplified sequencing for a 2 bank acquisition Figure 17 Simplified acquisition sequencing Hardware acq ECS proc Meas storing Acq init Full proc Sensor proc Run Active halt Active halt Initialization of a bank acquisition Hardware acquisition the CPU can enter in low power mode WFI WFE active halt Measurement storing for each enabled receivers of the bank just acquired Sensor processing can be split in different functions touchkeys linear or rotary sensors Lj ECS processing not performed after each set of acquisitions but executed sequentially after a delay elapsed MSv31741V1 Conditions e Cosmic STM8 C compiler 32K version v4 3 6 e Compiler options modslO pxp split pp e SIMrTouch driver default options ECS ON DTO ON DXS ON excepted if one channel is used e Each sensor has its own parameters all parameters placed in RAM The following table summarizes the timings measured for the different acquisition sequences Table 16 STM8TL5x acquisition timings Conditions Duration Comment us Startup before main my 60000 Compiler dependent 3 touchkeys PIPO Naaawa tate edes T pa 4 1bank ime before the driver is ready to TSL initialization TSE ON OTOU PIME report a touch including the retin 19
111. operators are applied to an operand of underlying type unsigned char or Use shift on signed unsigned short the quantity for the result shall be linear rotary position immediately cast to the underlying type of the operand 10 5 Required A cast should not be performed between a pointer type and an integral type Needed when addressing memory mapped registers 11 3 Advisory Bitwise operators shall not be applied to operands whose underlying type is signed Shift of signed value 12 7 Required needed M O Co y 12 125 DoclD024201 Rev 4 UM1606 Coding rules and conventions Table 2 MISRA C 2004 rules not followed continued MISRA C 2004 Required rule number advisory Before preprocessing a 14 3 Required null statement shall Usage of macros to only occur on a line by simplify the code itself Summary Reason of deviance The continue statement Used to optimize the 14 5 Required l shall not be used code speed execution All macro identifiers in preprocessor directives shall be defined before All parameters are 19 11 Required use except in ifdef and checked in the ifndef preprocessor check config files directives and the defined operator DoclD024201 Rev 4 13 125 UM1606 STMTouch driver 2 2 1 14 125 STMTouch driver Supported devices and development tools Supported devices This STMTouch driver version supports the following devices and acquisition
112. res This is useful to adjust the Debounce ECS and DTO parameters e The linear and rotary touch sensors position in the TSL_LinRotData_T structure The following snapshot is an example of data visualization on STM Studio Figure 22 STM Studio snapshot MA SIM Studio tib2G stm81153 File Run Views Options Help amp Be uN jw vB Display Variables Write Variables Display Variables settings Add Type Color 0x1b8 signe Ox1ba Isigne T Ox1bc lsigne si IL t 0x1be signe bag s7 m ETUUTEUUTUE NAN aaa Variables Expression Type Name Acqvar Function Sc Color DD 12 Min DD 12 Average 10 last BIG Viewers TS Ta 2 General Display al Point Viewer delta Hexadecimal C position as Bar Graph Ko NI D S s OT ae Le ae S a 33 m3 eme KONGY x N state Ho Variables position List of Variables average MyLinRots_Data 0 RawPosition position IMyLinRots Data 1 RawPosition 600 4 500 4 400 4 300 4 200 4 Delete All 100 D Value Range lower Value upper Value Variables 3 116 125 DoclD024201 Rev 4 UM1606 Getting started 3 3 Low power strategy The following figure shows the acquisition sequencing for a single bank acquisition in low power mode To reduce the power consumption the acquisitions are sequenced with a long delay in
113. 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 amp MyLinRots Data 0 amp MyLinRots Param 0 amp 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 amp MyLinRots Data 1 amp MyLinRots Param 1 amp 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 bi 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 amp MyLinRots Data 0 amp MyLinRots Param 0 amp MyChannels Data CHANNEL 0 DEST 3 Number of channels MyLinRot0 DeltaCoeff TSL tsignPosition T TSL POSOFF 3CH LINH TSL SCTCOMP 3CH LIN H TSL POSCORR CH LIN H MyLinRots StateMachine Specific state machine amp MyLinRots Methods Specific methods Ij Example of one extended rotary touch sensor with 3 channels mono electrode design CONST SL LrinRo
114. t T MybinRots 0 DoclD024201 Rev 4 33 125 STMTouch driver UM1606 2 11 34 125 LinRot sensor 0 amp MyLinRots Data 0 amp MyLinRots Param 0 amp 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 amp MyLinRots Methods Specific methods Main state machine The main state machine is managed by the user in the application layer A set of functions are available to accomplish this task The main state machine can be defined with polling or with interrupt modes using one or several banks The modularity of the STMTouch driver allows also the application code to be inserted between acquisition and processing tasks oeveral examples are given below The functions to use for the acquisition are e SL acq BankConfig e SL acq BanksStartAcq e SL acq BankWaitEOC e SL acq BankGetResult These functions are device dependent and are described in the ts acq mcu c files The functions to use for the processing are e SL obj GroupProcess e SL ecs Process e SL dxs FirstObj Other functions that can be used during the processing e SL tim CheckDelay ms e TSL obj SetGlobalObj e SL tkey GetStateld e SL tkey GetStateMask e TSL linrot SetStateOff e TSL linrot SetStateCa
115. th proximi Channels Md Mind 9 TKeys 1 Linear 3ch 1 Rotary 3ch 1 The content of this table is provided for information purposes only MCU resources The table below shows the peripherals that are used by the STMTouch driver on STM32FO0xx devices Care must be taken when using them to avoid any unwanted behavior Table 21 STM32F0xx MCU resources used GPIOs Acquisition E Time base 1 ECS and DTO STM32F0xx available touch sensing channels The tables below provide an overview of the available touch sensing channels for the STM32F0xx devices The following tables are not restrictive in term of part numbers supported by the STMTouch driver The STMTouch driver can be used on any new device that may become available as part of ST microcontrollers portfolio Please contact your ST representative for support For n available pins in an I O group one pin is used as sampling capacitor and n 1 pins are used as channels The I O group cannot be used if the number of available pins in less or equal to one DoclD024201 Rev 4 Ly Table 22 Available touch sensing channels for STM32F042 x 909 LINN y NIY LOTYZOG 0G G1 IO1 G1 102 PAO 3 channels 3 channels 3 channels Number Number Number Number Number Gx IOy of of Pin of of of availabl available LQFP available available available e pins pins channels 3 channels 4 with 1 wani with 1 with 1 G1 103 samplin sampling sa
116. tml 3 STM Touch Driver um chm mi Projects Utilities G MCO ST Liberty SW License Agreement V2 pdf B Release Notes html A unins000 dat q uninsll l exe DoclD024201 Rev 4 15 125 STMTouch driver 2 3 Figure 2 Installation folder 2 2 S STMTeuch Driver hy inc E E 4 B E tsl h tal acq h tal acq stm3ztUss h tal acq stm32llss hw h tal acq stm32llss sw h tal acq stmatlbs h ts check config h ts check config miza ts check config stm3zll s h ts check config stmatibs h lea tal conf stm32f xx h TOADAPT ts conf stm32ll h TOADAPT tsl conf stm8t5xh TOADAPT tal dxs h tal ecs h tal filber h tal glabals h tal linrat h ta object h tal time h tal lime stm sete h tal time mda tal time stmatibs h tal touchkey h tal tupes h Main features e Environment Change System ECS e Detection Time Out DTO e Detection Exclusion System DXS e Noise filter tel c ts acq c ts acq stm32llss c tal acq maize hw c kal acq stm3zlls sw c E tal acq stmatibs c E tal des tal amp cs c S tal filter c E tal globals c E tal linrat c E ts abject c S tsl time c E tal time stm32f xs c E tl time stm32llxs c E tsl time stmBtl5s c tal touchkey c Release Notes htiml STMT ouch Driver um chm e Supports proximity touchkeys and linear touch sensors 9 Unlimited number of sensors e Modular architecture allowing easy addition of new acquisitions
117. tors sampling capacitors This GPIO offers a reduced touch sensing sensitivity It is thus recommended to use it as sampling capacitor I O 2 Notall 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 JOALIP YONOLIWLS GZL ZOL U o c c RE s O o o lt y NIY LOCcvcodI od 3 Table 39 Available touch sensing channels for STM32L1xx 256K table 1 2 Part numbers Group 4 Gx_lOy G1 101 G1 102 G1 103 G1 104 G2 101 G2 102 G2 103 G2 104 G2 105 G3 101 G3 102 G3 103 G3 104 G3 105 G4 101 G4 102 G4 103 PAO PA1 PA2 PA3 PA6 PA7 PF15 PGO 2 PG10 PBO PB1 PB2 PF11 PF12 PA8 PAQ PA10 oO CO NO N lm a a a ajad OJ O O O Nf OO OINI gt J O Number of available STM32L1xx 256K LQFP48 or UFQFPN48 WLCSP63 LQFP64 WLCSP64 STM32L152CC STM32L151UC STM32L151RC STM32L152RC STM32L162RC Number WLCSP of ball available pins Number of LQFP available pin Teenage SS 2 Dep 3 channels with 1 sampling capacitor 3 channels with 1 sampling capacitor capacitor 1 channel with 1 sampling 1 channel with 1 sampling capacitor 1 sampling capacitor capacitor 2 channels with did 2 channels with 1 sampling capacitor 2 channels with 1 sampling capacitor 2 ch
118. touchkey c e tsl touchkey h y DoclD024201 Rev 4 UM1606 STMTouch driver Two types of touchkey sensor are available e Basic defined by the TSL_TouchKeyB_T structure e Extended defined by the TSL_TouchKey_T structure Two functions called methods are used to initialized the sensor parameters and to run the sensor state machine e TSL tkey Init e TSL tkey Process The difference between the basic and extended concerns the usage of the methods and sensor state machine For the basic sensor the methods and state machine are those used in the TSL Params structure For the extended sensor the methods and state machine are those declared in their own structure 2 9 3 Parameters e TSLPRM TOTAL TKEYS 2 9 4 Usage example The user must declared these methods in the application code Note One can also use its own initialization and process functions instead const TSL TouchKeyMethods T MyTKeys Methods TSL tkey Init TSL tkey Process iz The declaration of the touchkey sensor is done by the user in the application code Example with basic sensor Basic touchkeys Always placed in ROM const TSL TouchKeyB T MyTKeys TSLPRM TOTAL TKEYS amp MyTKeys Data 0 amp MyTKeys Param 0 amp MyChannels Data 0 amp MyTKeys Data 1 amp MyTKeys Param 1 amp MyChannels Data 1 amp MyTKeys Data 2 amp MyTKeys Param 2 amp MyChannels Data 2 Example with
119. vironment the floating nets must be avoided tracks copper elements conductive frames etc As a consequence e All unused touch controller l Os must be either configured to output push pull low or externally tied to GND e The parameter TSLPRM_IODEF should also be configured to the output push pull low state e We recommend to drive the sampling capacitor common node using a standard I O of the touch controller configured in output push pull low mode y DoclD024201 Rev 4 GZL E9 y NIY LOCvcOdl9P 0d Figure 16 STM8L101 hardware implementation example 2 3 MCU_VDD 100nF X7R 06 XSR 0603 pF OR 0603 DNF U2 Vin _ Vout A Z aena d JUMPER LP2980A M3 3 TR Cl 4 7uF X5R 0603 C2 100nF X7R 0603 MCU VDD RI 10K 196 0603 C3 100nF X7R 0603 820R 196 0603 M5V PD5 LA MCU VDD a A 24 PD7 SER PA0 SWIM BEEP IR TIMER 8 gt Eg ppc ee 25 26 PAI NRST pe 23 PD6 EBs 27 28 29 30 PA2 pps 22 DS PEE ME 2 io e PA3 pp4 2LPD4 2 ia CND PA4 TIM1_BKIN PD3 CMP2 CH4 2 a Hp UEM PAS 5 11 UNE 222 gt pas TIM BKIN PD2 CMP2 CH3 OR 196 0603 PA6 6 10 4 7nF COG 1206 ET INO 0 PA6 CMP VREF PDI TIM2 TRIG CMP1 CH4 Ae T tuns PDO TIM2 CH2 TIM IR CMP1 CH3 gt PCS EN c R5 13 PBO TIMI CHI CMPI CH
120. x20000075 Dx20000076 Dx20000077 Dx20000077 Dx20000077 Dx20000078 Dx20000078 Dx20000078 Type TSL LinRotData T 1 TSL LlinRotData T enum LInnamecd 99 gt uinta t uinta t uinta t enum xlinnamed 31 gt enum Unnamed 31 gt uinta t TSL Bool enum T TSL Bool enum T e The arrays of TSL TouchKeyParam T and TSL LinRotParam T contain the touchkeys linear and rotary sensors parameters mainly thresholds and debounce counters Figure 27 Debug of TSL TouchKeyParam T Expression z MyTReys_ Param a M 3 Fraxln Th Frax iut Th Detectln Th DetectQutTh CalibTh CounterDebCalib CounterDebProx CounterDebDetect CounterDebRelease CounterCQebError Value array gt lt Struct gt 10 B fall 50 lt Struct ztruct Location Qe 20000050 QeZ0000050 Dz2 0000050 x20000051 Dxz2000005 Dxz20000053 Ix20000054 Dx 0000055 x20000056 Dx20000057 Dxz 0000055 Dx20000059 Dx2000005A Dxz20000064 DoclD024201 Rev 4 Type TSL_TouchkeyParam_T 3 TSL TouchKeyFaram T uinta t uinta t uinta t uinta t uinta t uinta t uinta t uinta t uinta t uinta t TSL TouchKeyFaram T TSL TouchkeyFaram T 121 125 Getting started UM1606 Figure 28 Debug of TSL_LinRotParam_T structures Expression Value Location Type MyLinRots_FParam farray gt Dx20000064 TSL LinRotFaram T 1 0 imtruct Dx20000064 TSL LinRotParam T 122 125 Froxln Th ProxQutTh DetectIn Th LietectiutTh Calip Th
121. y UM1606 Expression Ee MyrKevs Data 0 Stateld Getting started Figure 25 Debug of TSL TouchKeyData T structure Counter 0 Change DeSLock 1 Stateld Value array gt Struct gt TSL STATEID PROX TSL STATE NOT CHANGED TSL FALSE Struct gt Counter Change Des Lock 2 Stateld TSE STATETO DETECT TSL STATE NOT CHANGED TSL FALSE LStruct gt Counter 0 Change Ds Lock TSL STATEID PROX TSL STATE HOT CHANGED TSL FALSE Location Oxz20000084 Oxz20000084 ODx20000054 ODxz20000085 Ox20000085 ODx20000085 ODx20000086 Oxz20000086 Dx20000087 Oxz20000087 Ox20000087 Dx200000885 Oxz200000885 Oxz20000089 Dx2000008539 Oxz20000089 Type TSL TouchheyData T 3 TSL TauchKevDiata T enum Unnamed 40 gt uinta t enum Unnamed 31 gt TSL Bool enum T TSL TouchRheyData T enum Unnamed 90 gt uinta t enum Unnamed 317 TEL Bool enum T TSL TouchkeyData T enum Unnamed 907 uinta t enum Unnamed 31 gt TSL Baal enum T e The array of TSL_LinRotData_T contains the linear and rotary sensors state and position Expression MylinRots Data a m Figure 26 Debug of TSL_LinRotData_T structure otateld HawPFnsition Position 78 Counter B Change FosChange Counter 3 DxSLock Direction Value array gt Struct gt TSL STATEID DETECT 157 TSL STATE NOT CHANGED TSL STATE NOT CHANGED Tsk FALSE TSL FALSE Location Dx20000074 Dx20000074 Dx20000074 D

Download Pdf Manuals

image

Related Search

Related Contents

Manuale  STAIR CHAIR - MedSource International  Mustek PowerMust 1400 USB    Thecus Manual do usuário  abila 45-50-42–52 b–bt abila 45 e 230v abila 50 e 230v  ドラコ取扱説明書 - enRoute  Manual de instalación: Suelos multicap a  GUIA DO USUÁRIO - Support  Geant4 User's Guide for Application Developers  

Copyright © All rights reserved.
Failed to retrieve file