Author Topic: Getting started with STM8S  (Read 10531 times)

0 Members and 1 Guest are viewing this topic.

Offline MusteyTopic starter

  • Contributor
  • Posts: 12
  • Country: gb
Getting started with STM8S
« on: June 25, 2020, 04:50:07 pm »
It's a weird story but the gist of it is that I am trying to save the fledgling business of my friend.
This requires me to help him with programming a little on the stm8s003f3.

I just received today my STLINK-V3SET and I should be receiving a few eval boards soon.

I started looking into the software toolchain but I am already scared that I might not be able to find all the "API" calls to actually compose code for that chip to run.
I don't even know if these should be referred to as API calls, methods, routines?

I guess I will be installing a library specific to that chip with those calls but is there a resource that describes the library and how to use it?
Ideally with some examples on reading/writing from/to i2c devices?
 

Offline ebclr

  • Super Contributor
  • ***
  • Posts: 2332
  • Country: 00
Re: Getting started with STM8S
« Reply #1 on: June 25, 2020, 05:24:03 pm »
 

Offline MusteyTopic starter

  • Contributor
  • Posts: 12
  • Country: gb
Re: Getting started with STM8S
« Reply #2 on: June 25, 2020, 06:12:19 pm »
I have just installed it and it doesn't work ("side-by-side configuration")... Nevermind, let's say I get it to work - I had a look at the provided docs and it looks even scarier. This C look a lot less nice than the C I learned when I was programming on a windows machine!

I guess you are going to say that it's not something a novice can pick up in a couple of weeks?
 

Offline OZ1LQB

  • Regular Contributor
  • *
  • Posts: 60
  • Country: dk
Re: Getting started with STM8S
« Reply #3 on: June 25, 2020, 06:24:00 pm »
Hi ..
This is what godt me started
Cosmic and STVD
and this very good and free book
http://embedded-lab.com/blog/wp-content/uploads/2018/01/Starting-STM8-Microcontrollers.pdf
good luck and have fun
 
The following users thanked this post: abraxalito, I wanted a rude username, Mustey

Offline OZ1LQB

  • Regular Contributor
  • *
  • Posts: 60
  • Country: dk
 

Offline MusteyTopic starter

  • Contributor
  • Posts: 12
  • Country: gb
Re: Getting started with STM8S
« Reply #5 on: June 25, 2020, 07:37:45 pm »
I just skimmed that resource and I feel like I need to give the guy some donation or help him maintain/update this document.
A serious body of work that looks also pretty accessible.

I did forget to mention I dug everywhere on google and found some stuff like E. Marinoni's site but mostly it looks like people who may know what they are talking about but have no idea how to transfer their knowledge effectively.
I didn't find this document but now you showed it to me - thanks!
 

Offline rhodges

  • Frequent Contributor
  • **
  • Posts: 364
  • Country: us
  • Available for embedded projects.
    • My public libraries, code samples, and projects for STM8.
Re: Getting started with STM8S
« Reply #6 on: June 25, 2020, 10:05:08 pm »
I use the free SDCC (small device C compiler) and ST-LINK V2 and stm8flash to program the chips.

I have a nice ecosystem of STM8 libraries, sample/example programs, and projects on github. Most of it is for STM8S103 or STM8S105, but the STM8S003 is so close, they will work fine.

The libraries have support for many input and output devices, such as keypads, LCD, and LED modules, binary/decimal conversion, PWM/servo control, ultrasonic rangefinding, UART. It also has a support library for the STM8S003 W1209 thermostat, which has three buttons, a 3-digit display, a temperature probe, and a relay.
https://github.com/unfrozen/stm8_libs/wiki

Here are some test and example programs, ready to compile with the libaries and write to flash:
https://github.com/unfrozen/stm8_tests/wiki

Here is a PWM controller project for a motor:
https://github.com/unfrozen/pwm_pump/wiki

Here is a water tank level sensor using ultrasonic rangefinder:
https://github.com/unfrozen/pwm_pump/wiki

Feel free to browse the code, and use whatever you like.
Currently developing embedded RISC-V. Recently STM32 and STM8. All are excellent choices. Past includes 6809, Z80, 8086, PIC, MIPS, PNX1302, and some 8748 and 6805. Check out my public code on github. https://github.com/unfrozen
 
The following users thanked this post: I wanted a rude username, Mustey

Offline soFPG

  • Frequent Contributor
  • **
  • Posts: 283
  • Country: de
Re: Getting started with STM8S
« Reply #7 on: June 26, 2020, 08:15:33 am »
I can recommend the IAR environment for STM8, it allows debugging, probably has the best compiler for performance and code size.
As far as I know they also offer header files with register and bit definitions.
But for commercial use you may have to buy the software from them. Probably several thousand dollars.
 

Offline HwAoRrDk

  • Super Contributor
  • ***
  • Posts: 1942
  • Country: gb
Re: Getting started with STM8S
« Reply #8 on: June 26, 2020, 09:01:45 am »
If you want to use ST's SPL but not use proprietary toolchain, their device headers have been open-sourced and there is a patch to make SPL compile with SDCC.

https://github.com/gicking/STM8_headers
https://github.com/gicking/STM8-SPL_SDCC_patch
 

Offline PCB.Wiz

  • Super Contributor
  • ***
  • Posts: 3443
  • Country: au
Re: Getting started with STM8S
« Reply #9 on: June 26, 2020, 10:53:05 pm »
It's a weird story but the gist of it is that I am trying to save the fledgling business of my friend.
This requires me to help him with programming a little on the stm8s003f3.
What does he have already working ? Are PCBs already designed ?

Usually, with a new micro you are best to take the most traveled path, initially.

That means buying Eval Boards (more than 1 is useful, as you can A-B compare different code versions ) - they are so cheap, it is useful to have spares.

One detail to keep in mind, is the smaller ST8M packages have few code-size choices.
If size is not an absolute must, and the board is not done yet, you could consider TQFP32 package, as that has larger code size options.
If you are new to MCUs, & the requirements morph, spare code capacity can be gold :)
 

Offline HwAoRrDk

  • Super Contributor
  • ***
  • Posts: 1942
  • Country: gb
Re: Getting started with STM8S
« Reply #10 on: June 27, 2020, 09:05:09 am »
If you are new to MCUs, & the requirements morph, spare code capacity can be gold :)

Although bear in mind that once you get to chips with more than 32KB of flash, you have to jump through a few hoops to properly utilise the extra space (the compiler needs to be able to handle 24-bit 'far' addresses).

I believe the free version of Cosmic is restricted to 32KB.
 

Offline OZ1LQB

  • Regular Contributor
  • *
  • Posts: 60
  • Country: dk
Re: Getting started with STM8S
« Reply #11 on: June 27, 2020, 12:49:08 pm »
Hi.
HwAoRrDk it is not restricted anymore.
here is what it says on hompage of cosmic

STM8 free tools with no limits
The popular STM8 compiler, with no technical limitations.
 

Offline MusteyTopic starter

  • Contributor
  • Posts: 12
  • Country: gb
Re: Getting started with STM8S
« Reply #12 on: July 06, 2020, 08:39:25 am »
Spent 9 hours yesterday (20:00 - 05:00am!) trying to get started. I followed the 'embedded-lab' guide which looks a little better than it actually is. It's amazing how low level it gets sometimes and then just totally skips over stuff. Also code is full of typos, which is nearly fatal for someone who isn't an embedded-c developer like me...

Once I got something that builds fine, I tried to flash it into the chip. Tried both STVD-lite-programmer and STVP - both complained about not being able to communicate with the application (pretty sure this means the chip) via SWIM.
I found an application installed with STVD that's supposed to "upgrade" (update?) my LINK with the latest firmware - it said the data on my link is corrupted... Although not sure if that program is designed to work with the V3SET in the first place...

Now, I will be starting the SDCC route. Unfortunately, all the examples I can find are on linux. I know a little linux so I know what they mean and how to do it on Win10, but would be more confident to see a real example - I don't reckon any of you SDCC users are on windows and can tell me which compiler and build tool you used (for preparing STCC)?
 

Offline soFPG

  • Frequent Contributor
  • **
  • Posts: 283
  • Country: de
Re: Getting started with STM8S
« Reply #13 on: July 06, 2020, 09:00:35 am »
Maybe you can get some help from the man himself:



Even though he is using the Padauk backend I think there might still be some information in there.

But I don't know how switching to a different compiler will help you with not being able to communicate with your uC. I didn't find this information in your comments, but: which board are you using? How is your setup?
« Last Edit: July 06, 2020, 09:02:50 am by soFPG »
 

Offline MusteyTopic starter

  • Contributor
  • Posts: 12
  • Country: gb
Re: Getting started with STM8S
« Reply #14 on: July 06, 2020, 09:58:36 am »
I know it's a little unrelated - the STVD itself has an option to choose the compiler (I don't remember if SDCC is there)...
I was just looking at it from a tactical point of view: much easier to find worked-out examples of SDCC+stm8flash or STVD+STVP but much less common to see a mixture of them... And I think STVD is the offending member of my system, which is:
Win10 > STVD > Cosmic > STVP > STLINK-V3SET > stm8s003f3

Yeah, I just saw this vid as a recommendation when I was searching for music this morning, lol :) Have not had the time yet to take a look!
 

Offline soFPG

  • Frequent Contributor
  • **
  • Posts: 283
  • Country: de
Re: Getting started with STM8S
« Reply #15 on: July 06, 2020, 10:17:13 am »
I am going back to my recommendation: In order to verify that you have a working setup you might still want to try IAR's STM8 workbench (which you can get for free, with code size restrictions though) which is an all-in-one package.
After you have verified that everything works you can still switch to an open source toolchain.
 

Offline MusteyTopic starter

  • Contributor
  • Posts: 12
  • Country: gb
Re: Getting started with STM8S
« Reply #16 on: July 06, 2020, 11:42:50 am »
Yeah, I am definitely up for trying different things... Just it all takes time!

Anyway, I have another direction to go to. I got some support from the manufacturer and what they say is interesting. I think it may benefit others, should they be in my very particular situation, to know the following:
https://community.st.com/s/question/0D53W00000BrKYsSAN/stlinkv3set-cannot-communicate-with-target-over-swim-or-doesnt-work-at-all-with-stvdstvp

(TL;DR: Apparently there's missing info in the manual and when downloading drivers. JP3 also needs to be closed and a different driver than what they initially say, needs to be used)
 
The following users thanked this post: soFPG


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

- - -
-->