STM32 Blue Pill & STM32F103

STM32 Blue Pill & STM32F103
CPU: ARM Cortex-M3Clock: 72 MHzLogic: 3.3V (5V Tolerant)ADCs: 2x 12-bit (1 MSPS)Flash + RAM: 64/128 KB + 20 KBDebug: SWD / ST-Link

What is STM32 Blue Pill & STM32F103?

The STM32 Blue Pill is a legendary, low-cost minimum system development board powered by the STMicroelectronics STM32F103C8T6 32-bit ARM Cortex-M3 microcontroller running at 72 MHz. Long celebrated as the budget gateway into the 32-bit ARM embedded ecosystem, it delivers extraordinary computing performance at AVR prices.

Equipped with 64 KB (often 128 KB) of flash memory, 20 KB of SRAM, two high-speed 12-bit ADCs, USB 2.0 Full-Speed connectivity, and multiple 5V-tolerant I/O pins, the Blue Pill is widely used for industrial automation, real-time motor PID loops, and learning bare-metal register programming with STM32CubeIDE or Arduino.

Technical Specifications

MicrocontrollerSTMicroelectronics STM32F103C8T6 (LQFP-48)
Core ArchitectureARM 32-bit Cortex-M3 with hardware divide/multiply
Clock Frequency72 MHz maximum (via 8 MHz crystal + PLL)
Operating Logic Voltage3.3V (Many digital pins are 5V-tolerant)
Input Voltage (VIN / USB)5V DC via Micro-USB or 4.5V–12V on 5V pin
Flash Memory64 KB (Often 128 KB on C8 chips)
SRAM Memory20 KB high-speed SRAM
Digital GPIO Pins32 GPIOs (Port A, Port B, Port C)
DMA Controller7 Channels (Direct Memory Access for SPI/I2C/ADC)
Analog ADC Channels2x 12-bit ADCs (up to 10 channels, 1 MSPS)
Timers4x 16-bit timers (including motor control PWM timer)
Communication Peripherals2x SPI, 2x I2C, 3x USART, 1x CAN 2.0B, 1x USB 2.0 FS
Debugging InterfaceSerial Wire Debug (SWD) via 4-pin header
Dimensions & Weight53 mm x 22 mm (8 g)

Recommended Applications & Industry Uses

⚙️

High-Speed Motor & Inverter Control

Advanced timer 1 generates complementary 3-phase PWM signals with programmable dead-time insertion for brushless DC (BLDC) motor drivers.

🚗

Automotive & CAN Bus Nodes

Built-in CAN 2.0B active controller interfaces directly with vehicle onboard diagnostics (OBD-II) networks and automotive telemetry.

🎹

USB Audio & MIDI Devices

Native USB 2.0 Full-Speed device controller enables low-latency USB MIDI keyboards, synthesized tone generators, and custom HID devices.

🔬

High-Precision Oscilloscopes & DAQs

Dual 12-bit 1 MSPS ADCs paired with circular DMA buffers sample analog signals at high frequencies without consuming CPU execution cycles.

Key Features & Architectural Highlights

⚡

ARM Cortex-M3 Processing

72 MHz 32-bit

Includes hardware integer multiplication and hardware division. Computes math and digital filtering algorithms up to 10x faster than traditional 8-bit AVR microcontrollers.

🛡️

5V-Tolerant GPIO Lines

5V Tolerant

Unlike most 3.3V microcontrollers, many pins on the STM32F103 (marked FT) safely accept 5V digital logic inputs, protecting the board when interfacing with legacy sensors.

📊

High-Precision 12-bit ADCs

Dual 12-bit 1Msps

Two independent 12-bit analog-to-digital converters deliver 4096 discrete resolution steps with ultra-fast 1 million samples per second sampling rates.

🔧

Single-Wire Debug Interface

SWD Hardware Debug

Step through C/C++ firmware line-by-line, set live watch variables, and monitor memory using an inexpensive ST-Link V2 dongle and GDB.

⏱️

Motor Control PWM Timers

Advanced Timers

Advanced-control timer (TIM1) features complementary PWM outputs and dead-time insertion, engineered specifically for 3-phase BLDC motor inverter bridges.

🚗

Automotive CAN Bus Native

CAN 2.0B Bus

Integrated hardware CAN 2.0B active controller capable of transmitting and receiving automotive telemetry frames up to 1 Mbps.

Pin Configuration & Peripheral Layout

Digital GPIO Pins (PA0 - PB15, PC13 - PC15)

37 GPIO pins operating at 3.3V logic. Most pins accept up to 5V inputs without damage.

  • Pins marked FT (Five-volt Tolerant) include PA8–PA15, PB3, PB4, PB6–PB9, PB12–PB15
  • Pin PC13 connects to the onboard green/blue user LED (active LOW)
  • Pins PA9 and PA10 serve as the primary USART1 serial programming interface

Dual 12-bit ADCs (ADC1 & ADC2)

10 external analog channels capable of synchronized dual-ADC simultaneous conversions.

  • Channels ADC0 to ADC9 located on pins PA0 through PA7 and PB0, PB1
  • Full 12-bit conversion delivers 0–4095 digital counts across 0V to 3.3V
  • Direct connection to multi-channel DMA for autonomous analog sensor streaming

Hardware Communication & Debug

Multi-channel serial controllers, automotive CAN bus, and debug ports.

  • 3 hardware USARTs, 2 SPI interfaces (up to 18 MHz), and 2 I2C interfaces (up to 400 kHz)
  • Hardware CAN 2.0B bus on pins PB8 (RX) and PB9 (TX)
  • SWD header pins: PA13 (SWDIO) and PA14 (SWCLK) for ST-Link programming

Communication Protocols

Hardware USART (x3)

PA9/PA10, PA2/PA3, PB10/PB11

Three independent serial ports supporting baud rates up to 4.5 Mbps with hardware RTS/CTS flow control.

Hardware SPI (x2)

SPI1 (18 MHz) & SPI2 (9 MHz)

High-speed SPI buses with DMA support for driving graphical LCD screens, high-speed ADCs, and SD cards.

Hardware I2C (x2)

I2C1 (PB6/PB7) & I2C2 (PB10/PB11)

Dual I2C buses supporting Standard and Fast (400 kHz) modes with SMBus and PMBus protocol compliance.

CAN 2.0B Controller

PB8 (CAN_RX) & PB9 (CAN_TX)

Automotive Controller Area Network peripheral with 14 filter banks, supporting 11-bit standard and 29-bit extended frames.

USB 2.0 Full Speed

PA11 (USB D-) & PA12 (USB D+)

12 Mbps on-chip USB peripheral for emulating virtual COM ports, USB MIDI keyboards, or mass storage devices.

SWD Debug Port

PA13 (SWDIO) & PA14 (SWCLK)

Two-pin ARM Serial Wire Debug protocol interface providing full hardware breakpoints and register stepping.

Advanced Topics & Expert Knowledge

🔧

ST-Link V2 SWD Flashing Workflow

Connect 4 wires (3.3V, GND, SWDIO, SWCLK) from an ST-Link V2 programmer to the Blue Pill header. Flash firmware instantly in VS Code or STM32CubeProgrammer.

st-flash write firmware.bin 0x8000000

Pro tip: SWD flashing bypasses the USB bootloader completely and allows setting live hardware breakpoints in GDB.

⚡

7-Channel Direct Memory Access (DMA)

Stream ADC conversions or UART buffers directly into SRAM without any CPU execution intervention using the 7-channel DMA controller.

HAL_ADC_Start_DMA(&hadc1, (uint32_t*)adc_buffer, 8);

Pro tip: Using DMA with ADC eliminates sampling jitter and frees 100% of CPU cycles for real-time control algorithms.

🔌

The USB R10 Pull-Up Resistor Mod

Many budget clone Blue Pill boards feature an incorrect 10kΩ or 4.7kΩ pull-up resistor on the USB D+ line (R10) instead of the required 1.5kΩ resistor.

// Solder a 1.8k resistor across PA12 (D+) and 3.3V

Pro tip: If your computer fails to recognize the Blue Pill USB device, replace R10 or solder a 1.5k–1.8k resistor between PA12 and 3.3V.

⚙️

Nested Vectored Interrupt Controller (NVIC)

The Cortex-M3 NVIC supports 16 programmable priority levels and sub-priorities, delivering ultra-low interrupt latency down to 12 clock cycles.

HAL_NVIC_SetPriority(EXTI0_IRQn, 2, 0); HAL_NVIC_EnableIRQ(EXTI0_IRQn);

Pro tip: Higher priority interrupts can preempt lower priority ISRs, guaranteeing deterministic timing for motor shutoffs.

🚗

Automotive CAN Bus Interfacing

Pair the Blue Pill’s onboard CAN controller with an inexpensive MCP2551 or TJA1050 5V transceiver to read vehicle OBD-II diagnostics frames.

HAL_CAN_AddTxMessage(&hcan, &tx_header, tx_data, &tx_mailbox);

Pro tip: Remember to terminate both ends of the CAN bus with 120Ω resistors between CAN-H and CAN-L.

📁

128 KB Undocumented Flash Bonus

Although labeled as STM32F103C8 (rated for 64 KB), the overwhelming majority of genuine ST silicon contains 128 KB of working physical Flash memory.

# STM32CubeIDE linker script: FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 128K

Pro tip: You can safely modify your linker script from 64K to 128K on almost all Blue Pill boards.

Recommended Applications & Industry Uses

⚙️

High-Speed Motor & Inverter Control

Advanced timer 1 generates complementary 3-phase PWM signals with programmable dead-time insertion for brushless DC (BLDC) motor drivers.

🚗

Automotive & CAN Bus Nodes

Built-in CAN 2.0B active controller interfaces directly with vehicle onboard diagnostics (OBD-II) networks and automotive telemetry.

🎹

USB Audio & MIDI Devices

Native USB 2.0 Full-Speed device controller enables low-latency USB MIDI keyboards, synthesized tone generators, and custom HID devices.

🔬

High-Precision Oscilloscopes & DAQs

Dual 12-bit 1 MSPS ADCs paired with circular DMA buffers sample analog signals at high frequencies without consuming CPU execution cycles.

Programming on STM32 Blue Pill & STM32F103

⚡ Arduino C++ (STM32duino): Fast Multi-ADC Sampling
// STM32 Blue Pill - Multi-channel 12-bit ADC Reading
const int sensorPin1 = PA0;
const int sensorPin2 = PA1;
const int ledPin = PC13; // Onboard LED (Active LOW)

void setup() {
  Serial.begin(115200);
  pinMode(ledPin, OUTPUT);
  
  // Set 12-bit ADC resolution (0 - 4095)
  analogReadResolution(12);
  Serial.println("STM32 Blue Pill 12-bit ADC Ready");
}

void loop() {
  int raw1 = analogRead(sensorPin1);
  int raw2 = analogRead(sensorPin2);

  float volt1 = raw1 * (3.3 / 4095.0);
  float volt2 = raw2 * (3.3 / 4095.0);

  Serial.printf("PA0: %d (%.3fV) | PA1: %d (%.3fV)\n", raw1, volt1, raw2, volt2);

  digitalWrite(ledPin, LOW);  // Turn ON LED
  delay(100);
  digitalWrite(ledPin, HIGH); // Turn OFF LED
  delay(900);
}
⚙️ Bare-Metal CMSIS: Direct Register GPIO Toggle
// STM32F103 - Direct Register Access Blink (Zero HAL Overhead)
#include "stm32f10x.h"

void delay_cycles(volatile uint32_t count) {
  while (count--) { __NOP(); }
}

int main(void) {
  // 1. Enable GPIOC clock in RCC APB2ENR register
  RCC->APB2ENR |= RCC_APB2ENR_IOPCEN;

  // 2. Configure PC13 as Output Push-Pull @ 2 MHz
  GPIOC->CRH &= ~(0xF << 20); // Clear CNF13 & MODE13
  GPIOC->CRH |= (0x2 << 20);  // Output 2MHz, Push-Pull

  while (1) {
    GPIOC->BSRR = (1 << 13);  // Turn OFF PC13 LED (Active LOW)
    delay_cycles(1000000);
    GPIOC->BRR  = (1 << 13);  // Turn ON PC13 LED
    delay_cycles(1000000);
  }
}

📚 Official Citations & Technical References

To ensure the absolute accuracy and reliability of this guide, all specifications, pinouts, and register settings have been cross-verified with official manufacturer documentation:

Related Resources

Basic Projects

Build beginner-friendly microcontroller projects

Sensor Guides

Learn about ultrasonic, temperature, and motion sensors

Electronics Tools

Use our free circuit calculators

Embedded Roadmap

Follow a structured learning path

Frequently Asked Questions

Why does my computer not detect the Blue Pill via the USB port?

Most clone Blue Pill boards do not come with a USB bootloader installed from the factory and feature an incorrect pull-up resistor on R10 (D+). Program the board using an ST-Link V2 programmer or a USB-to-UART converter on pins PA9/PA10.

Which pins on the STM32 Blue Pill are 5V tolerant?

Pins marked "FT" (Five-volt Tolerant) in the ST datasheet safely accept 5V digital logic inputs. These include PA8 through PA15, PB3, PB4, PB6 through PB9, and PB12 through PB15. Analog pins (PA0–PA7, PB0, PB1) are strictly 3.3V maximum.

What are the BOOT0 and BOOT1 jumpers used for?

The jumpers select the chip boot mode: (BOOT0=0, BOOT1=0) boots from User Flash memory (normal running mode). (BOOT0=1, BOOT1=0) activates the built-in factory ROM serial bootloader on USART1 (PA9/PA10). (BOOT0=1, BOOT1=1) boots from internal SRAM.