How to write programs for STM32
I often write here that I don't use Cube/CubeMX. This sometimes rises questions, e.g. one forum member asked me off-forum:
> What would be the best way to program STM32 MCUs ?
> Don't you use the cubemx generated code ?
> Have you some sort of good guideline about stm32 programming ?
Unfortunately, I don't have any guidelines. I can tell what I am using - a generic programmer editor of my liking, make-driven gcc, command-line gdb for debugging with STLink. I don't use any "library" (i.e. intermediate code attempting to embrace all aspects of the STM32 such as Cube, SPL, libopencm3) and by extension don't use CubeMX.
We can discuss the rationale, merits and demerits of this approach which may appear spartan, but that's not what recommendations are about. The problem with recommendations is, that there are many options, and none of them is "the best", "the one" - all of them have their place and are useful, given particular circumstances of use.
Thus, Cube/CubeMX may be perfectly adequate for hobbyist "arduino-like" use, or in cases where the hard-real-time controller-like aspects are not important, or in cases which fit perfectly to the usage cases the CubeMX/Cube authors envisaged and won't depart from them ever. And there are other libraries and code related to STM32, often as part of bundles for some particular purpose (e.g. drone flight control software, RTOS, security software package); there are third-party libraries for various specific purposes; there are several IDEs, high-$, low-$ and free; and there are other programming languages and other tools to create programs for STM32. I may have heard about some of them, but not even tried most of them not to mention using them properly. How could I posssibly make a recommendation, then?
So, it's upon you to do the research and decide, what to chose.
But I do have a recommendation, a pretty generic one. Whatever the toolset, strive to write as many (mostly simple) programs as possible, try to excercise as much peripherals of STM32 as possible, try many modes of their operation, and try to interface with external circuits. Try various debugging techniques, build your own toolbox. And read the available literature. This sounds - and is - painful and takes time, but it's the only way to achieve perfection.
My 2 eurocents.
JW
PS. I wrote this post in the hope that forum members more knowledgeable than me will make the recommendations and answer the questions from the start of this post.