Lesson plan

Embedded on the STM32F411 lesson plan

A Cortex-M4 at 84 MHz, where a pin is a port and a number and every peripheral starts with its clock switched off.

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

The unit

Objectives and materials

By the end, students can

  • Active low wiring, a button, and what one line of Arduino is hiding.
  • Six pins on one port, and a timer that holds a brightness for you.
  • USART1 both ways, then a blank page and six lamps.

Materials for the whole unit

  • Full-size breadboard
  • LED x 6
  • Pushbutton
  • Resistor x 6
  • 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

The board

Active low wiring, a button, and what one line of Arduino is hiding.

LessonTimeWhat students do
The LED that is on when the pin is lowThe Black Pill wires its LED between the rail and the pin, so the pin has to go low to light it. Active low, and why so much hardware is built that way.60 min
  1. Wired the other way around
  2. Run it
  3. The lamp you wired
  4. Catch it low
  5. Blink it faster
  6. What one line of Arduino is hiding
Reading a pinA button on PB0 with the pull-up on, lighting an active low lamp. Two inversions in one circuit, and how to stop them confusing you.60 min
  1. Two inversions at once
  2. Watch the input
  3. And the output
  4. And the lamp
  5. Turn it round
  6. What EXTI would give you

Materials

  • LED
  • Pushbutton
  • Resistor
  • STM32F411 Black Pill

Check for understanding

Each student finishes "Reading a pin" 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: "What EXTI would give you".

Chapter 2. About 2 h

Ports and timers

Six pins on one port, and a timer that holds a brightness for you.

LessonTimeWhat students do
Six pins on one portA dot along PA1 to PA6, from an array of pin numbers. What a port is, and why six pins on the same one can be written in a single instruction.60 min
  1. A pin is a port and a number
  2. Run it
  3. All the way along
  4. Watch a pin in the middle
  5. Slow it down
  6. What a pin can be instead
PWM from a timerPA0 is TIM5 channel 1, and once it is set up the hardware holds the brightness on its own. Prescaler, reload, and the compare value.60 min
  1. The three numbers behind analogWrite
  2. Run it and watch it breathe
  3. What the core is doing meanwhile
  4. What 0 and 255 really do
  5. Make the breath faster
  6. Where else a timer goes

Materials

  • Full-size breadboard
  • LED x 6
  • Resistor x 6
  • STM32F411 Black Pill

Check for understanding

Each student finishes "PWM from a timer" 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: "Where else a timer goes".

Chapter 3. About 2 h

Talking, and making it yours

USART1 both ways, then a blank page and six lamps.

LessonTimeWhat students do
The board talks and listensUSART1 on PA9 and PA10, the monitor, and an echo driven from a receive interrupt. What printing costs and why the receive side is different.60 min
  1. Nothing is wired, and that is the circuit
  2. Say hello
  3. A floating point unit, left unused
  4. The uptime, from SysTick
  5. Type something
  6. What printing costs
Project: make the sweep yoursSix lamps and a blank page. Rewrite the sweep around the clock, count what it does, and measure how long your own loop takes.60 min
  1. What you have to work with
  2. Take the delays out
  3. Add the thing it could not do before
  4. Change the pattern
  5. Measure yourself
  6. What you would reach for next

Materials

  • Full-size breadboard
  • LED x 6
  • Resistor x 6
  • STM32F411 Black Pill

Check for understanding

Each student finishes "Project: make the sweep yours" 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: "What you would reach for next".

Your class

Teach this unit as a class

Start a class from this course and its 6 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.