I am interested in this thread becuase I am in very much the same boat as OP.
Started dabbling with STM32 a few years ago, but haven't done a real project yet.
My interest in STM32 mainly comes from the use of this processor family in a lot of Chinese products and its price/performance ratio.
In total I bought from Ali:
- 3x Maple Mini.
- 10x "Blue Pill"
- 20x STM32F103C8T6 loose chips.
- 1x FX2N Mitsubishi PLC clone. (Decent power supply, common mode filter, smps, hardened I/O)
- 4x DPS5005 ( Alternative software "opendps")
- 1x DP30V5A-L (USD 11 programmable power supply).
- 1x DSO138 ("oscilloscope" development board with TFT LCD).
- 1x DSO150 ("oscilloscope" development board with TFT LCD).
- 3x ST-Link V2 (I have some spares
.
I have been endlessly wanderig about where and how to start, which is complicated a bit extra because I use linux exclusively and a lot of stuff is windows oriented.
One of the first really usefull things I found was the tutorial from Pandafruits.
It is a very short ( 20 minutes to read, afternoon to understand) introduction in linker scripts and startup code targeted to STM32. It also helps with makefiles, programming, and a short intro to debugging. If you want to know these low level basics, it is an excellent read:
http://pandafruits.com/stm32_primer/stm32_primer_hardware.phpThen I installed an enoumous amount of ST stuff, among which the SPL. I was sort of disgusted by the bloatware. For changing a single bit in some register, you have to:
1). Declare some structure (of which the name you don't know).
2). Modify that sturcture.
3). Give that structure to some initialisation function (of which you also don't know the name).
After getting a blinking led project going I wanted to look a bit into what the startup code does. With a decent IDE (I use Qt Creator) it is of course easy to follow program execution / function calls through multiple files. Then I found stuff that after 3 function calls deep it did nothing. It went to a line of comment where you might someday want to enter some code
Yuch.
But at least that stuff from ST has linker scripts for gcc-none-eabi, but they do not use that name, but hide them in templates for IDE's that use the GCC compiler. Sigh.
Talking about linker scripts: I believe STM32 has no separate built-in "EEPROM", but instead you can reserve a piece of FLASH in a linker script to emulate "EEPROM". Is this correct? What is the endurance of the FLASH? Every little bit of info costs me hours and hours to find, untill I loose concentration and get stuck.
I've dabbled a bit with Platformio. Platformio is really handy for installing a recent compiler, and initializing projects (MBED, Arduino, SPL, and more) and at least getting something to compile.
PlatformIO uses "SCONS" as a build environment. It seems to work and is not too complicated, and it works together with Qt Creator, which I already used for AVR projects (not arduino).
PlatformIO is a plus. As a "safety" you could analyze the command lines it spits out and cobble together a simple makefile which does the same. Learning from (working) examples works better with me than learning from an overwhelming amount of spread out documentation.
In PlatfomIO I build a little project. Just read the ADC, scale it a bit and output PWM to a RC servo.
This "worked" in a few minutes. The servo sort of followed the potentiometer. However, every time the duty cycle is written to the timer it generates a glitch on the PWM output pin. So I had a look through the mbed platform. The code of which was neatly pulled from Internet by Platformio. First thing I noticed is that the mbed code was build on top of another lib (I think STL). So then you have the situation that in order to debug your own 3 line program ( read adc, output pwm, repeat) you are confronted with 2 apparently buggy frameworks on top of each other.
Not my cup of tea, so I abandoned that pretty fast.
A nice thing of MBED is the overview of development boards on their site. 100+ different boards from a handfull of manufacturers. If you're not fully committed to STM32 yet, then try to form an opinion on the quality of the development tools for those boards. STM32 is "not the best" in development tools.
Arduino...
I also did a blinking led with STM32duino (Fork of the Maple Mini) for the "blue pill" board.
I'm a bit confused why this fork exists. The "blue pill" and the "maple mini" are both readily available from Ali / Ebay, and the price for both is in a range that it does not matter. The Maple may be 20ct less cheap, but you get twice the memory for that. I think that RogerClarckeMelbourne made the fork for the "blue pill" boards before he realized that the Maple Mini was also available for very similar pricing.
Arduino does a lot horribly wrong (such as the java contaption which they call "IDE", and the redicilous connector pinout and the lack of a SMPS on their boards)
On the software side it seems to be a mixed bag. The "digitalWrite()" is attrocious and I very much dislike the random mix of C and C++ (which they give some other name to).
Another thing I dislike very much about the "arduino" stuff is all the pre-instantiated objects. First time I wanted to use "arduino" I wanted to use my self written RS485 library for the uart, but the USART was "occupied" by some pre-instantiated object hidden in the library code somewhere.
But "arduino" also seems to do some things right. It has a somwhat consistent API to get things done.
I might be tempted to pull parts out of the arduino framework, modify it to only instantiate the objects I need for a project and take it from there. Doing this might make it easier to take some leverage from the thousands of little libraries that can be installed with PlatformIO. On the other hand, I think it is also build upon a very old version of the SPL and I 'm not sure I want to put time in that.
I also played a bit with stmCUBE. It "works" under Linux (surprisingly) and it seems to be a nice way to do the initial project setup with hardly any learning curve. PLL settings and the whole clock distribution can be set up and experimented with, with just a few mouse clicks in a gui.
stmCUBE also seems to help a lot in assigning pins to peripherals. Almost all peripherals can be routed to 2 (or 3?) different locations on the chip and there are lot of opportunities for pin conflicts. StmCube keeps track of those and you can point and click in gui to find a working combination.
Just knowing which pins to use for which peripheral is a plus. It also copies template code into a new project, and adds your custom I/O configuration, and it also generates a fairly readable makefile. After the project is set up it is not dependent anymore on stmCUBE. I think stmCUBE is a plus for beginners to ease the learning curve a bit, even though the generated code is not of the highest quality. At least having some code with the right register names and bits in your created template gets you familiar with those names.
LL
I think LL has existed for some time but is being "revived" by ST because the rest sucks so much.
I have not tried it yet, but if you have written code for any uC before and are familiar with directly working with registers for initializing peripherals then you probably also dislike the bloatware of the frameworks stacked on top of each other, and you just want a header file with register and bit names to address registers, and then get on with it to write your own application.
Templates:
I've seen a few projects for intialisation of I/O registers which are template based. C++ templates are very powerful and have very little run time overhead. Downside is that they are a bitch to write and debug. If these were more widely accepted I might be very tempted to use them, but I already have my hands and head more than full with all the other stuff I'm overwhelmed with.
If you are interested in this then search for "Kvasir" " XPCC" "bmtk"
The small Davy Jones has also written his own template lib, and compares it with the ST stuff in:
Compatibility:
I have a bunch of self written libraries for hardware to control with my AVR's (doing that for 20 years). I would like to have some compatibility layer to be able to use these libraries also for STM32 but the differences seem to be too big to make this worthwile.
I also had some peeks at datasheets of processors of the same class as the STM32. (ATSAM3, Freescale, LPC). They may use the same processor core and instruction set, but peripherals are implemented in completely different ways. Timers and USARTs have different bits in different registers and different functionalities. The only road for a "common framework" for such processors would be ... just as worse as arduino or mbed I'm afraid.
I think I agree with posts in this thread before me.
Learning to wade through documentation efficiently is a valuable skill to learn.
Writing C / C++ in a "clean" way also a valuable skill to learn.
If I take the USART as an example, then the code for basic USART operations is probably 50 to 100 lines of code. If these are wrapped in readable / logical functions then your code will be relatively easy to maintain (and possibly port) to other micro controllors without touching the bulk of your application code.