Introduction
I'd like to share how I use 7 segment displays and STM8 boards to monitor/display numbers of any kind. This started out as a project for work, but quickly escalated to something a little more interesting, and challenging, and maybe even useful. So here's the story, and I'll try to keep it short. And I'll even try to put the good details up front so you don't have to wait.
This project rests on the shoulders of others and it's not at all 100% my own creative doing, but a lot of this may bridge the gap for some of you out there who want to do this type of thing, so I'm sharing. I'm pretty jazzed about this and I hope you are too. Some preliminary thanks to Thomas for sharing the bulk of the information I've relied upon and his super awesome willingness to prod me in the right direction. Thomas also has a github site for stm8ef and other projects you can find here on Github. The site Bare Metal Programming and a great blog get some serious read time credit to lujji! A great many good vibes to Robin for this page https://maker.pro/custom/tutorial/using-gpio-on-stm8-microcontrollers and all that good info. A huge thanks to the Sduino Project and all the detailed info about the blue pill board. I welcome feedback, comments, and corrections regarding this page.
Hardware
The STM8 comes in a variety of shapes and sizes, and Thomas has covered a huge swath of them in great detail and has provided a lot of more generalized details about the STM8 line and the devices that you can find out there. I'm intending to cover only just this one, because it's popular, inexpensive, easy to use, and what I have on hand at the moment that works for my development needs for the project I started out to finish. I'm accomplished the task a few different ways, but I am after a better way, always. I'm using the STM8S103F3P6 in a board that brings all the pins out to the edge so you can get at them, and you can install header pins and make it plug right into a protoboard. I grew up in the era of Radio Shack's popular books by Forest M Mimms III, which featured many circuits, using a breadboard or protoboard, and dip chips and transistors and other small component to build a large variety of applications and educational demonstrations. The protoboard is probably the easiest way to get this stuff built so you can play with it, adjust it, experiment with it and learn things while being productive.
Hardware setup. Blue Pill STM8 board for under a buck. 4-digit seven segment display. Serial interface. USB "swim" programmer. Breadboard. a 10K to 25K pot and 8 limiting resistors for your LEDs (almost anything from 220R to 1K should do, as long as you've got a handful of them). And header pins, or just some bits of the right kind of wire if that's all you've got. The pins are cheap, buy a bunch. And a linux box (ubuntu worked well), and you might get a nice multi-port powered USB hub to make things easier on yourself.
Software
Rev 1: I used the Arduino IDE and the "sduino" bits that I found out on the web. This let me write in C and allows for reasonably readable and easy to write code, and a binary of about 5200 bytes. I'm sure I can do better, the things only got 8K, and I want room to move around in there...
Rev 2: ... So I try my hand and cobbling it together in SDCC from source (and librarie files borrowed from all over the place) on my linux box. I borrowed a little #define macro here, and a little idea about a smarter way to do the thing I was doing there, and a little speed increase by trying more direct GPIO over here, and pretty soon, I'm looking at a reasonable facsimile of a running hunk of code on the proto and it's more configurable, faster and only about...
Read more »
Thanks! I'm just trying to give what I get. I'm learning a ton from this project, and I imagine there are others that might benefit from a single example that is well fleshed out. The stm8ef project covers _so_ _much_ ground that it took a good many little bits from many different places to make the cohesive picture I needed to understand it. My goal is to really cover this one thing in depth. It also serves as a handy reference for my aging gray cells.