cancel
Showing results for 
Search instead for 
Did you mean: 

STM8S103F3 programming in assembly language.

Mkuma.12
Associate II

Hello,

I am newbie in ST MCU.Before ST MCU i use Microchip MCU lot. I am mostely using in assebley language code because i wote code for SMPS.In microchip there is good IDE and they provide a lot example with comments to learn easy.While i get very difficult to learn ST MCU.when I use STVD is always get crashes. i dont know why. And also face lack of example

to get start in ST MCU. I want to learn ST MCU but stuck.Kindly Give me suggestion to Overcome and to learn ST MCU.

Thanks and Regards

munna kumar

8 REPLIES 8
Xavi92
Associate II

Hello Munna,

I recommend you to use the open-source SDCC compiler together with the stm8-binutils-gdb package, which currently has support for unused code elimination.

Minimal example using SDCC to generate assembly code from C code to be later compiled and linked by stm8-binutils-gdb. The linker script provided on this example works for the STM8S103F3, concidentially:

https://github.com/XaviDCR92/stm8-dce-example

Fork of SDCC that allows generating GNU as-compatible files with support for '--function-sections' and '--data-sections', so unused code can be later eliminated by the linker (GNU ld):

https://github.com/XaviDCR92/sdcc-gas

This fork of the GNU binutils package for STM8 allows you to generate ELF files from assembly (combine it with SDCC for C support) that can be later flashed by OpenOCD:

https://github.com/XaviDCR92/stm8-binutils-gdb

Mkuma.12
Associate II

Thanks xavi92. I go through your instruction.

Please feel free to ask any questions!

Philipp Krause
Senior II

I also recommend to start with C.

You can use plain upstream SDCC (it does not have removal of unused functions, but for someone used to programming in assembler that should not be a problem - I don't think an assembler programmer would put some C functions into a source file that aren't called at all). It might be a bit easier to get started with, since there is more documentation and support (e.g. the sdcc-user mailing list). Also, tutorials: http://www.colecovision.eu/stm8/

Flashing can be done with stm8flash, so no binutils fork would be required. The main advantage of OpenOCD over stm8flash is that OpenOCD allows on-target debugging.

Once you're a bit familiar with SDCC, it should be easy to migrate to the GNU-as fork or the OpenOCD approach if you wish.

If you are looking for an IDE, AFAIK currently Code::Blocks has the best SDCC integration.

Cristian Gyorgy
Senior III

I believe it also depends how deep you want to go into assembly and knowing the STM8's, and the future plans with these chips.

To start from scratch you can also use this assembler: http://shop-pdp.net/ashtml/asxget.php, and any text editor to write the code. This way, nothing obscure done by the compiler or scripts is hidden to you, but of course some hard work lays ahead.

For flashing I also recommend stm8flash.

Thanks Philipp Krause.

And sorry for late reply

Thanks for reply. Sorry for late reply.