User manual
STM8 C tutorial UM0036
332/385 Doc ID 7705 Rev 11
12 STM8 C tutorial
The STM8 tutorial illustrates some of the main features of STVD by guiding you through the
process of building and debugging a sample application in C language.
Each procedure presented in this tutorial focuses on a functional aspect of the build and
debug processes. Steps should be performed in the sequence in which they are presented;
failure to do so can result in errors in the steps that follow.
After the successful completion of a procedure, you should save your workspace by
selecting File>Save Workspace As… from the main menu. By doing so, you will be able to
return to a previous, successfully completed stage if necessary.
The tutorial example is based on an application for a traffic signal. It is designed to be built
using the Raisonance or Cosmic C toolset for STM8. You can download limited versions of
these toolsets for free from st.mcu.com.
This application uses features that are common to all STM8 microcontroller families
(STM8L, STM8A, STM8S) so that emulator users can choose a microcontroller that is
supported by their emulator to follow most of the tutorial. The following files are provided to
build the application:
1. Setup: only minimum source files are provided.
● timer.c: application source file written in C language. This is an application for a traffic
signal. A bug is generated during the execution of the application.
● mcuregs.h: generic include file for microcontroller-specific constants.
● st.toolset/include/<mcuname>.h: microcontroller-specific constants.
● Raisonance/R_stm8_interrupt_vector.c: file containing the interrupt vector table.
● Cosmic/stm8_interrupt_vector.c: file containing the interrupt vector table.
2. Build.
● tutorial.stw, tutorial.wed: workspace information files.
● cosmic/cosmic.stp, cosmic/cosmic.dep: cosmic project information files.
● raisonance/raisonance.stp, raisonance/raisonance.dep: raisonance project information
files.
These files are created during step 1, but are provided in the directory step2_build, so
that you may start the tutorial from step 2.
Note: For standard installations of STVD, the files listed above are saved under:
C:\Program Files\STMicroelectronics\st_toolset\stvd\Examples\
tutorial_STM8
Some lessons of the debug tutorial relate to features that are specific to a debug instrument,
while others relate to all debug instruments.
Table 85. Tutorial sections and applicable debug instrument
Section Debug instrument
Setup All
Build All
Start debugging All
Instruction breakpoints All