Source: https://mokxi.com/learn/path/bare-metal-stm32
Updated: 2026-11-20

All paths

# Bare-metal STM32

Under the HAL on an STM32F411 Black Pill: the reference manual and its memory map, RCC and the PLL, GPIO registers, SysTick, a USART driver and timer PWM written by hand, and a cubesat Morse beacon with no driver but your own.

STM32F411 Black Pill Free 7 lessons 7 h 4 chapters 2,885 XP Embedded engineering · Advanced +250 XP

0 of 7 done

Start the course free The reference manual Lesson plan for teachers

What you will build

## 3 projects, built step by step

7 lessons in 4 chapters, about 7 hours on a simulated STM32F411 Black Pill. Free, in your browser, every step checked by the simulator.

Chapter 1 project

### Clocks and RCC

A write to a port with its clock off is lost; the same write after RCC_AHB1ENR sticks. Then the PLL: PLLCFGR worked out for 84 MHz from the Black Pill’s 25 MHz crystal, and the switch to it, bit by bit.
Open it in the simulator

Chapter 2 project

### SysTick

The Cortex-M4’s own 24-bit timer, programmed directly: a reload for a 1 ms tick at 84 MHz, COUNTFLAG polled instead of an interrupt, the longest tick 24 bits allow, and an LED blinked by counting.
Open it in the simulator

Chapter 3 project

### Timer PWM by hand

TIM3 channel 1 on PA6 set up register by register: the prescaler to 1 MHz, ARR for a 1 kHz period, CCR1 for the duty, PWM mode 1 with preload, and a frequency counter checking the result while the LED breathes.
Open it in the simulator

The map

## Chapter by chapter

Each lesson opens when the one before it is done, and each chapter ends in a project.

Chapter 1

## Reading the chip

The reference manual, the memory map and the clock gates.

Open 303 XP

### The reference manual

Every peripheral is a block of addresses. Read registers straight from RM0383’s memory map, find their reset values, watch a port read 0 until its clock is on, and blink the LED through a raw pointer.

0 of 7 steps

Start What is in it

Project Locked 606 XP

### Clocks and RCC

A write to a port with its clock off is lost; the same write after RCC_AHB1ENR sticks. Then the PLL: PLLCFGR worked out for 84 MHz from the Black Pill’s 25 MHz crystal, and the switch to it, bit by bit.

0 of 7 steps

5 questions, graded as you go.

Chapter 2

## Pins and time

GPIO registers and the Cortex-M SysTick.

Locked 303 XP

### GPIO registers

The KEY button on PA0 with its pull-up set in PUPDR, read from IDR, and mirrored onto two LEDs through BSRR: one active low on PC13, one active high on PB12. MODER, PUPDR, IDR and BSRR, bit by bit.

0 of 7 steps

Project Locked 530 XP

### SysTick

The Cortex-M4’s own 24-bit timer, programmed directly: a reload for a 1 ms tick at 84 MHz, COUNTFLAG polled instead of an interrupt, the longest tick 24 bits allow, and an LED blinked by counting.

0 of 6 steps

4 questions, graded as you go.

Chapter 3

## Peripherals by hand

A USART driver and timer PWM, register by register.

Locked 242 XP

### USART by hand

USART1 with no Serial library: PA9 and PA10 to alternate function 7, BRR worked out for 115200 baud at 84 MHz, and bytes sent and received by polling TXE and RXNE. A whole driver in forty lines.

0 of 6 steps

Project Locked 560 XP

### Timer PWM by hand

TIM3 channel 1 on PA6 set up register by register: the prescaler to 1 MHz, ARR for a 1 kHz period, CCR1 for the duty, PWM mode 1 with preload, and a frequency counter checking the result while the LED breathes.

0 of 7 steps

4 questions, graded as you go.

Chapter 4

## Boss project

A driver-free cubesat Morse beacon.

Locked 341 XP

### Boss: a cubesat Morse beacon

A driver-free device: RCC, GPIO, SysTick, USART1 and TIM3 programmed by hand, not one Arduino call. It keys a callsign in Morse as an 800 Hz tone and the LED, and takes a new message from the ground station.

0 of 8 steps

3 questions, graded as you go.

Syllabus

## Every lesson in the course

All 7 lessons, in order, each with what it covers. Any of them opens in the editor right away.

Chapter 1

### Reading the chip

- The reference manual Every peripheral is a block of addresses. Read registers straight from RM0383’s memory map, find their reset values, watch a port read 0 until its clock is on, and blink the LED through a raw pointer.
- Clocks and RCC A write to a port with its clock off is lost; the same write after RCC_AHB1ENR sticks. Then the PLL: PLLCFGR worked out for 84 MHz from the Black Pill’s 25 MHz crystal, and the switch to it, bit by bit.

Chapter 2

### Pins and time

- GPIO registers The KEY button on PA0 with its pull-up set in PUPDR, read from IDR, and mirrored onto two LEDs through BSRR: one active low on PC13, one active high on PB12. MODER, PUPDR, IDR and BSRR, bit by bit.
- SysTick The Cortex-M4’s own 24-bit timer, programmed directly: a reload for a 1 ms tick at 84 MHz, COUNTFLAG polled instead of an interrupt, the longest tick 24 bits allow, and an LED blinked by counting.

Chapter 3

### Peripherals by hand

- USART by hand USART1 with no Serial library: PA9 and PA10 to alternate function 7, BRR worked out for 115200 baud at 84 MHz, and bytes sent and received by polling TXE and RXNE. A whole driver in forty lines.
- Timer PWM by hand TIM3 channel 1 on PA6 set up register by register: the prescaler to 1 MHz, ARR for a 1 kHz period, CCR1 for the duty, PWM mode 1 with preload, and a frequency counter checking the result while the LED breathes.

Chapter 4

### Boss project

- Boss: a cubesat Morse beacon A driver-free device: RCC, GPIO, SysTick, USART1 and TIM3 programmed by hand, not one Arduino call. It keys a callsign in Morse as an 800 Hz tone and the LED, and takes a new message from the ground station.

Kits

## Build it on your bench too

Every lesson runs in the simulator with nothing to buy. When you want the real thing, these kits have the parts.

Have a kit already?

### Find your kit

Pick the starter kit you own and run every lesson in its manual with the same parts on the same pins.
See every kit

Questions

## About Bare-metal STM32

Is Bare-metal STM32 free?

Yes. All 7 lessons of Bare-metal STM32 are free and run in your browser, with nothing to install and no parts to buy before you start.

Do I need a real STM32F411 Black Pill?

No. Every lesson runs on a simulated STM32F411 Black Pill with its parts on the canvas, and the simulator checks each step as you go. When you want to build it for real, the same wiring and code work on a real board.

How long does Bare-metal STM32 take?

About 7 hours: 7 lessons in 4 chapters, each one a few short steps. Your progress is kept, so you can stop after any lesson and pick up where you left off.

What will I build?

Each chapter ends in a project that puts it together: Clocks and RCC, SysTick and Timer PWM by hand.

Where do I start?

With "The reference manual", and each lesson builds on the one before it. New to circuits? Electronics basics is the course that starts from zero.
