Microcontroller Firmware from Scratch

Nikolai Kondrashov

spbnick

Obligatory Workbench Photo

Our development kit

TTL serial cable

~1.2โ‚ฌ on eBay*

STM32F103C8T6 devboard

~2โ‚ฌ on eBay*

* with delivery, no affiliation

What can you do with it?

โ€” or rather what have I managed?

๐Ÿ“„ย frankencar

๐Ÿ“„ย stm32-eeprom-dump

๐Ÿ“„ย christmas-card

๐Ÿ“„ย thermal-spectrumย (outdated, in progress)

You'll still need one library

๐Ÿ“• ARM-TRM

๐Ÿ“• STM-PM

๐Ÿ“• STM-RM

๐Ÿ“• STM-DS

๐Ÿ“• ARM-ARM

๐Ÿ“• BD

Blue Pill documentation stack

Don't Fear The Docs!

They're your friends!

STM32F103C8T6 MCU

Micro USB socket

Boot configuration jumpers

Reset button

8MHz crystal

32.768KHz crystal

Power LED

User LED

SWD header

The "Blue Pill"

๐Ÿ“• STM-DS

How to get your program in there?

๐Ÿ“• STM-RM

๐Ÿ“• STM-DS

๐Ÿ“• BD

๐Ÿ“• STM-DB

VCC

RX

TX

GND

RX

TX

GND

VCC

Embedded engineers have a secret

Embedded is easy and fun

* unless you're paid to do it

ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  *

Blink the LED!

LED light, D2 programmable

โ€”ย Google Translate

๐Ÿ“• BD

๐Ÿ“• STM-DS

๐Ÿ“• STM-DS

๐Ÿ“„ย blink.c

The Vector Table

๐Ÿ“• ARM-ARM

๐Ÿ“• ARM-ARM

๐Ÿ“• STM-PM

๐Ÿ“„ย blink.c

๐Ÿ“• ARM-ARM

๐Ÿ“• STM-PM

๐Ÿ“• STM-DS

๐Ÿ“• STM-DS

๐Ÿ“„ย blink.ld

๐Ÿ“„ย blink.c

Peripherals and Clocks

๐Ÿ“• STM-DS

๐Ÿ“• STM-RM

๐Ÿ“• STM-RM

๐Ÿ“• STM-RM

๐Ÿ“• STM-RM

๐Ÿ“• STM-RM

๐Ÿ“• STM-RM

๐Ÿ“• STM-RM

๐Ÿ“• STM-DS

๐Ÿ“„ย blink.c

GPIO

๐Ÿ“• STM-RM

๐Ÿ“• STM-RM

๐Ÿ“• STM-RM

๐Ÿ“• STM-RM

๐Ÿ“• STM-RM

๐Ÿ“• STM-DS

๐Ÿ“„ย blink.c

๐Ÿ“• STM-RM

๐Ÿ“„ย blink.c

Build

0x20000400

0x08000008 | 0x1

Flash

Run!

๐Ÿ“• BD

Defaults will get you far!

Make a Library

๐Ÿ“„ย libstammer/gpio.h

๐Ÿ“„ย libstammer/rcc.h

Accelerate!

๐Ÿ“• STM-RM

๐Ÿ“• STM-RM

๐Ÿ“• STM-RM

๐Ÿ“„ย libstammer/init.c

More peripherals!

USART

๐Ÿ“• STM-RM

๐Ÿ“• STM-RM

๐Ÿ“„ untested extract ofย stm32-poke/usart_hello.c

Timers/PWM

๐Ÿ“• STM-RM

๐Ÿ“„ untested extract ofย stm32-poke/pwm_blink.c

ADC

๐Ÿ“• STM-RM

๐Ÿ“„ untested extract ofย stm32-poke/adc_stream.c

SPI

๐Ÿ“• STM-RM

๐Ÿ“„ untested extract ofย stm32-poke/spi_leds.c

Go and experiment!

Give me some feedback, ask questions!

spbnick@gmail.com

Thank You!

PDF and HTML icons made by Dimitry Miroliubov from www.flaticon.com

Credits

Some Blue Pill board photos by user Marekic from wiki.stm32duino.com

Talk and slides by

Nikolai Kondrashov (spbnick)

Chip icon made by Eucalyp from www.flaticon.comย licensed under CC 3.0 BY

A fragment from "Parachuting Cats" advertisement by Folksam

Made with Slides.com