Introduction: what you will learn
This course teaches you to program STM32 microcontrollers with STM32CubeMX and the HAL library: you blink an LED, read a button, and then use interrupts, timers, PWM and UART. Chapter 7 then looks under the hood: the documents ST publishes and what is inside the chip. You work on an STM32 board; the lessons show the NUCLEO-F401RE, and you can adapt them to any STM32 board.
Two ways to program an STM32
With the HAL, you set things up in CubeMX, press Generate, and the code works. That is quick, but when something breaks it helps to know what happens underneath.
- STM32CubeMX and the HAL API (Hardware Abstraction Layer): you pick pins and settings in a window, CubeMX writes the setup code, and you call ready-made HAL functions. This is what these lessons use.
- Registers (CMSIS): you write to the chip's hardware registers yourself. CMSIS is ARM's standard set of header files that gives every register a name. Chapter 7 explains the chip and its documents, which you need before register programming; the full course also has the previous edition's register lessons, which we are remaking in this format.
Why STM32
Every STM32 has an ARM Cortex-M core, a very common core in embedded products: drones, robots, cars, medical and industrial devices. The chips have many peripherals, detailed documentation, and the tools are free (STM32CubeMX and STM32CubeIDE).
The board
We use an STM32 board. The lessons show the NUCLEO-F401RE, built around the STM32F401RE: it connects to your computer with one USB cable and has an ST-LINK debugger on board, so you can flash and debug without extra hardware. Its green LED (on pin PA5) and blue button (on pin PC13) are all we need for the first chapters. You are welcome to use any STM32 board you prefer.
The course adapts to any STM32 board: the steps and HAL functions are the same; only pin names, clock settings and some timers differ. Tell me your board under a lesson and I'll help you adapt it.
A note on AI
AI tools can write code, but they cannot tell you if that code is right. For that you need the basics. The engineers who use AI well are the ones who can read its output, catch its mistakes and fix them. This course builds that base.