Author Topic: Learning STM32  (Read 1633 times)

Tation and 3 Guests are viewing this topic.

Offline Vinar20122Topic starter

  • Newbie
  • Posts: 3
  • Country: ua
Learning STM32
« on: November 24, 2026, 06:18:22 pm »
I'd like to ask people familiar with STM32 microcontrollers: what's the best way to get started with them?
I have an STM32 board based on the STM32F405RGT6.
What resources, books, or learning materials would you recommend for learning STM32, and how did you go about learning them yourself?
 

Offline voltsandjolts

  • Supporter
  • ****
  • Posts: 3935
  • Country: gb
 
The following users thanked this post: Karel

Offline pqass

  • Super Contributor
  • ***
  • Posts: 1193
  • Country: ca
Re: Learning STM32
« Reply #2 on: November 24, 2026, 11:26:52 pm »
Mitch Davis has four videos which you may find useful on getting acquainted with STM32.
 

Offline mark03

  • Frequent Contributor
  • **
  • Posts: 785
  • Country: us
Re: Learning STM32
« Reply #3 on: November 25, 2026, 04:12:44 am »
Are you already familiar with microcontroller programming (without lots of libraries, Arduino, etc.)?  If so, start with the data sheet and the Reference Manual.  If not, ARM has a free textbook that I've used in undergraduate classes on embedded computing.  It's pretty good, and the second edition is based on an STM32 processor:

https://github.com/arm-education/Embedded-Systems-Fundamentals

If your goal is to learn how things work, I recommend not using the HAL:  manipulate the registers directly using the definitions in the CMSIS header file, i.e. write code like "TIM3->CR1 |= TIM_CR1_CEN".  (Once you gain a bit of experience, you'll probably still not want to use the HAL, but for different reasons.  The HAL is mainly for people who want to get something working in a hurry.)
« Last Edit: November 25, 2026, 04:20:48 am by mark03 »
 
The following users thanked this post: Vinar20122

Offline peter-h

  • Super Contributor
  • ***
  • Posts: 6154
  • Country: gb
  • Doing electronics since the 1960s...
Re: Learning STM32
« Reply #4 on: November 25, 2026, 11:24:37 am »
I think the best way is to pick a chip which will do the job of some projects you want to build. In 2016 I picked a 32F417 and I still use it, with the 437 giving another 64k RAM and with minimal other changes.

Then get one of the ST development boards, install Cube IDE, and get an LED flashing on and off :)

Then go from there. Once you have some running code, you can build on top of that easily enough.

I've been doing embedded since about 1980. Today is is very different. No assembler, only C. No more reading about details of CPU architecture (the ARM STM32 manual is about 5000 pages!). Even the CPU reference manual is 2000 pages and nobody reads it except for the bit they want to know e.g. the registers of the SPI controller. The CPU data sheet is 300 pages and you do have to read every word if you are going to design a PCB, but normally you base the PCB on the circuit of the ST development PCB :)

Later, you can add blocks to Cube like FreeRTOS, FatFS, whatever...
Z80 Z180 Z280 Z8 S8 8031 8051 H8/300 H8/500 80x86 90S1200 32F417
 

Offline Doctorandus_P

  • Super Contributor
  • ***
  • Posts: 5404
  • Country: nl
Re: Learning STM32
« Reply #5 on: November 25, 2026, 11:56:54 am »
If you have some time to burn:

https://www.eevblog.com/forum/microcontrollers/is-st-cube-ide-a-piece-of-buggy-crap/

I bought a bunch of "blue pills" when they still had genuine ST processors on them, but those barely exist anymore. The "Black Pill" from WeAct seems a good alternative and have a newer (and significantly better) processor. I find Eclipse abhorrent, (If some small thing falls over, you spend a week searching for it). ST is pushing really hard to use their buggy IDE crap, but you can do "bare metal" yourself quite easily. Half a year or so ago I had another go at it, and made (Yet another) blinking led project. This time I used a bit of help from an online AI to make a makefile for me. It's a nice simple and very readable makefile.

Back then I also bought a hand full of the ST-Link V2 clones. There are small pinout differences on the 10 pin connector, they have different uC's inside (from GD and AMP If I remember well). But the Cube Hogware accepted them and even uploaded the "latest / greatest" ST-Link firmware in to them. But these days, the official ST-Link has been so affordable (< EUR 10) that I would buy those instead. I do want more than one programmer and at least a handful of development boards (working on different projects interchangeably, but also when a uC board gets shorted or otherwise damaged, you can just exchange it and continue.
 

Online Tation

  • Frequent Contributor
  • **
  • Posts: 321
  • Country: pt
Re: Learning STM32
« Reply #6 on: November 25, 2026, 06:43:58 pm »
ST Nucleo boards  include an ST-Link debugger and are cheap. WeAct boards are also nice, although with no included debug interface, but they also offer their Mini.Debugger cards (in 2 flavours: STLink & DAPLink) which are very convenient (including NRST, SWD + SWO and serial in a single connector).

Now you can use Claude for it to setup the tools for you. Need neither STM Cube, nor HAL, nor Eclipse, nor VS Code (although I still use it when really writing code and/or debugging) nor... well, just using  here the system compiler (clang, compiles to any reasonable target, including arm and RISC-V, and comparing the binaries it generates against those compiled with the true and only armclang, they are really similar in both size and speed), also system's cmake/ninja and Claude managed to get the required headers, CMSIS-core (too used to it, so I insist on it), a working openocd/pyocd and the .csv files in case I want to manually debug. Fed the AI with the datasheet+reference manual (and the debugger + target connected to the host)  and ask it to setup the tools, create the scatter file, CMakeLists.txt and blinky.c . Start learning from here. The ~$20€ of a month in Claude will allow you to start  very fast and with much less frustration, avoiding crappy vendor tools and libraries. And, if you really want to use some IDE, also ask Claude to generate the necessary setup for your project to be accepted by such IDE.

 
 

Offline peter-h

  • Super Contributor
  • ***
  • Posts: 6154
  • Country: gb
  • Doing electronics since the 1960s...
Re: Learning STM32
« Reply #7 on: Yesterday at 08:37:00 am »
I don't know why people buy STLINK clones. The real ones cost so little.

Cube IDE is far from perfect but that's true for all development tools, whether free or paid for. I use it all day and it does the job.

I use Claude too. It is a brilliant tool, increasing coding productivity 10x to 100x. For sure it is well able to knock up the entire source code for your requirements. One problem with using Claude from the very start is that if you are new to stm32, you may not understand what it has done. You will have working code allright but will need to use Claude for ever to do anything with it.
« Last Edit: Yesterday at 08:49:23 am by peter-h »
Z80 Z180 Z280 Z8 S8 8031 8051 H8/300 H8/500 80x86 90S1200 32F417
 

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 4659
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: Learning STM32
« Reply #8 on: Yesterday at 08:57:56 am »
You can ask Claude what it has done. It is very helpful in analyzing and tracing code. Try it sometimes. It will find many bugs  :-DD
 

Offline Vinar20122Topic starter

  • Newbie
  • Posts: 3
  • Country: ua
Re: Learning STM32
« Reply #9 on: Yesterday at 10:41:58 am »
I think the best way is to pick a chip which will do the job of some projects you want to build. In 2016 I picked a 32F417 and I still use it, with the 437 giving another 64k RAM and with minimal other changes.

Then get one of the ST development boards, install Cube IDE, and get an LED flashing on and off :)

Then go from there. Once you have some running code, you can build on top of that easily enough.

I've been doing embedded since about 1980. Today is is very different. No assembler, only C. No more reading about details of CPU architecture (the ARM STM32 manual is about 5000 pages!). Even the CPU reference manual is 2000 pages and nobody reads it except for the bit they want to know e.g. the registers of the SPI controller. The CPU data sheet is 300 pages and you do have to read every word if you are going to design a PCB, but normally you base the PCB on the circuit of the ST development PCB :)

Later, you can add blocks to Cube like FreeRTOS, FatFS, whatever...

I chose a chip that can handle everything I need it to do, and even more. It's the STM32F405RGT6. I already have a development board based on this microcontroller and a programmer.

The problem is that I haven't been able to find any resources that explain its architecture. :-//
What's the point of getting an LED to blink if you don't understand what's happening behind the scenes? Practice without understanding doesn't make much sense to me.

In my opinion, to work with STM32, you first need to understand its architecture (the basic chip architecture, things like the processor core at a basic level, GPIO, RCC, AHB/APB1/APB2 buses, etc.) and only then start programming.

Maybe you could suggest how I can understand its architecture? People on the STM32 forum told me to just read the RM and DS :-+. They said almost everything is explained there, and if I have questions, I can ask AI.
« Last Edit: Yesterday at 10:45:50 am by Vinar20122 »
 

Offline peter-h

  • Super Contributor
  • ***
  • Posts: 6154
  • Country: gb
  • Doing electronics since the 1960s...
Re: Learning STM32
« Reply #10 on: Yesterday at 11:13:57 am »
It is a CPU (microprocessor) like any other. It has ROM (FLASH actually, programmed with an SWD debugger usually) and RAM. It fetches instructions from the ROM. Like a Z80 in 1976 :)

But the 32F4 is a microcontroller (MCU) which is a CPU with peripherals and memory, all on the same chip. So you have UARTs, etc. If you read through the data sheet you will see them all described. Individually they are not really complicated.

Well, the ETH and USB subsystems are horribly complicated but you don't need them (unless you need them). Because they are so complicated, STM buy these from Synapsys as blocks.

There is no magic. It is just like what one would have done 30-40 years ago but you would have about a square meter of PCB area for all the required chips :) Or a CPU and a big expensive FPGA (and many happy weeks spent with shitty FPGA design tools).

If you have never programmed microprocessors then you would do just as well learning the Z80. Or some low-end PIC chip (but those have silly limitations).
« Last Edit: Yesterday at 11:15:42 am by peter-h »
Z80 Z180 Z280 Z8 S8 8031 8051 H8/300 H8/500 80x86 90S1200 32F417
 

Offline Vinar20122Topic starter

  • Newbie
  • Posts: 3
  • Country: ua
Re: Learning STM32
« Reply #11 on: Yesterday at 11:29:25 am »
It is a CPU (microprocessor) like any other. It has ROM (FLASH actually, programmed with an SWD debugger usually) and RAM. It fetches instructions from the ROM. Like a Z80 in 1976 :)

But the 32F4 is a microcontroller (MCU) which is a CPU with peripherals and memory, all on the same chip. So you have UARTs, etc. If you read through the data sheet you will see them all described. Individually they are not really complicated.

Well, the ETH and USB subsystems are horribly complicated but you don't need them (unless you need them). Because they are so complicated, STM buy these from Synapsys as blocks.

There is no magic. It is just like what one would have done 30-40 years ago but you would have about a square meter of PCB area for all the required chips :) Or a CPU and a big expensive FPGA (and many happy weeks spent with shitty FPGA design tools).

If you have never programmed microprocessors then you would do just as well learning the Z80. Or some low-end PIC chip (but those have silly limitations).

I understand the difference between a microprocessor and a microcontroller. :)

What I mean is that a microcontroller is a much more complex system than just a processor that executes instructions and performs calculations. There is a lot going on around the CPU, and I want to understand how all these components interact with each other.

I don't just want to learn how to write code that makes the microcontroller do something. I want to understand what's actually happening inside it (at least at a basic level, because I won't get very far otherwise) and what exactly I'm configuring in the IDE.

Perhaps I'm not explaining myself very clearly, but I hope you understand what I mean.  :-//
 

Offline Karel

  • Super Contributor
  • ***
  • Posts: 2553
  • Country: 00
 
The following users thanked this post: Vinar20122

Online Tation

  • Frequent Contributor
  • **
  • Posts: 321
  • Country: pt
Re: Learning STM32
« Reply #13 on: Yesterday at 11:53:32 am »
The problem is that I haven't been able to find any resources that explain its architecture. :-//

Page 20 of the datasheet shows the architecture of the whole chip. Its 3rd chapter describes each unit in 1 or 2 paragraphs. Then the reference manual shows the architecture of each module, explains its workings and describes how to manage it.

If you have a working blinky (or any other example), you can, from the above documentation, ascertain why and how it works, modify its behaviour, test ideas, ...
 

Offline newbrain

  • Super Contributor
  • ***
  • Posts: 1920
  • Country: se
Re: Learning STM32
« Reply #14 on: Yesterday at 12:14:13 pm »
And if you want to dig deeper in the CPU itself and associated peripherals (e.g. NVIC, MPU), there is a lot of Arm technical documentation, specific to the Cortex-M4 (Armv7-M).

Cortex-M4 Technical Reference Manual
Cortex-M4 Processor Datasheet
M4 Generic User Guide
Nandemo wa shiranai wa yo, shitteru koto dake.
 

Offline peter-h

  • Super Contributor
  • ***
  • Posts: 6154
  • Country: gb
  • Doing electronics since the 1960s...
Re: Learning STM32
« Reply #15 on: Yesterday at 03:55:07 pm »
Those arm docs come to about 5000 pages :)

There are reasons why the 168MHz 32F417 I am using is 100x to 1000x faster than a 8MHz Z80 :) And if you use floats you quickly get past the 1000x ratio.
Z80 Z180 Z280 Z8 S8 8031 8051 H8/300 H8/500 80x86 90S1200 32F417
 

Offline mark03

  • Frequent Contributor
  • **
  • Posts: 785
  • Country: us
Re: Learning STM32
« Reply #16 on: Yesterday at 04:38:00 pm »
Viewing all of the peripherals as "magic memory locations," where setting bits does stuff, isn't a bad way to start.  The details of the bus architecture (APBx versus AHB, and so on) don't have to be in the front of your mind, especially on the simpler chips.  These things will sink in slowly as you gain experience.

Studying the "clock tree" diagram in the Reference Manual will help you understand what all of those registers in RCC are doing.

As others have said, AI can be an excellent tutor when you use it carefully.  The dev/build environments promoted by ST are so insanely complex that trying to learn anything can feel overwhelming, even if your actual code is simple.  So I really like the idea, mentioned earlier, of using AI to cut through that crap and put together a "bare bones," makefile-based project.

(Of course, it's still possible to use ST's tooling, e.g. the "STM32Cube for Visual Studio Code", without understanding the guts of the build process, and just focus on your code and what's happening in the chip.  Having the fancy editor, debugger, and Intellisense-style code navigation is really nice.  It's too bad that ST doesn't make it easier to set that up without also using the "Cube" code generators.  With the VSCode extension, you can tell it to set up an empty project, but then it doesn't provide the CMSIS headers and you have to scour the internet for them yourself.)
 

Offline peter-h

  • Super Contributor
  • ***
  • Posts: 6154
  • Country: gb
  • Doing electronics since the 1960s...
Re: Learning STM32
« Reply #17 on: Yesterday at 05:16:16 pm »
The most complicated thing is the clock config.

Cube MX (at its simplest, a pin allocation / config tool) produces a nice diagram of how the clocks are generated and routed. I am not sure if Claude can do the same. It can - just tested it on my project :)
Z80 Z180 Z280 Z8 S8 8031 8051 H8/300 H8/500 80x86 90S1200 32F417
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

- - -
-->