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.
- 8peripheral areas modeled
- 3projects ready to run
- Real timeon your own machine
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.
Open one and press Run
Each of these opens in the editor exactly as it is drawn here.
Every built-in project on the Blue Pill
Each has its own page with the circuit running, the code and a parts list.
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.
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.
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.
The other boards
Every one of these runs today, and every one is free.
Looking for the shorter introduction? See the Blue Pill simulator page.
A RISC-V chip at 160 MHz, on the real memory map.
The classic Arduino, with an ATmega328P running at 16 MHz.
The Uno’s chip on a small board that fits a breadboard.
The big Arduino, with 54 digital pins and four serial ports.
An Uno-shaped board whose chip does its own USB serial.
A second RISC-V board, with 31 pins and simulated WiFi.
The classic ESP32 at 240 MHz, with simulated WiFi.
The ESP32-S3 at 240 MHz, with USB serial and an RGB LED.
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.