2020-06-03 11:40 PM
Dear Forum Members,
I am new in STM8 and I would like to familiar with this MCU series and use it.
For starting, I would like to programming in assember. When I make a new project the IDE SW automatically generates
a basic code, but I do not understand what is this for. Anyway, I do not understand its sxntax, directives etc.
Could someone give me a documentation about assembler syntax?
And I would like to ask reffering to the Flash prgramming how the Bootloader, ISP, IAP programming exactly work, for example which MCU pins used and the required HW tool adapters. For example whether the Bootloader use the normal UART TX/RX pins or other pinis and in this case serial comm onyl emulated by the Boot SW in the ROM.
Thanks in advance,
József
2020-06-07 04:25 AM
Hi József,
There is a fork of the GNU binutils package for STM8 that 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
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
Minimal example using SDCC to generate assembly code from C code to be later compiled and linked by stm8-binutils-gdb:
https://github.com/XaviDCR92/stm8-dce-example
Edit: the example is for STM8S, but it should be easy to adapt it to STM8L.
2020-08-25 01:13 AM
Hi Xavier,
I have ordered an ST-Link/V2 tool and some 08L050J tiny SO-8 device. I would like to use IAR Assembler at starting (it is perfect to learn device by written smaller codes).
Somewhere I read be careful when device does not have an RST pin and SWIM interface used: the dice can be locked forever accidentally if program code execution not delayed. Can you please suggest an easy and safe procedure (codeing technique) to avoid this phenomenon? (I would not like to lock it at first since it is soldered onto a small PCB:) Anyway, general tips for starting a program (stack pointer, clock, wdt, pin direction settings etc). Thank you in advance!
Kind regards,
József
2020-08-25 04:11 PM
Hi József,
You are right, the STM8L050J3 does not feature a RST pin, so the datasheet recommends adjusting PA0 (if needed) as GPIO at least after 5 seconds so there's still time to flash the device through the SWIM pin. OTOH, there is also a bootloader available on pins 1 (PA0/RX) and 8 (PC1/TX) if you do not want to deal with SWIM, but that might not be the most interesting option for you.
To be honest, I have never used the STM8L050J3 so far (only STM8S003F3 and STM8S207C8), but I guess the startup routine (stack pointer and .bss/.data initialization) should not be too different. When using GNU as-compatible output, SDCC outputs a hardcoded init file that is later linked by stm8-ld, so you could check whether it is still compatible with STM8L.
So, considering the lack of a RST pin, I suggest not to use or modify pin 1 (SWIM/PA0) mode until you feel comfortable enough with both the toolchain and the device itself. Meanwhile, I would definitely recommend configuring TIM2 so you can define a regular time tick that can be later used to build a very simple round-robin scheduler for your application, which in turn can be used to determine the 5-second-or-greater delay afterwards. ST's libraries for STM8, albeit non-free software, can be useful as a starting point. Once your prototype application is stable, you will be able to move on to the next step and switch pin 1 to any other mode if needed.
Hope it helps.
Best regards,
Xavier
2020-09-15 07:00 AM
Hi Xavier,
I will not change the Swim pin function. I started to coding, but I get always errors. I would have some quaestions:
it is not good:
LD A,#$FF
LD PB_DDR,A
LD PB_CR1,A
LD A,#$00
LD PB_CR2,A
I seen these symbols in the device .inc file (I have included).
How the direct addressing Works? Wheter this address is an absolute or relative (to PC?)
Thanks and regards,
József