The process and method of STM8S microcontroller development

Publisher:CrystalRoseLatest update time:2020-08-17 Source: elecfansKeywords:STM8S Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

The STM8S MCU development environment consists of three parts, including the development software on the PC (integrated development software, driver, etc.), the debugger & programmer ST-LINK, and the target MCU circuit board. As shown in the figure below:

The process and method of STM8S microcontroller development

1. Develop software on PC

The software on the PC includes: ST-LINK driver, IAR integrated development environment, STM8S standard function library, and STVP burning tool.


ST-LINK debugger & programmer requires driver

This driver does not need to be installed separately, it will be installed together with STVP.


IAR Integrated Development Environment

IAR integrated development environment is an integrated development tool that integrates program editing, compiling, program downloading, debugging and other functions. It can download programs to the target STM8S microcontroller through the ST-LINK debugger & programmer, and perform online debugging (including setting breakpoints, single-step execution, viewing internal microcontroller memory data, etc.).

The process and method of STM8S microcontroller development

There are many integrated development tools for STM8S. This tutorial uses IAR integrated development tools because it is mature, stable, simple and easy to use. The full name of IAR integrated development tools is "IAR for STM8", and the recommended version is the more mature version 2.10.5.


STM8S standard library functions

The STM8S standard function library is a C language function library originally launched by ST. It encapsulates the basic operations of the STM8S microcontroller into a library, which can greatly improve development efficiency. The full name of the STM8S standard function library is STM8S_StdPeriph_Lib_V2.1.0. Of course, you can also develop microcontroller programs without using standard library functions, but this requires operating each register of the microcontroller yourself, and you need to be very familiar with the internal structure of the microcontroller and the function of the registers to do this, and the development complexity will increase exponentially.


STVP Burning Tool

The STVP (ST Visual Programmer) burning tool is also launched by ST. Although it is generally possible to download programs to the microcontroller using the IAR integrated development environment, it is more convenient to use the STVP burning tool to set the option bytes (OPTION BYTE) of the STM8S microcontroller. The option byte has two most important and most commonly used functions: one is to set the read-out protection switch (ROP). You may encounter that the finished STM8S microcontroller development board you bought cannot be used to download and debug programs using IAR. This is because the ROP is set to on. In this case, you need to use STVP to reset it to off before you can use it; the second is to set the second function of the microcontroller pin. Many pins of the STM8S microcontroller have multiple functions, such as as an SPI interface or as a timer channel, which also needs to be set through the option byte.

The process and method of STM8S microcontroller development

Let's talk about the installation of the software on the PC. The installation packages to be used are as follows:

EWSTM8-2105-Autorun.exe

IAR for STM8 2.10.5 registration machine.7z

The above two packages are the installation program and registration machine of IAR for TM8 . You can install the first one directly, and follow the tutorial that comes with the compressed package for the second one.


STM8S_StdPeriph_Lib_V2.1.0.rar

The above package is the STM8S standard library function, which does not need to be installed, just unzip it for later use. Every time you create a new project in IAR, you must first copy the main.c, stm8s_conf.h, stm8s_it.c, stm8s_it.h and other files in the LibrariesSTM8S_StdPeriph_Driver directory of this package and ProjectSTM8S_StdPeriph_Template to the new project directory.


sttoolset.zip

sttoolset_pack24_patch.zip

The two files above are the installation packages of STVP burning tool and ST-LINK driver, which can be directly unzipped and installed. Note that STVD (ST Visual Develop) inheritance development software will be installed at the same time, but STVD only supports assembly language by default, so IAR is generally used. You can just not use it after installation.


As for these installation packages, you can download them from the official website or from Baidu Netdisk (search by file name through Panduoduo). I will not post them here.


2. ST-LINK debug programmer

ST-LINK is a USB interface hardware product that connects the PC to the target STM8S microcontroller. The following is a compatible ST-LINK debugger programmer:

The ST-LINK debugger programmer is usually connected to the target microcontroller circuit board through four Dupont wires. The four wires are power supply (3.3V or 5V optional), ground GND, and SWIM and RST. After the SWIM and RST of the ST-LINK are connected to the SWIM and RST pins of the microcontroller chip, the microcontroller can be debugged and programmed.


3. Target MCU circuit board

The target MCU circuit board is the STM8S MCU system hardware to be developed. As mentioned above, the SWIM and RST pins of the target MCU chip need to be connected to the SWIM and RST ports of ST-LINK. In the later learning process of this tutorial, you can use the STM8S minimum system board (containing only the reset circuit) as the target MCU circuit board for experiments, or you can use the STM8S development board introduced in Part 5 of this tutorial (containing the reset circuit, power switch, lithium battery charging management, Bluetooth communication circuit, etc.) for experiments.

STM8S MCU minimum system board:

The process and method of STM8S microcontroller development

STM8S development board:

The process and method of STM8S microcontroller development

If you have enough patience, you can also solder the microcontroller IC by yourself and use a breadboard for experiments. As shown below (the small square in the middle is the microcontroller IC, and wires are soldered to its 0.65mm pitch pins and plugged into the breadboard).


The above is an introduction to the development environment. Next, let’s briefly talk about the use of the development environment.

1. Create a new project in IAR

For the process of creating a new project in IAR, it is recommended to refer to this document "Detailed description of standard steps for creating a new project in STM8 under IAR environment": http://wenku.baidu.com/link?url=01T1358oA4Hgs4YgaM-YmLD5lCJwx5c1vokjZGr_c0lAkcos5QJ15B2cJHRBLNwlxhmSPepEbvhC3OlsiMJ7N4w2jRcS7-xheI8jerTaHrS


There are two points that require special attention: 1) After creating the project, you need to set the Debugger Driver to ST-LINK in the project properties (click the project name in the workspace window, right-click and select the Open menu ). Otherwise, the default selection of Simulator will not connect to the target MCU circuit board through the actual ST-LINK.

The process and method of STM8S microcontroller development

2) After adding the library files of STM8S_StdPeriph_Lib (all .h and .c files in the LibrariesSTM8S_StdPeriph_Driver directory), the compilation may fail because different MCU sub-models support different functions. There are always unsupported functions. But it doesn’t matter. Just delete the library files with compilation errors from the project.


2. Use STVP to set the MCU chip option byte (OPTION BYTE)

As mentioned above, two settings need to be completed through STVP. One is to set the readout protection switch (ROP); the other is to set the second function of the microcontroller pin. Especially for the first one, it is best to use STVP to set the ROP for newly purchased microcontroller ICs or minimum system boards and development boards, otherwise they cannot be used in IAR. The setting process using STVP is relatively simple, so I will not go into details here.


That’s all about the development environment. Starting from the next piece, I will take the STM8S103F3P6 microcontroller as an example to explain in detail how to use the microcontroller.

Keywords:STM8S Reference address:The process and method of STM8S microcontroller development

Previous article:Understand stm8s MCU to realize multi-channel conversion in three minutes
Next article:Body central control system solution based on STM8A and TI/ROHM

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号