STM32F103C8T6 Blue Pill

STM32 Blue Pill

The "Blue Pill": an STM32F103C8 (Cortex-M3, 72 MHz) on a breadboard stick, with a micro-USB connector, an SWD header and the BOOT0 and BOOT1 jumpers.

EmbassyDatasheet
STM32 Blue PillSTM32F103C8 · Cortex-M3 · 72 MHz · 20 KB · bare metalSTM32F103C812345678910111can0 CANbxCAN, remapped to PB8/PB9 (add a transceiver)· tx PB9, rx PB82usb USBMicro-USB (PA11, PA12)3swd jtagSWD header (SWDIO PA13, SWCLK PA14)4pwr Power5 V USB, or 3.3 V on a 3.3 pin5v3v3 Power3.3 pins (the board's regulator)6v5 Power5V pin (from USB)7gnd PowerGND8uart1 UARTUSART1 (A9, A10) · tx PA9, rx PA109uart2 UARTUSART2 (A2, A3) · tx PA2, rx PA310i2c1 I²CI2C1 (B7, B6) · sda PB7, scl PB611spi1 SPISPI1 (A5, A7, A6, A4) · sck PA5, mosi PA7, misoPA6, cs PA433 GPIO pins, each a port (led, …)

In short

A cheap STM32 stick: an STM32F103C8 (one 72 MHz Cortex-M3), 64 KB flash, 20 KB SRAM, 3.3 V pins (most take 5 V). Program it through SWD (an ST-LINK). bxCAN on PB8/PB9 needs a transceiver.

Clock72 MHz
Flash64 KB
RAM20 KB
GPIO33
Logic3.3 V

Specs

From the board’s model in the store.

Processor
STM32F103C8 · 1× Cortex-M3 · chip "stm32f103c8"
Clock
72 MHz
Flash
64 KB
RAM
20 KB
GPIO pins
33
ADC
ADC1 10 ch 12-bit, ADC2 10 ch 12-bit
Logic level
3.3 V
Power
5 V USB, or 3.3 V on a 3.3 pin (in); 3.3 pins (the board's regulator): 3.3 V (≤ 150 mA); 5V pin (from USB): 5 V (≤ 500 mA)
Current per pin
20 mA
Buses
UART ×3, I²C ×2, SPI ×2, CAN ×1, USB ×1
Runs
bare metal (no OS)

Pin map

Each pin by what it does. Hover or tap a pin to see what else it can be.

  • Power 3
  • Ground 1
  • Digital 12
  • Analog 2
  • Bus 16
  • Control 5
  • PA0A0
  • PA1A1
  • PA2A2
  • PA3A3
  • PA4A4
  • PA5A5
  • PA6A6
  • PA7A7
  • PA8A8
  • PA9A9
  • PA10A10
  • PA11A11
  • PA12A12
  • PA15A15
  • PB0B0
  • PB1B1
  • PB3B3
  • PB4B4
  • PB5B5
  • PB6B6
  • PB7B7
  • PB8B8
  • PB9B9
  • PB10B10
  • PB11B11
  • PB12B12
  • PB13B13
  • PB14B14
  • PB15B15
  • PC13C13 (LED)
  • PC14C14
  • PC15C15
  • PA13PA13
  • PA14PA14
  • PB2PB2
  • pwr5 V USB, or 3.3 V on a 3.3 pin
  • v3v33.3 pins (the board's regulator)
  • v55V pin (from USB)
  • gndGND

Watch out

What archec checks for this board, from its data. Each one names the check that catches it.

  • Its pins work at 3.3 V. A 5 V sensor’s output on one of them needs a level shifter between them.

    check pin-level

  • One pin gives at most 20 mA. An LED needs a resistor; a motor or a relay needs a driver.

    check pin-current

  • Two of the board’s connectors share these pins: PB9 (bxCAN, remapped to PB8/PB9 (add a transceiver) / B9), PB8 (bxCAN, remapped to PB8/PB9 (add a transceiver) / B8), PC13 (LED (PC13, on when low) / C13 (LED)), PA9 (USART1 (A9, A10) / A9), PA10 (USART1 (A9, A10) / A10), PA2 (USART2 (A2, A3) / A2), PA3 (USART2 (A2, A3) / A3), PB7 (I2C1 (B7, B6) / B7), PB6 (I2C1 (B7, B6) / B6), PA5 (SPI1 (A5, A7, A6, A4) / A5), PA7 (SPI1 (A5, A7, A6, A4) / A7), PA6 (SPI1 (A5, A7, A6, A4) / A6), PA4 (SPI1 (A5, A7, A6, A4) / A4). Use one or the other.

    check pin-conflict

  • The board already uses PC13 (LED (PC13, on when low)), PA0 (A0), PA1 (A1), PA2 (A2), PA3 (A3), PA4 (A4), PA5 (A5), PA6 (A6), PA7 (A7), PA8 (A8), PA9 (A9), PA10 (A10), PA11 (A11), PA12 (A12), PA15 (A15), PB0 (B0), PB1 (B1), PB3 (B3), PB4 (B4), PB5 (B5), PB6 (B6), PB7 (B7), PB8 (B8), PB9 (B9), PB10 (B10), PB11 (B11), PB12 (B12), PB13 (B13), PB14 (B14), PB15 (B15), PC13 (C13 (LED)), PC14 (C14), PC15 (C15). Something else wired there fights with it.

    check pin-conflict

  • The 3.3 pins (the board's regulator) gives at most 150 mA at 3.3 V. Add up what you power from it.

    check board-current

  • The 5V pin (from USB) gives at most 500 mA at 5 V. Add up what you power from it.

    check board-current

  • It gives 3.3 V (3.3 pins (the board's regulator)), 5 V (5V pin (from USB)). Power each part from a rail at its own voltage.

    check board-supply

  • It has 3 UART, 2 I²C, 2 SPI, 1 CAN. One more bus of a kind than that is an error.

    check board-peripheral

  • Each bus goes on the pins that can carry it (see the pin map). Another pin is an error.

    check pin-function

First model

A blink for this board: the board, an LED and a part that turns it over every 500 ms. archec checks it, then writes the code on the right.

main.archeOpen in the playground
project Blink "Blink" {
  version "0.1.0"
  edition "1.0"
  uses arche-hw-store "^0.1"
}

include "arche-hw-store/boards/stm32-bluepill/stm32-bluepill.arche"
include "arche-hw-store/devices/led/led.arche"

/// Turns the LED over at each step.
component Blinker "Blinker" {
  out led: requires Led
  fn blink "Blink" {
    ```arche
    led.toggle()
    ```
    wcet 50us
  }
}

/// The board, an LED on the board's LED (PC13, on when low) (PC13), and the blinker.
system Hw "Blink" {
  part board:   Stm32BluePill
  part led:     GpioLed { in pin { pins { pin PC13 } } }
  part blinker: Blinker
  blinker.led -> led.led
}

/// The firmware: the blinker every 500 ms.
deployment OnBoard "On the board" {
  system Hw
  platform Hw
  binary blink on board {
    thread main "Blink" { runs blinker; period 500ms; step blink }
  }
}
archec gen --target embassyblink/src/app/blinker.rs
//! Your code: the state and behaviour of this part. Write it between the USER CODE markers:
//! when the model changes, `archec gen` writes this file again around them (a new function, a
//! new input) and keeps them. Edit outside them and the file is yours: it is left as it is,
//! and the compiler says what to add (a new trait method).

#[allow(unused_imports)]
use crate::arche::*;

// @arche blinker main.arche:25 part
/// blinker
#[derive(Default)]
pub struct Blinker {}

impl BlinkerBehaviour for Blinker {
    // @arche blinker.blink main.arche:13 fn
    async fn blink(&mut self, _out: &BlinkerOut) {
        // Blink: from the model (```arche)
        _out.call_led_toggle().await;
    }
}

blink/src/app/blinker.rs, one of the 14 files archec writes.

Open in the playground

Parts on the board

What each numbered part is. Click a number to find it on the board.

1 2 3 4 5 6 7 8 9 10 11 12

Find the part

The quiz names a part: click it on the board. A first try scores a point.

Compare every board