Skip to content
This repository has been archived by the owner on Apr 21, 2024. It is now read-only.
prosper00 edited this page Nov 27, 2020 · 3 revisions

Welcome to the STM8-AD9833-Function-Generator wiki!

Preface:

The purpose of this wiki is to provide a tutorial, describing and walking through all the steps needed to set up a FOSS environment and toolchain for the STM8 platform, include the ST Standard Peripheral Library, and develop our first ever STM8 project from scratch.

I will be approaching this tutorial from the perspective of someone who's got a basic understanding of programming and electronics, perhaps familiar with the popular Arduino products and toolset, but has never touched the STM8 microcontroller or its tools before. This tutorial will be entirely based on Linux, using free and opensource tools. We'll describe the tools needed, their function, and how to install them on your system.

I found just 'jumping in' and starting from zero to be quite overwhelming - there are so many tools and things that need to be installed to get a working development environment up and going, and no clear picture of what all the tools were for, and so many little rabbit trails to chase down before I could even begin to start developing my first project. My aim here it to document the steps that I took to set up and configure my system, and to walk through my first practical project on the STM8 platform.

Why the STM8? Why not Arduino?

STM8 vs arduino, my take on it. It really comes down to one main feature: debug! Arduino and AVR really does not have an FOSS debug option that I'm aware of. All debugging has to happen over the UART via various printf's, or toggling LED's on pins. The STM8 can do in-circuit debugging using the same hardware as you're already using for programming. Not only is this more powerful - examining the state and contents of variables in runtime, this also frees up pins, frees up your UART, and saves space in Flash, not having to compile in print/printf and UART support.

Otherwise, the STM8 family is fairly mature, and has really good documentation and FOSS tools. ST is quite open with their tools, specifications, and libraries. Community support and libraries are nowhere near as comprehensive as with AVR, but that's not to say there's not a LOT out there, and it is growing and (IMO) generally higher quality.

STM8 boards are also very economical, as is the STLink programmer/debugger.

There IS a project to bring STM8 support to the Arduino environment - here. It's a super cool project and they've accomplished some really impressive things, however, I really don't think it's a good fit, due to limitations of SDCC. Arduino is a C++ environment, SDCC is standard C only. It can kinda-sorta be made to work in a similar way, but not similar enough to offer true compatibility. Also, Arduino is a fat environment, and SDCC does a terrible job of optimizing out unused code. So, especially with an 8k board, we run out of flash really REALLY quickly. Using a bare-metal approach, or one of the 'split' SPL's (like we'll be doing on this project) greatly economizes our flash requirements.

Although we're not going to abuse ourselves and go totally bare metal with the datasheet in one hand and a text editor in the other, doing our own register definitions, I'd HIGHLY recommend reading https://lujji.github.io/blog/bare-metal-programming-stm8/ just to get an idea of what the STM8 microcontroller is really doing, and to get an idea of the things the STM8-SPL is doing for us.