Board

STM32 Blue Pill simulator, F103 and all

Mokxi models the STM32 "Blue Pill" on our own Cortex-M3 core, running the STM32F103 at 72 MHz. GPIO through the F1’s own CRL and CRH registers, TIM1 to TIM4, USART1, a twelve-bit ADC and SysTick use their real addresses. Test finished firmware on the physical board too.

Start building free
  • 8peripheral areas modeled
  • 3projects ready to run
  • Real timeon your own machine
STM32 Blue Pill (F103): blinklive0.000 s 0.00x
Click to open it in the editor
The board is running real firmware right now. Click it to open the circuit in the editor.
The model

What is modeled

Taken from the board's own contract document and put in plain words, with what is missing beside it.

Modeled

Core
Cortex-M3 (ARMv7-M), no DSP extension and no FPU, with the datasheet cycle count of every instruction
GPIO
Ports A to C through CRL and CRH, four bits a pin, with the pull direction in ODR where the F1 keeps it
TIM1 to TIM4
All sixteen bits, up, down and center-aligned, with glitch-free PWM, and TIM1’s MOE and repetition counter
AFIO
The alternate-function remaps in MAPR, and SWJ_CFG, which is what hands PA15, PB3 and PB4 back to your sketch
ADC1
A twelve-bit single conversion on ten pins, timed at the part’s own conversion rate rather than handed back early
USART1
Paced at the configured baud rate, wired to the serial monitor
SysTick and the NVIC
The real priority bits and interrupt lines, so a handler runs the way the datasheet says
Memory map
The real STM32F103C8 addresses for everything above: 64 KB of flash and 20 KB of SRAM, and the link fails if you overrun them

Not modeled

  • DMA, USB, CAN, I2C and SPI. Their registers are unmapped, so touching one is a fault rather than a silent zero.
  • The clock tree. SYSCLK is fixed at 72 MHz from power-on rather than brought up from HSI, HSE and the PLL.
  • The RTC, the backup registers and the watchdogs.
  • Vendor binaries: the STM32Cube HAL, libopencm3 and the STM32duino core. The firmware runtime here is ours.
Start here

Open one and press Run

Each of these opens in the editor exactly as it is drawn here.

Projects

Every built-in project on the Blue Pill

Each has its own page with the circuit running, the code and a parts list.

Libraries

Arduino libraries that compile as they are

Paste a tutorial that includes one of these and it builds. For any other library, the build names the Mokxi header that does the same job.

Servo.h
attach, write, writeMicroseconds, read, detach, on any pin
Wire.h
I2C as a master; Wire.begin() puts it on PB7 (SDA) and PB6 (SCL)
SPI.h
transfer and transactions, on the board’s usual SPI pins
EEPROM.h
read, write, update, get, put and EEPROM[i], kept in 4 KB of RAM, which a reset clears: this board has no EEPROM to write
LiquidCrystal_I2C.h
the 16x2 LCD behind its I2C backpack
Adafruit_GFX.h and Adafruit_SSD1306.h
the 128x64 I2C OLED: text, pixels, lines, rectangles, circles, triangles and bitmaps
DHT.h
the DHT11 and DHT22: temperature, humidity and the heat index, as floats you can print
OneWire.h and DallasTemperature.h
DS18B20 thermometers, any number on one pin, found by the 1-Wire search

And 14 more, 22 in all: Adafruit_BME280.h, Adafruit_BMP280.h and SparkFunBME280.h; RTClib.h; Adafruit_SHT31.h; Adafruit_PCF8591.h; Adafruit_ADXL345_U.h; LedControl.h; Adafruit_LEDBackpack.h; Adafruit_TCS34725.h; Adafruit_SGP30.h; Adafruit_INA219.h; Adafruit_ADS1X15.h; Adafruit_MCP23X17.h; Bounce2.h; HX711.h.

Learn

Tutorials that use this board

Each one ends in a running circuit, on this same board.

Questions

Is it free?

Yes. Every board and every part is on the free plan, with no account needed.

Which STM32?

The STM32F103C8T6 in its 48-pin package, on the board everybody calls the Blue Pill.

How is this different from the Black Pill?

A different generation. The F103 is a Cortex-M3 at 72 MHz with 64 KB of flash, it configures a pin with one four-bit field in CRL or CRH rather than four registers, it takes an input’s pull direction out of ODR, and it has an ADC. Not one peripheral address is shared with the F411.

Why will my sketch not drive PA15, PB3 or PB4?

The debug port holds them out of reset. Write AFIO->MAPR = AFIO_MAPR_SWJ_SW_ONLY once in setup() and they are yours. The model does this exactly as the chip does.

Will my firmware run on a real Blue Pill?

Yes, as long as it does not reach for DMA, USB, CAN, I2C or SPI. The memory map and the register offsets are the real ones.

Try it on your own firmware

What you build here runs on the board on your desk, unchanged. Nothing to install and no account needed.