Black Pill (STM32F411CE) pinout
The Black Pill (STM32F411CE) (STM32F411CE) pinout: what each pin does, from GPIO, analog inputs and PWM to UART, I2C and SPI, with the notes that catch…
The board
- Microcontroller: STM32F411CEU6, 32-bit Arm Cortex-M4 with a floating-point unit
- Clock: 96 MHz (the 25 MHz crystal / 25 × 192 / 2 through the PLL); APB1 at 48 MHz, APB2 at 96 MHz
- Flash / SRAM: 512 KB / 128 KB
- Logic level: 3.3 V; 5 V tolerant but PA0 and PB5, and none in analog mode
- Analog inputs: 10 pin channels (PA0–PA7, PB0, PB1), 12-bit
- PWM: Timer channels TIM1–TIM5 (TIM2 and TIM5 32-bit), TIM9–TIM11: 1 kHz by default
- Serial: USART1 on PA9/PA10 (Serial, with usb=none); USART2 on PA2/PA3, USART6 on PA11/PA12
- I2C and SPI: Wire is I2C1 on PB7/PB6, SPI is SPI1 on PA5–PA7; I2C2 on PB3/PB10, I2C3 on PB4/PA8, SPI2–SPI5
- Floating point: float in hardware (single precision), double in software; the DSP instructions
- External interrupts: Any pin: EXTI line n takes pin n of one port
- On-board LED: PC13, lit LOW
- Buttons: KEY on PA0 (USER_BTN), LOW while pressed with INPUT_PULLUP (the board has no pull-up); NRST resets
Pins
| Pin | Functions | Notes |
|---|---|---|
| B12 | PB12, EXTI12, SPI2 NSS, SPI4 NSS, SPI3 SCK | SPI2 chip select. SPI4 chip select. SPI3 clock. External interrupt on EXTI line 12: attachInterrupt(digitalPinToInterrupt(PB12), handler, mode). 5 V tolerant (FT): a 5 V input is safe. |
| B13 | PB13, EXTI13, TIM1_CH1N, SPI2 SCK, SPI4 SCK, ~PWM | analogWrite() PWM from TIM1_CH1N, 1 kHz by default (analogWriteFrequency()). SPI2 clock. SPI4 clock. External interrupt on EXTI line 13: attachInterrupt(digitalPinToInterrupt(PB13), handler, mode). 5 V tolerant (FT): a 5 V input is safe. |
| B14 | PB14, EXTI14, TIM1_CH2N, SPI2 MISO, ~PWM | analogWrite() PWM from TIM1_CH2N, 1 kHz by default (analogWriteFrequency()). SPI2 data in. External interrupt on EXTI line 14: attachInterrupt(digitalPinToInterrupt(PB14), handler, mode). 5 V tolerant (FT): a 5 V input is safe. |
| B15 | PB15, EXTI15, TIM1_CH3N, SPI2 MOSI, ~PWM | analogWrite() PWM from TIM1_CH3N, 1 kHz by default (analogWriteFrequency()). SPI2 data out. External interrupt on EXTI line 15: attachInterrupt(digitalPinToInterrupt(PB15), handler, mode). 5 V tolerant (FT): a 5 V input is safe. |
| A8 | PA8, EXTI8, MCO1, TIM1_CH1, I2C3 SCL, ~PWM | Can output a clock (MCO1). analogWrite() PWM from TIM1_CH1, 1 kHz by default (analogWriteFrequency()). I2C3 clock. 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 (built with usb=none). 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, SPI5 MOSI, ~PWM | USART1 receive: what the Serial Monitor sends. analogWrite() PWM from TIM1_CH3, 1 kHz by default (analogWriteFrequency()). SPI5 data out. External interrupt on EXTI line 10: attachInterrupt(digitalPinToInterrupt(PA10), handler, mode). 5 V tolerant (FT): a 5 V input is safe. |
| A11 | PA11, EXTI11, USB D-, TIM1_CH4, SPI4 MISO, USART6 TX, ~PWM | USB D- on the USB-C connector (with usb=none, as the simulator builds, a plain GPIO). analogWrite() PWM from TIM1_CH4, 1 kHz by default (analogWriteFrequency()). SPI4 data in. USART6 transmit: HardwareSerial Serial6(PA12, PA11). 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+, SPI5 MISO, USART6 RX | USB D+ (with usb=none, a plain GPIO). SPI5 data in. USART6 receive. 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, SPI1 NSS, SPI3 NSS, ~PWM | JTAG data in at reset (alternate function 0); a GPIO once the sketch sets its mode. analogWrite() PWM from TIM2_CH1, 1 kHz by default (analogWriteFrequency()). SPI1 chip select. SPI3 chip select. 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/SWO, TIM2_CH2, SPI1 SCK, SPI3 SCK, I2C2 SDA, ~PWM | JTAG data out and the trace output at reset; a GPIO once the sketch sets its mode. analogWrite() PWM from TIM2_CH2, 1 kHz by default (analogWriteFrequency()). SPI1 clock. SPI3 clock. I2C2 data for TwoWire Wire2(PB3, PB10). 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, SPI1 MISO, SPI3 MISO, I2C3 SDA, ~PWM | JTAG reset at reset (alternate function 0, pulled up); a GPIO once the sketch sets its mode. analogWrite() PWM from TIM3_CH1, 1 kHz by default (analogWriteFrequency()). SPI1 data in. SPI3 data in. I2C3 data. 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, SPI1 MOSI, SPI3 MOSI, ~PWM | analogWrite() PWM from TIM3_CH2, 1 kHz by default (analogWriteFrequency()). SPI1 data out. SPI3 data out. 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, TIM4_CH1, I2C1 SCL, ~PWM | analogWrite() PWM from TIM4_CH1, 1 kHz by default (analogWriteFrequency()). I2C1 clock for Wire. External interrupt on EXTI line 6: attachInterrupt(digitalPinToInterrupt(PB6), handler, mode). 5 V tolerant (FT): a 5 V input is safe. |
| B7 | PB7, EXTI7, TIM4_CH2, I2C1 SDA, ~PWM | analogWrite() PWM from TIM4_CH2, 1 kHz by default (analogWriteFrequency()). I2C1 data for Wire. 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, TIM10_CH1, I2C1 SCL, SPI5 MOSI, I2C3 SDA, ~PWM | analogWrite() PWM from TIM4_CH3, 1 kHz by default (analogWriteFrequency()). analogWrite() PWM from TIM10_CH1, 1 kHz by default (analogWriteFrequency()). I2C1 clock. SPI5 data out. I2C3 data. 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, TIM11_CH1, I2C1 SDA, SPI2 NSS, I2C2 SDA, ~PWM | analogWrite() PWM from TIM4_CH4, 1 kHz by default (analogWriteFrequency()). analogWrite() PWM from TIM11_CH1, 1 kHz by default (analogWriteFrequency()). I2C1 data. SPI2 chip select. I2C2 data. External interrupt on EXTI line 9: attachInterrupt(digitalPinToInterrupt(PB9), handler, mode). 5 V tolerant (FT): a 5 V input is safe. |
| B10 | PB10, EXTI10, TIM2_CH3, I2C2 SCL, SPI2 SCK, ~PWM | analogWrite() PWM from TIM2_CH3, 1 kHz by default (analogWriteFrequency()). I2C2 clock for TwoWire Wire2(PB3, PB10). SPI2 clock. External interrupt on EXTI line 10: attachInterrupt(digitalPinToInterrupt(PB10), handler, mode). 5 V tolerant (FT): a 5 V input is safe. |
| B2 | PB2, EXTI2, BOOT1 | Read at reset with BOOT0; a GPIO after. External interrupt on EXTI line 2: attachInterrupt(digitalPinToInterrupt(PB2), handler, mode). 5 V tolerant (FT): a 5 V input is safe. |
| B1 | PB1, EXTI1, ADC9, TIM1_CH3N, TIM3_CH4, SPI5 NSS, ~PWM | Analog input: analogRead() reads ADC channel 9 (12-bit; the core returns 10 bits unless analogReadResolution(12)). analogWrite() PWM from TIM1_CH3N, 1 kHz by default (analogWriteFrequency()). analogWrite() PWM from TIM3_CH4, 1 kHz by default (analogWriteFrequency()). SPI5 chip select. External interrupt on EXTI line 1: attachInterrupt(digitalPinToInterrupt(PB1), handler, mode). 5 V tolerant (FT): a 5 V input is safe. |
| B0 | PB0, EXTI0, ADC8, TIM1_CH2N, TIM3_CH3, SPI5 SCK, ~PWM | Analog input: analogRead() reads ADC channel 8 (12-bit; the core returns 10 bits unless analogReadResolution(12)). analogWrite() PWM from TIM1_CH2N, 1 kHz by default (analogWriteFrequency()). analogWrite() PWM from TIM3_CH3, 1 kHz by default (analogWriteFrequency()). SPI5 clock. External interrupt on EXTI line 0: attachInterrupt(digitalPinToInterrupt(PB0), handler, mode). 5 V tolerant (FT): a 5 V input is safe. |
| A7 | PA7, EXTI7, ADC7, TIM1_CH1N, 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 TIM1_CH1N, 1 kHz by default (analogWriteFrequency()). 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). 5 V tolerant (FT): a 5 V input is safe. |
| 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). 5 V tolerant (FT): a 5 V input is safe. |
| A5 | PA5, EXTI5, ADC5, TIM2_CH1, SPI1 SCK, ~PWM | Analog input: analogRead() reads ADC channel 5 (12-bit; the core returns 10 bits unless analogReadResolution(12)). analogWrite() PWM from TIM2_CH1, 1 kHz by default (analogWriteFrequency()). SPI1 clock for the SPI library. External interrupt on EXTI line 5: attachInterrupt(digitalPinToInterrupt(PA5), handler, mode). 5 V tolerant (FT): a 5 V input is safe. |
| A4 | PA4, EXTI4, ADC4, SPI1 NSS, SPI3 NSS | Analog input: analogRead() reads ADC channel 4 (12-bit; the core returns 10 bits unless analogReadResolution(12)). SPI1 chip select. SPI3 chip select. External interrupt on EXTI line 4: attachInterrupt(digitalPinToInterrupt(PA4), handler, mode). 5 V tolerant (FT): a 5 V input is safe. |
| A3 | PA3, EXTI3, ADC3, TIM2_CH4, TIM5_CH4, TIM9_CH2, 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()). analogWrite() PWM from TIM5_CH4, 1 kHz by default (analogWriteFrequency()). analogWrite() PWM from TIM9_CH2, 1 kHz by default (analogWriteFrequency()). USART2 receive. External interrupt on EXTI line 3: attachInterrupt(digitalPinToInterrupt(PA3), handler, mode). 5 V tolerant (FT): a 5 V input is safe. |
| A2 | PA2, EXTI2, ADC2, TIM2_CH3, TIM5_CH3, TIM9_CH1, 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()). analogWrite() PWM from TIM5_CH3, 1 kHz by default (analogWriteFrequency()). analogWrite() PWM from TIM9_CH1, 1 kHz by default (analogWriteFrequency()). USART2 transmit: HardwareSerial Serial2(PA3, PA2). External interrupt on EXTI line 2: attachInterrupt(digitalPinToInterrupt(PA2), handler, mode). 5 V tolerant (FT): a 5 V input is safe. |
| A1 | PA1, EXTI1, ADC1, TIM2_CH2, TIM5_CH2, SPI4 MOSI, ~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()). analogWrite() PWM from TIM5_CH2, 1 kHz by default (analogWriteFrequency()). SPI4 data out. External interrupt on EXTI line 1: attachInterrupt(digitalPinToInterrupt(PA1), handler, mode). 5 V tolerant (FT): a 5 V input is safe. |
| A0 | PA0, EXTI0, ADC0, KEY, TIM2_CH1, TIM5_CH1, ~PWM | Analog input: analogRead() reads ADC channel 0 (12-bit; the core returns 10 bits unless analogReadResolution(12)). The KEY button (USER_BTN), which pulls the pin low when pressed; also WKUP. analogWrite() PWM from TIM2_CH1, 1 kHz by default (analogWriteFrequency()). analogWrite() PWM from TIM5_CH1, 1 kHz by default (analogWriteFrequency()). 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. External interrupt on EXTI line 15: attachInterrupt(digitalPinToInterrupt(PC15), handler, mode). 5 V tolerant (FT): a 5 V input is safe. |
| C14 | PC14, EXTI14, OSC32_IN | The 32.768 kHz crystal for the RTC. External interrupt on EXTI line 14: attachInterrupt(digitalPinToInterrupt(PC14), handler, mode). 5 V tolerant (FT): a 5 V input is safe. |
| C13 | PC13, EXTI13, LED | The blue LED, wired to 3.3 V: digitalWrite(PC13, LOW) lights it. External interrupt on EXTI line 13: attachInterrupt(digitalPinToInterrupt(PC13), handler, mode). 5 V tolerant (FT): a 5 V input is safe. |
| 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. |
| 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. |
Good to know
- Pins are named by port and bit in code too: pinMode(PB12, INPUT_PULLUP), digitalWrite(PC13, LOW).
- Register by register: the ports are on AHB1 (RCC->AHB1ENR |= RCC_AHB1ENR_GPIOCEN), the peripherals on APB1 (48 MHz) and APB2 (96 MHz), and APB1's timers count at twice their bus, 96 MHz. Set the pin's two bits in MODER, its alternate function in AFR[0] or AFR[1] (USART1, 2 are AF7, I2C AF4, SPI1 AF5), then drive it with BSRR or ODR.
- The Cortex-M4F does float arithmetic in hardware (VADD.F32, VMUL.F32, VSQRT.F32) and double in software, so 1.0f is much faster than 1.0. The core turns the FPU on (SCB->CPACR) before setup().
- PA13 and PA14 are the SWD pins; PA15, PB3 and PB4 start as JTAG pins and become GPIO as soon as the sketch sets their mode.
- The 48-pin package has no PB11 and no port C below PC13.
- In the simulator, VB and R connect to nothing; press KEY (it needs INPUT_PULLUP) and NRST on the board drawing.
- 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
- Blue Pill (STM32F103C8) 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
- Raspberry Pi Pico pinout
- Raspberry Pi Pico W pinout
- Raspberry Pi Pico 2 pinout
- Raspberry Pi Pico 2 W pinout