Source: https://mokxi.com/teachers/plans/bare-metal-stm32
Updated: 2026-11-19

Lesson plan

# Bare-metal STM32 lesson plan

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.

4 chapters, 7 lessons, about 7 hours, on the STM32F411 Black Pill. Every lesson runs in the browser, with nothing to install.

Start a class from this course

The unit

## Objectives and materials

### By the end, students can

- The reference manual, the memory map and the clock gates.
- GPIO registers and the Cortex-M SysTick.
- A USART driver and timer PWM, register by register.
- A driver-free cubesat Morse beacon.

### Materials for the whole unit

- Frequency counter
- LED x 3
- Piezo speaker
- Pushbutton
- Resistor x 3
- STM32F411 Black Pill

Every part is already on the simulator’s bench, so there is nothing to buy or hand out. The counts are the most any one lesson uses, if you build it on real breadboards too.

Chapter 1. About 2 h

## Reading the chip

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

Lesson | Time | What students do

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. | 60 min

- Registers by address
- A base and an offset
- A port with no clock
- Clock on, reset value back
- Blink through a pointer
- Read port C
- How to read a register page

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. | 60 min

- The lost write
- Open the gate
- Start the crystal
- Configure the PLL
- Switch over
- 96 MHz
- What the model does with clocks

### Materials

- Frequency counter
- LED x 3
- Pushbutton
- Resistor x 3
- STM32F411 Black Pill

### Check for understanding

Each student finishes "Clocks and RCC" on their own, without opening the hints. The simulator checks 7 of its 7 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "What the model does with clocks".

Chapter 2. About 1 h 55 min

## Pins and time

GPIO registers and the Cortex-M SysTick.

Lesson | Time | What students do

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. | 60 min

- A pull-up from a register
- Two bits a pin
- Press KEY
- Active low
- Reading IDR
- Invert it
- Why BSRR

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. | 55 min

- The core’s own timer
- Twenty-four bits
- Count the ticks
- Ticks and toggles
- Polling or interrupt
- Blink faster

### Materials

- Frequency counter
- LED x 3
- Pushbutton
- Resistor x 3
- STM32F411 Black Pill

### Check for understanding

Each student finishes "SysTick" on their own, without opening the hints. The simulator checks 6 of its 6 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Blink faster".

Chapter 3. About 1 h 55 min

## Peripherals by hand

A USART driver and timer PWM, register by register.

Lesson | Time | What students do

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. | 55 min

- A baud rate from a divider
- Send and receive
- Another line
- The pins
- 9600 baud
- What Serial adds

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. | 60 min

- Prescaler and reload
- Measure it
- Mode, preload, enable
- The LED breathes
- The usual mistakes
- 2 kHz
- Resolution and frequency

### Materials

- Frequency counter
- LED x 3
- Pushbutton
- Resistor x 3
- STM32F411 Black Pill

### Check for understanding

Each student finishes "Timer PWM by hand" on their own, without opening the hints. The simulator checks 7 of its 7 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Resolution and frequency".

Chapter 4. About 1 h 10 min

## Boss project

A driver-free cubesat Morse beacon.

Lesson | Time | What students do

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. | 70 min

- Beacon on
- Dits and dahs
- The transmitter
- The light
- Uplink
- On repeat
- Change the tone
- Make it yours

### Materials

- Frequency counter
- LED x 2
- Piezo speaker
- Pushbutton
- Resistor x 2
- STM32F411 Black Pill

### Check for understanding

Each student finishes "Boss: a cubesat Morse beacon" on their own, without opening the hints. The simulator checks 8 of its 8 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Make it yours".

Your class

## Teach this unit as a class

Start a class from this course and its 7 lessons are assigned in one go, in order. Students join with a six-character code or printed login cards, and each one’s work comes back to you.

The class tools are free for 30 days for one class of up to 20 students, with no card. The lessons themselves are free either way.

Start a class from this course See the demo class

More units

## Other lesson plans

Electronics basics 20 lessons, about 10 h. Embedded on the Arduino Uno 16 lessons, about 12 h. Embedded on the ESP32-C3 13 lessons, about 11 h. Embedded on the Raspberry Pi Pico 7 lessons, about 6 h. Build your own fight stick 5 lessons, about 4 h. Embedded on the STM32F411 6 lessons, about 6 h. C++ on a board 13 lessons, about 10 h. Digital logic and memory 4 lessons, about 4 h. Interactive devices on the Uno 9 lessons, about 8 h. From gates to a computer 23 lessons, about 16 h. Build a claw machine 8 lessons, about 6 h. Every unit All the courses as ready-made units, on the teachers page.
