ST STM8S Application Note
Hide thumbs Also See for STM8S:
Table of Contents

Advertisement

Introduction
This application note complements the information in the STM8S datasheets by describing
the minimum hardware and software environment required to build an application around an
STM8S 8-bit microcontroller device. It is divided into the following sections:
Power supply
Analog-to-digital converter (ADC)
Clock management
Reset control and development
Debugging tool support
STM8 software toolchain
Setting up the STM8 development environment
This application note also contains detailed reference design schematics with descriptions
of the main components. In addition, some hardware recommendations are given.
April 2009
Getting started with the STM8S
Doc ID 14651 Rev 3
AN2752
Application note
1/42
www.st.com

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the STM8S and is the answer not in the manual?

Questions and answers

Summary of Contents for ST STM8S

  • Page 1 Getting started with the STM8S Introduction This application note complements the information in the STM8S datasheets by describing the minimum hardware and software environment required to build an application around an STM8S 8-bit microcontroller device. It is divided into the following sections: ■...
  • Page 2: Table Of Contents

    Contents AN2752 Contents Hardware requirements summary ......6 Power supply ..........7 Power supply overview .
  • Page 3 AN2752 Contents Pinouts ........... 21 STM8 development tools .
  • Page 4 List of tables AN2752 List of tables Table 1. General operating conditions ..........8 Table 2.
  • Page 5 AN2752 List of figures List of figures Figure 1. Power supply ............7 Figure 2.
  • Page 6: Hardware Requirements Summary

    Hardware requirements summary AN2752 Hardware requirements summary In order to build an application around an STM8S device, the application board should, at least, provide the following features: ● Power supply ● Clock management ● Reset management ● Debugging tool support: Single wire interface module (SWIM) connector...
  • Page 7: Power Supply

    AN2752 Power supply Power supply Power supply overview The device can be supplied through a 3.0 V to 5.5 V external source. An on-chip power management system provides the 1.8 V digital supply to the core logic, both in normal and low power modes.
  • Page 8: Main Operating Voltages

    In addition, each power supply pair should be decoupled with filtering ceramic capacitors (C) at 100 nF with one chemical C (1..2 µF) in parallel on the STM8S device. The ceramic capacitors should be placed as close as possible to the appropriate pins, or below the appropriate pins, on the opposite side of the PCB.
  • Page 9: Dd /Vss Pair

    AN2752 Power supply exact values depend on the application needs. Figure 3 shows the typical layout of such a pair. Figure 3. Typical layout of V pair Via to V Via to V STM8 Doc ID 14651 Rev 3 9/42...
  • Page 10: Analog-To-Digital Converter (Adc)

    Analog-to-digital converter (ADC) AN2752 Analog-to-digital converter (ADC) Analog power The ADC unit has an independent, analog supply reference voltage, isolated on input pin , which allows the ADC to accept a very clean voltage source. This analog voltage supply range is the same as the digital voltage supply range on pin V .
  • Page 11 AN2752 Analog-to-digital converter (ADC) Equation 1: SAMP where: ● is the total equivalent capacitor on the path of V ● is the equivalent sampling capacitance SAMP ● is the total external capacitance on the path of V to the macro pin. This includes parasitic routing capacitance, pad and pin capacitance and external capacitance.
  • Page 12: Clock Management

    For more details please refer to the section on clock management in the datasheet Internal clock The RC oscillator has an internal capacitor (C) and an internal resistor ladder (R). STM8S devices have two kinds of internal clock: a high speed internal clock (HSI) running at 16 MHz and a low speed internal clock (LSI) running at 128 kHz.
  • Page 13: Figure 6. Clock Sources

    AN2752 Clock management Figure 6. Clock sources Hardware configuration STM8 (I/O available) External source Frequency: 32 kHz … 24 MHz Comparator hysteresis: 0.1 * V Caution: Without prescaler, a duty cycle of maximum 45/55% must be respected STM8 Load capacitors Frequency range: 1-24 MHz Wake-up time: <...
  • Page 14: Reset Control

    Reset control AN2752 Reset control Reset management overview The reset cell is a dedicated 5 V bidirectional I/O. Its output buffer driving capability is fixed to Iol = 2 mA @ 0.4 V in the 3 V to 5.5 V range which includes a 40 k pull-up. Output buffer is reduced to the n-channel MOSFET (NMOS).
  • Page 15: Hardware Reset Implantation

    AN2752 Reset control 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.
  • Page 16: Rc Circuit

    Reset control AN2752 5.2.1 RC circuit The RC circuit concept is the simplest and most cost-effective external reset solution, where the supply waveform is monotonous and the maximum rise time is known. The principle is to let the RESET pin rise with the microcontroller supply voltage after a delay. The circuit is shown in Figure The basic solution is to use an RC delay determined by the rise rate of the supply itself.
  • Page 17: Recommendations

    AN2752 Recommendations Recommendations Printed circuit board For technical reasons, it is best to use a multi-layer PCB with a separate layer dedicated to the V and another layer to the V supply, which results in a good decoupling, as well as a good shielding effect.
  • Page 18: Other Signals

    User options STM8S devices have user option features that can be used for remapping or enabling/disabling an automatic reset or low speed watchdog. For more details please refer to the product datasheet.
  • Page 19: Reference Design

    Component list Component name Reference Quantity Comments Refer to the ‘Pinouts and pin description’ and ‘Package characteristics’ sections of Microcontroller STM8S the Root part number 2 datasheet, to choose the right package Push button Resistor 10 kOhm Capacitor 100 nF...
  • Page 20: Schematics

    1. If pins 22 or 25 are required as GPIO, R1 and R2 should be removed. 2. V must be within the allowed supply voltage range of the STM8S microcontroller. 20/42 Doc ID 14651 Rev 3...
  • Page 21: Pinouts

    AN2752 Reference design Pinouts STM8S devices have several package types, including the LQFP 80-pin pinout shown in Figure 12. Please refer to the Root part number 2 datasheet for more details. Figure 12. LQFP 80-pin pinout NRST OSCIN/PA1 OSCOUT/PA2 SSIO_1...
  • Page 22: Stm8 Development Tools

    STM8 development tools AN2752 STM8 development tools Development tools for STM8S microcontrollers include the STice emulation system supported by a complete software tool package including C compiler, assembler and integrated development environment with high-level language debugger. Single wire interface module (SWIM) 8.1.1...
  • Page 23: Hardware Connection

    Application board SWIM connector STM8 SWIM cable Caution: It is recommended to place the SWIM header as close as possible to the STM8S device, as this minimizes any possible signal degradation caused by long PCB tracks. Emulator STice 8.2.1 STice overview The STice is a modular, high-end emulator system which connects to the PC via a USB interface, and to the application board in place of the target microcontroller.
  • Page 24: Stice In Emulation Configuration

    Connection flex ● 60-pin or 120-pin cable for connection to the application board Connection adapter ● Links the connection flex to the footprint of the STM8S microcontroller Adapter socket ● Package-specific socket for connection adapter and STM8S microcontroller 8.2.2 STice in emulation configuration In emulation configuration, the STice is connected to the PC via a USB interface and to the application board in place of the target microcontroller being used.
  • Page 25: In-Circuit Programming And Debugging

    I/O. In both the emulation and the in-circuit programming/debugging configuration, STice is driven by the ST visual develop (STVD) or ST visual programmer (STVP) integrated development environment running on the host PC. This provides total control of advanced application building, debugging and programming features from a single easy-to-use interface.
  • Page 26: Figure 17. In-Circuit Programming And Debugging

    Figure 17. In-circuit programming and debugging ICD/ICP flat cable connects STice to microcontroller via ICD/ICP connector on application board SWIM connector linked to microcontroller (SWIM protocol for STM8, or ICC protocol for ST) ST microcontroller on application board 26/42 Doc ID 14651 Rev 3...
  • Page 27: Stm8 Software Toolchain

    AN2752 STM8 software toolchain STM8 software toolchain In order to write, compile and run the first software on an STM8S device, the following components of the software toolchain are required (see Figure 18): ● Integrated development environment ● Compiler ●...
  • Page 28: Integrated Development Environment

    RLink in-circuit debugger/programmer and the high-end STice emulator. To program applications to an STM8S, 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.
  • Page 29: Firmware Library

    AN2752 STM8 software toolchain Firmware library The STM8 firmware library is a complete set of source code examples for each STM8 peripheral. It is written in strict ANSI-C and it is fully MISRA C 2004 compliant (see Figure 19). All examples are delivered with workspace and project definition files for STVD and Cosmic C compiler which enables the user to load and compile them easily into the development environment.
  • Page 30: Setting Up The Stm8 Development Environment

    ST toolset STM8 firmware library The Rlink does not need any dedicated software installation in the STM8 development environment because the necessary drivers are delivered with the ST toolset. Note: These R-link drivers must be launched separately as follows: Start/Programs/STtoolset/Setup/Install Rlink driver.
  • Page 31: Using The Tools

    Setting up the STM8 development environment 10.2 Using the tools Once the tools installation is complete, the ST visual develop (STVD) integrated development environment can be launched. The user then has the choice to generate either a new workspace with a new project or to open an existing workspace.
  • Page 32: Project Editing

    Setting up the STM8 development environment AN2752 10.2.1 Project editing All project source files are visible and can be edited (see Figure 21). Figure 21. STVD MCU edit mode 32/42 Doc ID 14651 Rev 3...
  • Page 33: Online Help

    AN2752 Setting up the STM8 development environment 10.2.2 Online help An online help manual is available inside the firmware installation directory (see Figure to help the user understand the structure of the STM8 firmware library. Figure 22. STM8 firmware library online help manual Doc ID 14651 Rev 3 33/42...
  • Page 34: Running The Demonstration Software

    Setting up the STM8 development environment AN2752 10.3 Running the demonstration software To run the demonstration software on the STM8 evaluation board, the project has to be compiled and the correct HW tool must be selected before the debug session can be started.
  • Page 35: Selecting The Correct Debug Instrument

    AN2752 Setting up the STM8 development environment 10.3.2 Selecting the correct debug instrument In the example below, the Rlink tool is used for communicating via the SWIM interface with the on-board debug module of the STM8. The Rlink tool can be selected from the ‘Debug Instrument Selection’ list in the ‘Debug Instrument Settings’...
  • Page 36: Connecting The Hardware

    Setting up the STM8 development environment AN2752 10.3.3 Connecting the hardware The Rlink tool can be connected to the PC by a standard USB connection. It is also powered by the USB interface. On the controller side the connection to the STM8 evaluation board is made by the SWIM interface cable.
  • Page 37: Starting The Debug Session

    AN2752 Setting up the STM8 development environment 10.3.4 Starting the debug session Debug mode can be entered by the command ‘Debug Start Debugging’ (see Figure 26). Figure 26. STVD: Starting the debug session Doc ID 14651 Rev 3 37/42...
  • Page 38: Running The Software

    Setting up the STM8 development environment AN2752 10.3.5 Running the software After entering debug mode, the software can be started by the run command in the menu ‘Debug Run’ (see Figure 27). Figure 27. STVD: Run the software 38/42 Doc ID 14651 Rev 3...
  • Page 39: Follow Up

    Figure 28. STM8 evaluation board 10.3.6 Follow up Step by step, additional peripherals of STM8S devices can be run, following on from the initial debug session described above. Many features of STM8S devices are supported by dedicated hardware on the STM8 evaluation board.
  • Page 40: Documentation And Online Support

    Cosmic C compiler user manual ● STM8/128-EVAL evaluation board user manual (UM0482) ● 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...
  • Page 41: Revision History

    AN2752 Revision history Revision history Table 4. Document revision history Date Revision Changes 03-Jun-2008 Initial release STM8S207/208 replaced by STM8S20xxx Figure 11: Reference design on page 20 Figure 12: LQFP 80- 01-Sep-2008 pin pinout on page 21 modified to be in line with the pin description of the STM8S20xxx datasheet Figure 7: Reset management on page 14 modified...
  • Page 42 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.

Table of Contents