Preparing the Software Tools
Firstly, we need three major documents before starting to program STM8 micros. These are as follows:
1. STM8 Reference Manual.
http://www.st.com/content/ccc/resource/technical/document/reference_manual/9a/1b/85
/07/ca/eb/4f/dd/CD00190271.pdf/files/CD00190271.pdf/jcr:content/translations/en.CD001
90271.pdf
2. Datasheet of the MCU (STM8S003) that we’ll be using.
http://www.st.com/content/ccc/resource/technical/document/datasheet/42/5a/27/87/ac/
5a/44/88/DM00024550.pdf/files/DM00024550.pdf/jcr:content/translations/en.DM0002455
0.pdf
3. STM8SVLDiscovery Board User Manual.
http://www.st.com/content/ccc/resource/technical/document/user_manual/c8/37/11/ba/b
5/e7/4c/ee/DM00040810.pdf/files/DM00040810.pdf/jcr:content/translations/en.DM00040
810.pdf
These docs will be needed everywhere during learning session. The reference manual states the use
and purpose of all the hardware blocks in details. It includes register descriptions, naming conventions,
modes of operation of all hardware, etc. However, it does not specify the specifications of a given
STM8 micro and that’s because it is a generalized literature for all STM8S and STM8AF micros. As we
know even within a family of micros, one MCU differs from another in many aspects. Most commonly
this variation comes in the form of memory capacities and I/O pin counts. Sometimes electrical specs
also vary and so to know the limits and general specs of our target MCUs we need to checkout their
respective datasheets. Lastly the Discovery board user manual is most useful for the hardware
schematics, pin assignments and layouts. If you are using some other board then I suggest that you
acquire at least its schematic.
Now with Cosmic, STVD and STVP installed our software tool setup is almost ready. There are two
approaches to STM8 programming. The first uses the traditional concepts of register-access-based
coding, meaning you’ll have to set up every register on your own. The second way utilizes a specialized
method of coding by using standard libraries developed by STM that are both universal and platform
independent, meaning your C code will be same for any compiler using these libraries. These libraries
are called Standard Peripheral Libraries (SPL). With these libraries, no one will ever need to get down
to register-level access. The libraries are so coded that a coder will only have to know his/her chips’
hardware specs and some basics of these hardware. On the coding part, he/she will only have to set
properties and desired values. The SPL manages the rest. For instance, when setting up a UART, we
will only need to set interrupts, IOs and UART properties like baud rate, parity, etc. All of these setups
are done with meaningful numbers and texts.
The STMicroelectronics Standard Peripheral Libraries (SPL) for STM8 microcontrollers can be found
here: http://www.st.com/en/embedded-software/stsw-stm8069.html.