AN3342
Application note
Getting started with STM8TL5xxx
Introduction
This application note complements the information in the STM8TL5xxx datasheets by
describing the minimum hardware and software environment required to build an application
around an STM8TL5xxx 8-bit microcontroller device.
A brief description of the principal hardware components is given. The power supply, reset
control and ProxSense lines are described in some detail. In addition, some hardware
recommendations are given. This application note also contains detailed reference design
schematics with descriptions of the main components. The STM8 development tools and
software toolchain are common to STM8TL5xxx, STM8L, STM8S and STM8A and are
presented in
Section 9,
and
10. Section 11
describes how to set up the STM8 development
environment. Finally,
Section 12
provides a list of relevant documentation and online
support resources.
Table 1.
Applicable products
Type
Microcontroller
Product sub-class
STM8TL5xxx
September 2012
Doc ID 18461 Rev 3
1/39
www.st.com
Contents
AN3342
Contents
1
2
Hardware requirements summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Power supply . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.1
2.2
2.3
Power supply overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Main operating voltages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Power-on/power-down reset (POR/PDR) . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3
Clock management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.1
Internal clocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
4
Reset control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
4.1
Reset management overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
4.1.1
4.1.2
Output characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Input characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
4.2
Hardware reset implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
5
ProxSense line management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
5.1
5.2
ProxSense line management overview . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Hardware ProxSense implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
6
Recommendations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
6.1
6.2
6.3
6.4
6.5
6.6
Printed circuit board . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Component position . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Ground and power supply (V
SS
, V
DD
, V
SSIO
, V
DDIO
) . . . . . . . . . . . . . . . . 16
Decoupling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Other signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Unused I/Os and features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
6.6.1
20-pins package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
7
Reference design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
7.1
7.2
Component references . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Schematics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2/39
Doc ID 18461 Rev 3
AN3342
Contents
8
STM8TL5x firmware libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
8.1
8.2
8.3
STM8TL5x standard peripheral library . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
STM8TL5x STMTouch library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Online help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
9
STM8 development tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
9.1
Single wire interface module (SWIM) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
9.1.1
9.1.2
9.1.3
SWIM overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
SWIM connector pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Hardware connection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
9.2
RLink and STLink . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
10
STM8 software toolchain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
10.1
10.2
Integrated development environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Compiler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
11
Setting up the STM8 development environment . . . . . . . . . . . . . . . . . 27
11.1
11.2
11.3
Installing the tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Using the tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
11.2.1
Project editing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Running the demonstration software . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
11.3.1
11.3.2
11.3.3
11.3.4
11.3.5
11.3.6
Compiling the project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Selecting the correct debug instrument . . . . . . . . . . . . . . . . . . . . . . . . . 31
Connecting the hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Starting the debug session . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Running the software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Follow up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
12
13
Documentation and online support . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Doc ID 18461 Rev 3
3/39
List of tables
AN3342
List of tables
Table 1.
Table 2.
Table 3.
Table 4.
Applicable products . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Component list . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
SWIM connector pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Document revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
4/39
Doc ID 18461 Rev 3
AN3342
List of figures
List of figures
Figure 1.
Figure 2.
Figure 3.
Figure 4.
Figure 5.
Figure 6.
Figure 7.
Figure 8.
Figure 9.
Figure 10.
Figure 11.
Figure 12.
Figure 13.
Figure 14.
Figure 15.
Figure 16.
Figure 17.
Figure 18.
Figure 19.
Figure 20.
Figure 21.
Figure 22.
Figure 23.
Power supply . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Typical layout of V
DD
/V
SS
pair . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Reset management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Output characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Input characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
ProxSense management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Touch key layout example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Reference design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
STM8TL5x standard peripheral driver online help manual . . . . . . . . . . . . . . . . . . . . . . . . . 21
STM8TL5x STMTouch driver online help manual. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
STM8TL5x STMTouch Examples online help manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Debug system block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Hardware connection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
STM8 software toolchain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
STVD open example workspace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
STVD MCU edit mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
STVD: Building the project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
STVD: Selecting the debug instrument. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
STM8TL53 Touch keypad in standalone . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
STM8TL53 Touch keypad Evaluation board and STMT-BOX™ Display board . . . . . . . . . 33
STM8TL53 Touch keypad with the STMT-BOX™ Display board and Isolation board . . . . 34
STVD: Starting the debug session . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
STVD: Run the software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Doc ID 18461 Rev 3
5/39