Blue Pill (STM32F103C8) pinout
The Blue Pill (STM32F103C8) (STM32F103C8) pinout: what each pin does, from GPIO, analog inputs and PWM to UART, I2C and SPI, with the notes that catch people…
The board
- Microcontroller: STM32F103C8T6, 32-bit Arm Cortex-M3
- Clock: 72 MHz (the 8 MHz crystal × 9 through the PLL)
- Flash / SRAM: 64 KB / 20 KB
- Logic level: 3.3 V; the pins marked 5 V tolerant take 5 V signals
- Analog inputs: 10 channels (PA0–PA7, PB0, PB1), 12-bit
- PWM: Timer channels TIM1–TIM4: 1 kHz by default
- Serial: USART1 on PA9/PA10 (Serial); USART2 on PA2/PA3; USART3 on PB10/PB11
- I2C: I2C1: SDA PB7, SCL PB6 (Wire); I2C2: SDA PB11, SCL PB10
- SPI: SPI1: SCK PA5, MISO PA6, MOSI PA7, NSS PA4; SPI2 on PB12–PB15
- External interrupts: Any pin: EXTI line n takes pin n of one port
- On-board LED: PC13 (LED_BUILTIN), lit LOW
Pins
| Pin | Functions | Notes |
|---|---|---|
| B12 | PB12, EXTI12, SPI2 NSS | SPI2 chip select. External interrupt on EXTI line 12: attachInterrupt(digitalPinToInterrupt(PB12), handler, mode). 5 V tolerant (FT): a 5 V input is safe. |
| B13 | PB13, EXTI13, SPI2 SCK, TIM1_CH1N, ~PWM | SPI2 clock. analogWrite() PWM from TIM1_CH1N, 1 kHz by default (analogWriteFrequency()). External interrupt on EXTI line 13: attachInterrupt(digitalPinToInterrupt(PB13), handler, mode). 5 V tolerant (FT): a 5 V input is safe. |
| B14 | PB14, EXTI14, SPI2 MISO, TIM1_CH2N, ~PWM | SPI2 data in. analogWrite() PWM from TIM1_CH2N, 1 kHz by default (analogWriteFrequency()). External interrupt on EXTI line 14: attachInterrupt(digitalPinToInterrupt(PB14), handler, mode). 5 V tolerant (FT): a 5 V input is safe. |
| B15 | PB15, EXTI15, SPI2 MOSI, TIM1_CH3N, ~PWM | SPI2 data out. analogWrite() PWM from TIM1_CH3N, 1 kHz by default (analogWriteFrequency()). External interrupt on EXTI line 15: attachInterrupt(digitalPinToInterrupt(PB15), handler, mode). 5 V tolerant (FT): a 5 V input is safe. |
| A8 | PA8, EXTI8, TIM1_CH1, MCO, ~PWM | analogWrite() PWM from TIM1_CH1, 1 kHz by default (analogWriteFrequency()). Can output a clock (MCO). External interrupt on EXTI line 8: attachInterrupt(digitalPinToInterrupt(PA8), handler, mode). 5 V tolerant (FT): a 5 V input is safe. |
| A9 | PA9, EXTI9, USART1 TX, TIM1_CH2, ~PWM | USART1 transmit: Serial, which the Serial Monitor shows. analogWrite() PWM from TIM1_CH2, 1 kHz by default (analogWriteFrequency()). External interrupt on EXTI line 9: attachInterrupt(digitalPinToInterrupt(PA9), handler, mode). 5 V tolerant (FT): a 5 V input is safe. |
| A10 | PA10, EXTI10, USART1 RX, TIM1_CH3, ~PWM | USART1 receive: what the Serial Monitor sends. analogWrite() PWM from TIM1_CH3, 1 kHz by default (analogWriteFrequency()). External interrupt on EXTI line 10: attachInterrupt(digitalPinToInterrupt(PA10), handler, mode). 5 V tolerant (FT): a 5 V input is safe. |
| A11 | PA11, EXTI11, TIM1_CH4, USB D-, ~PWM | analogWrite() PWM from TIM1_CH4, 1 kHz by default (analogWriteFrequency()). USB D- (with usb=none, as the simulator builds, a plain GPIO). External interrupt on EXTI line 11: attachInterrupt(digitalPinToInterrupt(PA11), handler, mode). 5 V tolerant (FT): a 5 V input is safe. |
| A12 | PA12, EXTI12, USB D+ | USB D+, pulled up by a resistor on the board (1.5 kΩ on a good one). External interrupt on EXTI line 12: attachInterrupt(digitalPinToInterrupt(PA12), handler, mode). 5 V tolerant (FT): a 5 V input is safe. |
| A15 | PA15, EXTI15, JTDI, TIM2_CH1, ~PWM | JTAG at reset: a GPIO once JTAG is off (the core turns it off when the sketch uses the pin). analogWrite() PWM from TIM2_CH1 (remapped by AFIO, which the core does for you), 1 kHz by default (analogWriteFrequency()). External interrupt on EXTI line 15: attachInterrupt(digitalPinToInterrupt(PA15), handler, mode). 5 V tolerant (FT): a 5 V input is safe. |
| B3 | PB3, EXTI3, JTDO, TIM2_CH2, ~PWM | JTAG at reset: a GPIO once JTAG is off. analogWrite() PWM from TIM2_CH2 (remapped by AFIO, which the core does for you), 1 kHz by default (analogWriteFrequency()). External interrupt on EXTI line 3: attachInterrupt(digitalPinToInterrupt(PB3), handler, mode). 5 V tolerant (FT): a 5 V input is safe. |
| B4 | PB4, EXTI4, NJTRST, TIM3_CH1, ~PWM | JTAG at reset: a GPIO once JTAG is off. analogWrite() PWM from TIM3_CH1 (remapped by AFIO, which the core does for you), 1 kHz by default (analogWriteFrequency()). External interrupt on EXTI line 4: attachInterrupt(digitalPinToInterrupt(PB4), handler, mode). 5 V tolerant (FT): a 5 V input is safe. |
| B5 | PB5, EXTI5, TIM3_CH2, ~PWM | analogWrite() PWM from TIM3_CH2 (remapped by AFIO, which the core does for you), 1 kHz by default (analogWriteFrequency()). External interrupt on EXTI line 5: attachInterrupt(digitalPinToInterrupt(PB5), handler, mode). Not 5 V tolerant: keep it at 3.3 V or below. |
| B6 | PB6, EXTI6, I2C1 SCL, TIM4_CH1, ~PWM | I2C1 clock for Wire. analogWrite() PWM from TIM4_CH1, 1 kHz by default (analogWriteFrequency()). External interrupt on EXTI line 6: attachInterrupt(digitalPinToInterrupt(PB6), handler, mode). 5 V tolerant (FT): a 5 V input is safe. |
| B7 | PB7, EXTI7, I2C1 SDA, TIM4_CH2, ~PWM | I2C1 data for Wire. analogWrite() PWM from TIM4_CH2, 1 kHz by default (analogWriteFrequency()). External interrupt on EXTI line 7: attachInterrupt(digitalPinToInterrupt(PB7), handler, mode). 5 V tolerant (FT): a 5 V input is safe. |
| B8 | PB8, EXTI8, TIM4_CH3, ~PWM | analogWrite() PWM from TIM4_CH3, 1 kHz by default (analogWriteFrequency()). External interrupt on EXTI line 8: attachInterrupt(digitalPinToInterrupt(PB8), handler, mode). 5 V tolerant (FT): a 5 V input is safe. |
| B9 | PB9, EXTI9, TIM4_CH4, ~PWM | analogWrite() PWM from TIM4_CH4, 1 kHz by default (analogWriteFrequency()). External interrupt on EXTI line 9: attachInterrupt(digitalPinToInterrupt(PB9), handler, mode). 5 V tolerant (FT): a 5 V input is safe. |
| B11 | PB11, EXTI11, USART3 RX, I2C2 SDA, TIM2_CH4, ~PWM | USART3 receive. I2C2 data. analogWrite() PWM from TIM2_CH4 (remapped by AFIO, which the core does for you), 1 kHz by default (analogWriteFrequency()). External interrupt on EXTI line 11: attachInterrupt(digitalPinToInterrupt(PB11), handler, mode). 5 V tolerant (FT): a 5 V input is safe. |
| B10 | PB10, EXTI10, USART3 TX, I2C2 SCL, TIM2_CH3, ~PWM | USART3 transmit: HardwareSerial Serial3(PB11, PB10). I2C2 clock: TwoWire Wire2(PB11, PB10). analogWrite() PWM from TIM2_CH3 (remapped by AFIO, which the core does for you), 1 kHz by default (analogWriteFrequency()). External interrupt on EXTI line 10: attachInterrupt(digitalPinToInterrupt(PB10), handler, mode). 5 V tolerant (FT): a 5 V input is safe. |
| B1 | PB1, EXTI1, ADC9, TIM3_CH4, ~PWM | Analog input: analogRead() reads ADC channel 9 (12-bit; the core returns 10 bits unless analogReadResolution(12)). analogWrite() PWM from TIM3_CH4, 1 kHz by default (analogWriteFrequency()). External interrupt on EXTI line 1: attachInterrupt(digitalPinToInterrupt(PB1), handler, mode). Not 5 V tolerant: keep it at 3.3 V or below. |
| B0 | PB0, EXTI0, ADC8, TIM3_CH3, ~PWM | Analog input: analogRead() reads ADC channel 8 (12-bit; the core returns 10 bits unless analogReadResolution(12)). analogWrite() PWM from TIM3_CH3, 1 kHz by default (analogWriteFrequency()). External interrupt on EXTI line 0: attachInterrupt(digitalPinToInterrupt(PB0), handler, mode). Not 5 V tolerant: keep it at 3.3 V or below. |
| A7 | PA7, EXTI7, ADC7, TIM3_CH2, SPI1 MOSI, ~PWM | Analog input: analogRead() reads ADC channel 7 (12-bit; the core returns 10 bits unless analogReadResolution(12)). analogWrite() PWM from TIM3_CH2, 1 kHz by default (analogWriteFrequency()). SPI1 data out for the SPI library. External interrupt on EXTI line 7: attachInterrupt(digitalPinToInterrupt(PA7), handler, mode). Not 5 V tolerant: keep it at 3.3 V or below. |
| A6 | PA6, EXTI6, ADC6, TIM3_CH1, SPI1 MISO, ~PWM | Analog input: analogRead() reads ADC channel 6 (12-bit; the core returns 10 bits unless analogReadResolution(12)). analogWrite() PWM from TIM3_CH1, 1 kHz by default (analogWriteFrequency()). SPI1 data in for the SPI library. External interrupt on EXTI line 6: attachInterrupt(digitalPinToInterrupt(PA6), handler, mode). Not 5 V tolerant: keep it at 3.3 V or below. |
| A5 | PA5, EXTI5, ADC5, SPI1 SCK | Analog input: analogRead() reads ADC channel 5 (12-bit; the core returns 10 bits unless analogReadResolution(12)). SPI1 clock for the SPI library. External interrupt on EXTI line 5: attachInterrupt(digitalPinToInterrupt(PA5), handler, mode). Not 5 V tolerant: keep it at 3.3 V or below. |
| A4 | PA4, EXTI4, ADC4, SPI1 NSS | Analog input: analogRead() reads ADC channel 4 (12-bit; the core returns 10 bits unless analogReadResolution(12)). SPI1 chip select (the SPI library's SS). External interrupt on EXTI line 4: attachInterrupt(digitalPinToInterrupt(PA4), handler, mode). Not 5 V tolerant: keep it at 3.3 V or below. |
| A3 | PA3, EXTI3, ADC3, TIM2_CH4, USART2 RX, ~PWM | Analog input: analogRead() reads ADC channel 3 (12-bit; the core returns 10 bits unless analogReadResolution(12)). analogWrite() PWM from TIM2_CH4, 1 kHz by default (analogWriteFrequency()). USART2 receive. External interrupt on EXTI line 3: attachInterrupt(digitalPinToInterrupt(PA3), handler, mode). Not 5 V tolerant: keep it at 3.3 V or below. |
| A2 | PA2, EXTI2, ADC2, TIM2_CH3, USART2 TX, ~PWM | Analog input: analogRead() reads ADC channel 2 (12-bit; the core returns 10 bits unless analogReadResolution(12)). analogWrite() PWM from TIM2_CH3, 1 kHz by default (analogWriteFrequency()). USART2 transmit: HardwareSerial Serial2(PA3, PA2). External interrupt on EXTI line 2: attachInterrupt(digitalPinToInterrupt(PA2), handler, mode). Not 5 V tolerant: keep it at 3.3 V or below. |
| A1 | PA1, EXTI1, ADC1, TIM2_CH2, ~PWM | Analog input: analogRead() reads ADC channel 1 (12-bit; the core returns 10 bits unless analogReadResolution(12)). analogWrite() PWM from TIM2_CH2, 1 kHz by default (analogWriteFrequency()). External interrupt on EXTI line 1: attachInterrupt(digitalPinToInterrupt(PA1), handler, mode). Not 5 V tolerant: keep it at 3.3 V or below. |
| A0 | PA0, EXTI0, ADC0, TIM2_CH1, WKUP, ~PWM | Analog input: analogRead() reads ADC channel 0 (12-bit; the core returns 10 bits unless analogReadResolution(12)). analogWrite() PWM from TIM2_CH1, 1 kHz by default (analogWriteFrequency()). Wakes the chip from Standby on a rising edge. External interrupt on EXTI line 0: attachInterrupt(digitalPinToInterrupt(PA0), handler, mode). Not 5 V tolerant: keep it at 3.3 V or below. |
| C15 | PC15, EXTI15, OSC32_OUT | The 32.768 kHz crystal's other side; as a GPIO it sinks 3 mA at most. External interrupt on EXTI line 15: attachInterrupt(digitalPinToInterrupt(PC15), handler, mode). Not 5 V tolerant: keep it at 3.3 V or below. |
| C14 | PC14, EXTI14, OSC32_IN | The 32.768 kHz crystal for the RTC sits here on the board; as a GPIO it sinks 3 mA at most. External interrupt on EXTI line 14: attachInterrupt(digitalPinToInterrupt(PC14), handler, mode). Not 5 V tolerant: keep it at 3.3 V or below. |
| C13 | PC13, EXTI13, LED | The on-board LED, wired to 3.3 V: digitalWrite(PC13, LOW) lights it. It can sink only 3 mA, so drive nothing else from it. External interrupt on EXTI line 13: attachInterrupt(digitalPinToInterrupt(PC13), handler, mode). Not 5 V tolerant: keep it at 3.3 V or below. |
| 5V | 5V | 5 V supply: from USB, or from the regulator when the board is powered through VIN. |
| GND | GND | Ground (0 V). |
| 3V3 | 3V3 | 3.3 V supply from the on-board regulator. Keep the load small. |
| GND | GND | Ground (0 V). |
| GND | GND | Ground (0 V). |
| 3V3 | 3V3 | 3.3 V supply from the on-board regulator. Keep the load small. |
Good to know
- Pins are named by port and bit in code too: pinMode(PB12, INPUT_PULLUP), digitalWrite(PC13, LOW).
- Register by register: turn a peripheral's clock on first (RCC->APB2ENR |= RCC_APB2ENR_IOPBEN), then set the pin's four bits in GPIOx->CRL (pins 0–7) or CRH (8–15), and drive it with GPIOx->BSRR or ODR.
- The pins run at 3.3 V. The 5 V tolerant ones (PA8–PA15, PB2–PB4, PB6–PB15) can take a 5 V input; the others cannot. Each sinks or sources up to 25 mA, PC13–PC15 only 3 mA.
- EXTI line n serves pin n of one port at a time: PA3 and PB3 cannot both interrupt.
- JTAG holds PA15, PB3 and PB4 after reset; the core frees them when the sketch uses them. PA13 and PA14 are the SWD programming pins.
- In the simulator, VBAT and R (reset) connect to nothing.
- Arduino Uno pinout
- Arduino Nano pinout
- Arduino Mega pinout
- ATtiny85 pinout
- ESP32-C3 DevKitM-1 pinout
- ESP32-S3 DevKitC-1 pinout
- ESP32-C5 DevKitC-1 pinout
- ESP32-C6 DevKitC-1 pinout
- ESP32-H2 DevKitM-1 pinout
- ESP32-P4 Function-EV pinout
- Nucleo-F030R8 pinout
- Nucleo-G071RB pinout
- Nucleo-F401RE pinout
- Nucleo-F446RE pinout
- Nucleo-F767ZI pinout
- Nucleo-H743ZI2 pinout
- Nucleo-WBA55CG pinout
- Nucleo-L552ZE-Q pinout
- Black Pill (STM32F411CE) pinout
- Raspberry Pi Pico pinout
- Raspberry Pi Pico W pinout
- Raspberry Pi Pico 2 pinout
- Raspberry Pi Pico 2 W pinout