Starting STM8 Microcontrollers
Just like any other software developer, my choice of language for software development is C language. I don’t want to spend time coding complex stuffs in assembly or other languages. STM8s are also C optimized micros. Apart from these reasons, I chose C language for the fact that STMicroelectronics has provided a Standard Peripheral Library (SPL) that is very easy to use. With SPL, it becomes totally unnecessary to program each peripheral register with meaningless numbers and maintain coding sequence. We will never need to access registers for any reason as everything is done under the hood of SPL. All sequences are dealt inside the SPL. All that we will ever need is the clear concept of each hardware block, their working principles, their capabilities and limitations.
We will need an Integrated Development Environment (IDE) and a C-language toolchain. The best stuffs you can get your hands on at zero costs are ST Visual Develop (STVD) IDE and Cosmic C compiler. Both are free but a rather difficult to use at first. STVD also packs with a programmer software tool called ST Visual Programmer (STVP). We will need STVP to upload codes to target STM8 micros.
Cosmic used to be a paid tool just like your PC’s antivirus software but at the time of writing this article, the Cosmic team has made it absolutely free for STM8 family. However, to use it you will need to register and acquire a license key via email. Usually this procedure of acquiring license and registration is maintained automatically by the software company’s server but with Cosmic it is different story. You will need to wait for some guy at Cosmic end to respond to your license request. It may take a few minutes or even a day but still the best part is getting a full version compiler for nothing.
You can get
STVD from here: http://www.st.com/en/development-tools/stvd-stm8.html and
Cosmic C compiler from here: http://www.cosmic-software.com/download.php.
You need to register in order to download both software. For Cosmic you will also need to acquire a free license for it work. So just fill in some basic info about you.
Firstly, we will need to install STVD. Installation procedure is simple and same as typical software installation. Just click next, next and next. After that we will need to install Cosmic C compiler. Again, just next, next and next until the screen as shown below.
After installation, you’ll prompted for licence. You must register your license unless you have already registered. If you have already registered, then you’ll be asked if to overwrite registration. You should skip reregistering.
For the first run, you’ll get the following screen looking for a valid license.
You must fill all the starred (*) points to complete the process of registration. Select “Write to File” option and save the file as a text (.txt) file. The file name should be “CM8_license.txt”. Send this file to stm8_Free@cosmic.fr with subject “STM8FSE, STM32 32K License Request”. Now you’ll need to wait for the Cosmic team to respond to you. They’ll send you an email back with an electronic key license. The file will have a name like “license.lic” and the email will have some instructions.
This was my emailed license.
Once you get the license, you’ll need to show the software its location and complete the licensing process as shown below. Save the license file in a secured location.
At the end of this process, we can enjoy the compiler without any limitations.
I also recommend that you download Sublime Text (https://www.sublimetext.com/) or Notepad++ (https://notepad-plus-plus.org/) for viewing your code with ease. These are very cool software. This is not mandatory though.