Skip to main content
Visitor II
June 7, 2020
Question

STM8S103F3 programming in assembly language.

  • June 7, 2020
  • 4 replies
  • 3119 views

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

    This topic has been closed for replies.

    4 replies

    Visitor II
    June 7, 2020

    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.12Author
    Visitor II
    June 7, 2020

    Thanks xavi92. I go through your instruction.

    Visitor II
    June 7, 2020

    Please feel free to ask any questions!

    Visitor II
    June 11, 2020

    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.

    Mkuma.12Author
    Visitor II
    June 16, 2020

    Thanks Philipp Krause.

    Mkuma.12Author
    Visitor II
    June 16, 2020

    And sorry for late reply

    Visitor II
    June 13, 2020

    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.

    Mkuma.12Author
    Visitor II
    June 16, 2020

    Thanks for reply. Sorry for late reply.