In this part of the tutorial I will discuss programming and debugging of STM8 microcontrollers. By programming I mean transfer of program from your PC to the flash memory of the STM8 microcontrollers. This process is a vital step in learning to use any microcontrollers. So a clear knowledge of what things are required and how to successfully carry out programming is a must.
Most modern microcontrollers supports some kind of serial link for programming and debugging. By serial I mean they don't need a lots of wire for this communication, only two or three wires are needed. In STM8 series of microcontrollers, it is called SWIM. It stands for Single Wire Interface Module. It is a high speed link between the MCU and the programmer/debugger. SWIM needs only a single wire for data transfer. This pin is labeled SWIM in the pin diagram of microcontroller.
This pin is also labeled on the development board.
this pin must be connected to the SWIM pin of the programmer/debugger. Also the ground pin and NRST(Resent) pin must also be connected. This completes the connection. The image below shows a programmer/debugger, you can see the marking. The development board must also be powered using a micro usb cable.
The Programming Software
The final software that would run on STM8 chip comes in form of a HEX file. You may have got it from internet or from the guy you have hired to develop the software or you might have created it yourself using one of the development tools. The programmer software reads the program from this HEX file and burns it to the flash memory of STM8 chip so that it can execute it.
When you launch it for the first time, you get the configuration dialog as shown in the image below. It lets you select the programming hardware, programming mode and the target MCU chip. Select ST-LINK as hardware and programming mode as SWIM.
The main window of the STVP is shown below. You just need to select the HEX file using the open command and then click the Program button.
I am attaching a HEX file that blinks LED on PB5 of STM8S103F3. This is the usual attachment of LED on the development board shown in the image above. You can try the burning procedure discussed in this article using this HEX file.
We cordially thanks the following peoples who shared this page on various social networks and insprided us to develop more quality contents!
Madesh, Uttam Dutta, Avinash, Avinash Gupta,