AN3342 STMICROELECTRONICS | Alldatasheet
Document overview
- Manufacturer or author: Provided By ALLDATASHEET.COM(FREE DATASHEET DOWNLOAD SITE)
- PDF pages: 39
Technical content
Datasheet sections
- 1 Hardware requirements summary
- 2 Power supply
- 2.1 Power supply overview
- 2.2 Main operating voltages
- 2.3 Power-on/power-down reset (POR/PDR)
- 3 Clock management
- 3.1 Internal clocks
- 4 Reset control
- 4.1 Reset management overview
- 4.1.1 Output characteristics
- 4.1.2 Input characteristics
- 4.2 Hardware reset implementation
- 5 ProxSense line management
- 5.1 ProxSense line management overview
- 5.2 Hardware ProxSense implementation
- 6 Recommendations
- 6.1 Printed circuit board
- 6.2 Component position
- 6.3 Ground and power supply (V
- 6.4 Decoupling
- 6.5 Other signals
- 6.6 Unused I/Os and features
- 7 Reference design
- 7.1 Component references
- 7.2 Schematics
around an STM8TL5xxx 8-bit microcontroller device. Table 1. Applicable products
Hardware requirements summary AN3342 6/39 Doc ID 18461 Rev 3
1 Hardware requirements summary
To build an application around an STM8TL5xxx device, the application board should provide the following features:
- Power supply (mandatory)
- Reset management (optional)
- ProxSense line management (optional)
- Debugging tool support: Single wire interface module (SWIM) connector (optional)
2 Power supply
2.1 Power supply overview
The STM8TL5xxx needs to be powered by a 1.65 V to 3.6 V external source. An on-chip power management system provides the constant digital supply to the core logic, both in normal and low power modes. This ensures that the logic consumes a constant current level over the voltage range. It is also capable of detecting voltage drops and generate a reset to avoid erratic behavior. The STM8TL5xxx device provides:
- One pair of power supply pins (VDD/VSS) for the main operating voltage (1.65 V to 3.6 V).
- Another pair of power supply pins (depending of package) (VDDIO/VSSIO) for the IOs (1.65 V to 3.6 V) The STM8TL5xxx device manages the supply voltage needed by the ProxSense interface by connecting a 1 µF capacitor low ESR ( 1 ) to the PXS_VREG pin (see Figure 1).
Figure 1. Power supply
- The device keeps operating as long as the batte ry voltage is above 1.65 V and no reset is generated.
2.2 Main operating voltages
a stable power supply (around 1.55 V) for the ProxSense peripheral.
2.3 Power-on/power-down reset (POR/PDR)
down reset circuit. The monitoring voltage begins at 0.7 V. order to wait for supply stabilization. reset release is defined in the electrical characteristics section of the product datasheets. A hysteresis is implemented (POR > PDR) to ensure clean detection of voltage rise and fall. threshold (isolated and repetitive events). dedicated power supply planes in multi-layer printed circuit boards (PCBs). Figure 2. Typical layout of V DD/VSS pair
3 Clock management
The STM8TL5xxx has no external clock so no precautionary measures are needed.
3.1 Internal clocks
STM8TL5xxx devices have three kinds of internal clock: A high speed internal clock (HSI) running at 16 MHz, a low speed internal clock (LSI) running at 38 kHz and a high speed internal clock dedicated to the ProxSense (HSI_PXS) running at 16 MHz. The HSI_PXS clock runs once the ProxSense is enabled if the LowPower bit is reset. If LowPower bit is set HSI_PXS clock runs only when an acquisition is being performed. After reset, the CPU starts at speed of 2 MHz driven by the internal RC (HSI clock signal) divided by 8.
4 Reset control
4.1 Reset management overview
programmed by software to be used as a general purpose output.
- External reset through the NRST pin
- Power-on reset (POR): During power-on, the POR keeps the device under reset until the supply voltage (VDD) reach the right voltage level.
- Independent watchdog reset (IWDG)
- Window watchdog reset (WWDG), featuring also software reset.
- SWIM reset: An external device connected to the SWIM interface can request the SWIM block to generate a microcontroller reset.
- Illegal opcode reset: If a code to be executed does not correspond to any opcode or prebyte value, a reset is generated. Figure 3 shows a simplified functional I/O reset schematic.
Figure 3. Reset management
4.1.1 Output characteristics
- A valid pulse on the pin is guaranteed with a 20 ns pulse duration on the internal output buffer.
- After a valid pulse is recognized, a pulse on the pin of at least 20 µs is guaranteed starting from the falling edge of A (output of the OR between the different reset sources). RPU VDD_IO Pulse generator (min 20 µs) System resetFilter 100 nF External reset circuit NRST MS18949V2 Illegal op code reset SWIM reset POR reset IWDG/WWDG/software reset Delay STM8TL5xxx (typ 40 kΩ)
Figure 4. Output characteristics
4.1.2 Input characteristics
- All pulses with a duration less than 50 ns are filtered
- All train/burst spikes with a ratio of 1/10 must be filtered. This means that a negative spike of up to 50 ns is always filtered, when a 5 ns interval between spikes occurs (ratio 1/10).
- All pulses with duration more than 300 ns are recognized as valid pulses
Figure 5. Input characteristics
4.2 Hardware reset implementation
The STM8TL5xxx does not require an external reset circuit to power-up correctly. Only a pull-down capacitor is recommended (see Figure 3). However, charging/discharging the pull-down capacitor through an internal resistor has a negative influence on the device power consumption. Therefore, the recommended capacitor value of 100 nF can be reduced down to 10 nF to limit such power consumption. The STM8TL5xxx reset state is released 1 ms after the POR value (1.35 V to 1.65 V) is reached. At this time, V DD should be in the 1.65 V to 3.6 V range.
5 ProxSense line management
5.1 ProxSense line management overview
capacitance variation acquisition. switches. This allows detection of proximity as well as touch by monitoring on PXS_RX.
- 10 independent receiver channels, allowing 10 measurements to be performed in parallel
- Each of the 10 receiver channels can be associated with two different pins, effectively allowing an application to have up to 20 receiver channels.
- Each receiver channel can be independently configured to perform projected capacitance measurements.
- The size of each CS capacitor can be independently configured with 5 bits of resolution. Figure 6 shows a simplified functional schematic of the ProxSense interface.
Figure 6. ProxSense management
- The receiver and transmit numbers are application dependent.
5.2 Hardware ProxSense implementation
The STM8TL5xxx does not require any external circuitry to transfer the charge correctly.
- 10 PXS_RX with 1 PXS_TX (10 measurements in parallel) or
- 10 PXS_TX with 1 PXS_RX (10 measurements in serial). However, any combination of 20 RX and 15 TX is allowed. Up to 15 PXS_TX are allowed to be used. Furthermore the 20 RX are organized in 2 groups, all RX belonging to the same group being acquired simultaneously. Advanced features such as an antenna (to detect noise) and external trigger may be implemented via the PXS_RFIN and PXS_TRIG pins in order to increase the robustness of the application. The footprint shown in Figure 7 gives an example of a touch key implementation on a PCB (for more details please refer to AN2869: Guidelines for designing touch sensing applications).
Figure 7. Touch key layout example The PXS_RX pins cannot be used as GPIOs, they are dedicated to ProxSense acquisition. acquisition bank with a RXn instead of a TXm in the transmitter definition.
AN3342 ProxSense line management Doc ID 18461 Rev 3 15/39 For devices with PXS_RXna and PXS_RXnb pins, i.e. with RX_GROUPA and RX_GROUPB, only the pins belonging to the same group are activated simultaneously. The disabled pins and the pins belonging to the not selected group are driven to V SS or configured in high impedance according to PXS_RXINSR register.
6 Recommendations
6.1 Printed circuit board
For technical reasons, it is best to use a multi-layer PCB with a separate layer dedicated to the VSS and another layer to the VDD supply. This results in a good decoupling, as well as a good shielding effect. For many applications, economic requirements prohibit the use of this type of board. In this case, the most important requirement is to ensure a good structure for the V SS and power supply.
6.2 Component position
A preliminary layout of the PCB must separate the different circuits according to their electromagnetic interference (EMI) contribution. This reduces cross-coupling on the PCB, for instance, noisy, high-current circuits, low voltage circuits, and digital components.
6.3 Ground and power supply (V SS, VDD, VSSIO, VDDIO)
The VSS should be distributed individually to every block (noisy, low level sensitive, and digital) with a single point for gathering all ground returns. Loops must be avoided or have a minimum surface. The power supply should be implemented close to the ground line to minimize the surface of the supply loop. This is due to the fact that the supply loop acts as an antenna, and is therefore the main emitter and receiver of EMI. All component-free surfaces of the PCB must be filled with additional grounding to create a kind of shield (especially when using single-layer PCBs).
6.4 Decoupling
The standard decoupler for the external power is a 1 µF capacitor. Supplementary 100 nF capacitors must be placed as close as possible to the VSS/VDD and VSSIO/VDDIO pins of the microcontroller to reduce the area of the current loop. As a general rule, decoupling all sensitive or noisy signals improves electromagnetic com- patibility (EMC) performances. There are two types of decouplers:
- Capacitors close to components. Inductive characteristics, which apply to all capacitors beyond a certain frequency, must be taken into account. If possible, parallel capacitors
- Inductors. Although often ignored, ferrite beads, for example, are excellent inductors due to their good dissipation of EMI energy and there is no loss of DC voltage (which is not the case when simple resistors are used).
6.5 Other signals
When designing an application, the following areas should be closely studied to improve EMC performances:
- Noisy signals (clock)
- Sensitive signals (high impedance)
- Signals for which a temporary disturbance affects operation of the application permanently, for example, interrupts and handshaking strobe signals (but not LED commands). A surrounding V SS trace for such signals increases EMC performances, as does a shorter length or absence of noisy and sensitive traces (crosstalk effect). For digital signals, the best possible electrical margin must be reached for the two logical states. Slow Schmitt triggers are recommended for eliminating parasitic states.
6.6 Unused I/Os and features
Microcontrollers are designed for a variety of applications, where often a particular application does not use 100 % of the microcontroller resources. To avoid unnecessary power consumption (especially important for battery powered applications) and also to improve EMC performance, unused clocks, counters, or I/Os, should not be left free, I/Os should be forced externally (pull-up or pull-down to the unused I/O pins), and unused functions should be ‘frozen’ or disabled. Alternatively, unused I/Os can be programmed as push-pull ‘low’ to keep them at a defined level without using external components. However in this case, the I/O is not driven during the power up phase, until the I/O is configured. This can add a little extra power consumption, and may be undesirable in very power sensitive applications. The unused PXS_RX pins should follow the same rule and can be driven to V SS by resetting the PXS_RXINSR register. 6.6.1 20-pin package A special care of I/O configuration must be taken with STM8TL5xFx devices. The port A, B and D I/Os are not all configured by default as it is the case on 28-pin packages. The user code must configure PA6, PA7, PD2, PD3, PD7 as output push pull low level. It is recommended to program all the unused I/Os to push-pull 'low level' even the ones not present in the device. While accessing to the GPIO registers, it is strongly recommended to mask the unused bit in order not to change their configuration or state. Concerning the PXS_RX: PXS_RXENRH and PXS_RXINSRH (and more generally all the MSByte of the register related to PxS_RX and PXS_TX) must be kept clear.
7 Reference design
7.1 Component references
Table 2. Component list
1 Microcontroller STM8TL5xxx 1
3 Capacitor 1 µF 1 Decoupling capacitor
4 Capacitor 1 µF
5 Capacitor 100 nF 2 Ceramic capacitor (decoupling capacitor)
6 SWIM connector 4 pins 1
7.2 Schematics
Figure 8. Reference design
- For best performance, select a low ESR ( 1 ) capacitance.
STM8TL5x firmware libraries AN3342 20/39 Doc ID 18461 Rev 3
8 STM8TL5x firmware libraries
In order to ease the development start-up, two firmware libraries are provided:
- The STM8TL5x standard peripheral library
- The STM8TL5x STMTouch library
8.1 STM8TL5x standard peripheral library
This STM8TL5x firmware library contains the standard peripheral drivers (timers, I2C, SPI, USART, watchdogs, etc...) and a complete set of source code examples for each STM8TL5x peripheral. It is written in strict ANSI-C and it is fully MISRA C 2004 compliant. All examples can be used with four workspace and project definition files:
- One for the STVD and Cosmic C compiler
- One for the STVD and Raisonance Compiler
- One for the Raisonance integrated debugging environment and compiler (RIDE7 IDE)
- One for the IAR embedded workbench for STM8 (EWSTM8). This enables the user to load and compile them easily into their preferred development environment.
8.2 STM8TL5x STMTouch library
The STM8TL5x STMTouch library is dedicated to the management of the ProxSense (PXS) peripheral. It follows the same coding rules as the standard peripheral library. The STM8TL5x STMTouch library allows you to enable touch sensing capabilities on STM8TL5x devices. This simple firmware offers a complete and robust solution to manage capacitive sensing keys, wheels or sliders.
8.3 Online help
directory (see Figure 9 and Figure 10). Figure 9. STM8TL5x standard peripheral driver online help manual Figure 10. STM8TL5x STMTouch driver online help manual
online help manual, available from the examples directory (see Figure 11). Figure 11. STM8TL5x STMTouch Examples online help manual
9 STM8 development tools
- STVD, IAR workbench, or RIDE for integrated development environment
- STM8 C compiler (from Cosmic, Raisonance, or IAR)
- ST toolset from STMicroelectronics
- Firmware libraries from STMicroelectronics (STM8TL5x_StdPeriph_Lib and STM8TL5x_STMTouch_Lib for STM8TL5x)
- STM8TL53 Touch keypad Evaluation board or STMT -BOX™ (a) Evaluation kit from STMicroelectronics.
- The debug interface ST -LINK is included in STMT -BOX™ Display board
- If you do not use STMT -BOX™ Display board, you may need the hardware debug interface ST -Link from STMicroelectronics or "Rlink" from Raisonance.
- STMStudio is a graphical user interface that allows sampling and viewing user variables in real time using any hardware debugging tool while the application is running.
9.1 Single wire interface module (SWIM)
9.1.1 SWIM overview
powerful and close in performance to a full-featured emulator. and debug module user manual (UM0470) for more SWIM protocol details. Figure 12. Debug system block diagram a. The STMT -BOX™ is an STMicroelectronics trademark.
9.1.2 SWIM connector pins
The SWIM connector pins consist of four pins as described in Table 3.
9.1.3 Hardware connection
Figure 13. Hardware connection device, as this minimizes any possible signal degradation caused by long PCB tracks.
9.2 RLink and STLink
Section 11.3.3: Connecting the hardware on page 32. Table 3. SWIM connector pins
10 STM8 software toolchain
- Integrated development environment
- Compiler
- Firmware library (optional, used to ease the startup)
Figure 14. STM8 software toolchain
STM8 software toolchain AN3342 26/39 Doc ID 18461 Rev 3
10.1 Integrated development environment
The integrated development environment ST visual develop (STVD) provides an easy-to- use, efficient environment for start-to-finish control of application development, from building and debugging the application code to programming the microcontroller. STVD is delivered as part of the free ST toolset, which also includes the ST visual programmer (STVP) programming interface and the ST assembler linker. To build applications, STVD provides seamless integration of C and assembly tool chains for ST including the Cosmic and Raisonance C compilers and the ST assembler linker. When debugging, STVD provides an integrated simulator (software) and supports a complete range of hardware tools including the low-cost RLink in-circuit debugger/programmer and the high-end STice emulator. To program applications to an STM8TL5xxx, the STVD also provides an interface for reading from the microcontroller memories, writing to them and verifying them. This interface is based on the ST visual programmer (STVP), and supports all the target devices and programming tools supported by STVP . The free ST toolset for STM8 is available from STMicroelectronics home page (see www.st.com).
10.2 Compiler
STM8TL5xxx device can be programmed by a free assembler toolchain which is included in the ST toolset. As the core is designed for optimized high-level-language support, use of a C compiler is recommended! C compilers for STM8 are offered by the third party companies Cosmic, Raisonance, and IAR. A free version of the C compiler with up to 32 Kbytes of generated code is available at:
AN3342 Setting up the STM8 development environment Doc ID 18461 Rev 3 27/39
11 Setting up the STM8 development environment
11.1 Installing the tools
All software tools are delivered with a setup wizard which guides the user through the installation process. It is recommended to install the tools in the following order: 1. C compiler 2. ST toolset 3. STM8TL5x firmware libraries ST -LINK does not need any dedicated software installation in the STM8 development environment because the necessary drivers are delivered with the ST toolset. The R-link drivers must be launched separately as follows: Start/Programs/STtoolset/Setup/Install Rlink driver.
11.2 Using the tools
development environment can be launched. an existing project from one of the STM8TL5x firmware libraries. template to configure all the compiler options. Enter your own code after main(). choose between STVD\\Cosmic, STVD\\Raisonance, RIDE, or EWSTM8. showing the STM8TL5x performances. Figure 15. STVD open example workspace
11.2.1 Project editing
All project source files are visible and can be edited (see Figure 16). Figure 16. STVD MCU edit mode
11.3 Running the de monstration software
- Choose STM8TL53 STMT -BOX™ Touch keypad firmware
- Open the desired project workspace within the chosen demonstration firmware package. To run the demonstration software on the STM8TL53 Touch keypad evaluation board, the project has to be compiled and the correct HW tool must be selected before the debug session can be started.
11.3.1 Compiling the project
The project can be compiled using the ‘Build’ function in the ‘Build’ menu (see Figure 17). Figure 17. STVD: Building the project
11.3.2 Selecting the correct debug instrument
with the on-board debug module of the STM8. Instrument Settings’ dialog (see Figure 18). Figure 18. STVD: Selecting the debug instrument Note: The Rlink can also be used for communicating via the SWIM interface. debug tool must be selected in the ‘Debug Instrument Settings’ window.
11.3.3 Connecting the hardware
powered through its USB connector. The figure below shows the STM8TL53 Touch keypad in standalone. Figure 19. STM8TL53 Touch keypad in standalone
Link debug tool must be selected. The figure below shows the STM8TL53 Touch keypad with the STMT -BOX™ Display board. Figure 20. STM8TL53 Touch keypad Evaluation board and STMT-BOX ™ Display
performed through the ST -Link built-in to the Display board. Figure 21. STM8TL53 Touch keypad with the STMT-BOX ™ Display board and
11.3.4 Starting the debug session
Debug mode can be entered by the command ‘Debug Start Debugging’ (see Figure 22). Figure 22. STVD: Starting the debug session
11.3.5 Running the software
Figure 23. STVD: Run the software
11.3.6 Follow up
the initial debug session described above. standard peripheral library and the STM8TL5x STMTouch library.
AN3342 Documentation and online support Doc ID 18461 Rev 3 37/39
12 Documentation and online support
Documentation resources related to tool usage includes: Application
- STM8TL5x datasheet.
- How to program Flash memory and data EEPROM on STM8TL5x microcontrollers (PM0212).
- STM8TL5x reference manual (RM0312)
- STM8 CPU programming manual (PM0044)
- AN2869 Guidelines for designing touch sensing applications Tools
- STM8TL5x firmware standard peripheral library and release note (detailed descriptions of the library are included as help files).
- STM8TL5x STMTouch library and release note (detailed descriptions of the library are included as help files).
- Cosmic, Raisonnance, or IAR C compiler user manual
- STMT -BOX™ Evaluation kit user manual
- STM8TL53 STMT -BOX™ Touch keypad firmware
- ST Visual Develop tutorial (included as help files in the ST -toolchain)
- ST Visual Develop (STVD) user manual
- STM8 SWIM communication protocol and debug module user manual (UM0470) The microcontroller discussion forum on www.st.com can be used by developers to exchange ideas. It is the best place to find different application ideas. In addition, the website has a knowledge base of FAQs for microcontrollers, which provide answers to many queries and solutions to many problems.
Table 4. Document revision history Updated Section 11.2: Using the tools on page 28.