Complete STM32F407Pinout & GPIO Ports-Embedded Systems Course for Freshers in Hyderabad

Need Help or More Information?

Questions about this free C programming course, embedded C training or career guidance? Get in touch.

Tutorial 02 — Board & Hardware

Complete STM32F407
Pinout & GPIO Ports

Every pin of the STM32F407VGT6 explained — GPIO ports A through H, 5V-tolerant pins, analog pins, power rails, and alternate functions mapped.

📌 100-pin LQFP Package⏱ ~25 min read⚡ 82 GPIO pins📊 24 ADC channels
PACKAGE

100-Pin LQFP Package

The STM32F407VGT6 comes in a 100-pin LQFP (Low-profile Quad Flat Package) with 0.5mm pitch. The 100 pins are distributed as follows:

CategoryCountDescription
GPIO (I/O)82General-purpose pins — ports A, B, C, D, E (full), H (2 pins)
Power (VDD/GND)11Multiple VDD and VSS pins for noise decoupling
VDDA/VSSA2Analog supply and ground for ADC/DAC
VREF+1ADC reference voltage (max voltage = full-scale ADC reading)
VBAT1Backup battery for RTC and backup registers
NRST1Active-low reset pin
BOOT01Boot mode select pin
PDR_ON1Power-down reset threshold selection
Total100
💡 BOOT0 pin: This pin determines where the MCU boots from after reset. BOOT0 = 0 (GND) → boot from Flash (normal operation). BOOT0 = 1 (VDD) → boot from system memory (ST’s built-in bootloader for flashing via UART/USB). On the Discovery board there is a jumper for this.
GPIO PORTS OVERVIEW

GPIO Ports Overview

Each GPIO port on the STM32F407 is a 16-bit wide parallel interface (16 pins max). On the 100-pin package, only ports A through E are fully available. Port H has only 2 pins used for the external crystal oscillator.

PORT A
PA0 – PA15 (16 pins)
Base: 0x40020000
  • PA0: USER BUTTON (active HIGH)
  • PA4: DAC_OUT1, SPI1_NSS
  • PA5: SPI1_SCK, ADC12_IN5
  • PA9/PA10: USART1_TX/RX
  • PA11/PA12: USB OTG FS D-/D+
  • PA13/PA14: SWDIO/SWDCLK (reserved!)
PORT B
PB0 – PB15 (16 pins)
Base: 0x40020400
  • PB3: SWO/TRACESWO (printf via SWD)
  • PB6/PB7: I2C1_SCL/SDA
  • PB10/PB11: I2C2_SCL/SDA, USART3
  • PB13/PB14: SPI2_SCK/MISO, USB HS
  • Many 5V tolerant pins
PORT C
PC0 – PC15 (16 pins)
Base: 0x40020800
  • PC0–PC5: ADC channels 10–15
  • PC7: I2S3_MCK (audio master clock)
  • PC10–PC12: USART3/SPI3/I2S3 pins
  • PC14/PC15: OSC32_IN/OUT (LSE 32kHz)
PORT D
PD0 – PD15 (16 pins)
Base: 0x40020C00
  • PD12: LED GREEN (LD4)
  • PD13: LED ORANGE (LD3)
  • PD14: LED RED (LD5)
  • PD15: LED BLUE (LD6)
  • PD5/PD6: USART2_TX/RX
PORT E
PE0 – PE15 (16 pins)
Base: 0x40021000
  • PE0: Accelerometer INT1
  • PE1: Accelerometer INT2
  • PE3: SPI1_CS (accel chip select)
  • PE9/PE11/PE13: TIM1 PWM channels
  • PE7–PE15: FSMC data bus
PORT H
PH0 – PH1 (2 pins only)
Base: 0x40021C00
  • PH0: OSC_IN (8 MHz HSE crystal)
  • PH1: OSC_OUT (8 MHz HSE crystal)
  • Not accessible as GPIO when HSE is enabled
INTERACTIVE PIN FILTER

Interactive Pin Reference Table

Filter pins by peripheral type. Click a button to show only those pins relevant to a specific protocol or function:

Pin NamePortPin #AF0Main Alternate FunctionsADC ChannelProperties
PA0A0—USART2_CTS, TIM2_CH1, TIM5_CH1ADC1/2/3_IN0WKUP1
PA1A1—USART2_RTS, TIM2_CH2, TIM5_CH2, ETH_MIIADC1/2/3_IN1FT
PA2A2—USART2_TX, TIM2_CH3, TIM5_CH3, TIM9_CH1ADC1/2/3_IN2FT
PA3A3—USART2_RX, TIM2_CH4, TIM5_CH4, TIM9_CH2ADC1/2/3_IN3FT
PA4A4—SPI1_NSS, SPI3_NSS, I2S3_WS, USART2_CKADC1/2_IN4, DAC_OUT1Analog
PA5A5—SPI1_SCK, TIM2_CH1/ETR, TIM8_CH1NADC1/2_IN5, DAC_OUT2Analog
PA6A6—SPI1_MISO, TIM1_BKIN, TIM3_CH1, TIM8_BKINADC1/2_IN6Analog
PA7A7—SPI1_MOSI, TIM1_CH1N, TIM3_CH2, TIM8_CH1NADC1/2_IN7Analog
PA8A8MCO1I2C3_SCL, TIM1_CH1, USART1_CK, OTG_FS_SOF—FT
PA9A9—USART1_TX, TIM1_CH2, I2C3_SMBA, OTG_FS_VBUS—FT
PA10A10—USART1_RX, TIM1_CH3, OTG_FS_ID—FT
PA11A11—USART1_CTS, CAN1_RX, TIM1_CH4, OTG_FS_DM—FT
PA12A12—USART1_RTS, CAN1_TX, TIM1_ETR, OTG_FS_DP—FT
PA13A13JTMS/SWDIO——RESERVED
PA14A14JTCK/SWCLK——RESERVED
PA15A15JTDISPI1_NSS, SPI3_NSS, I2S3_WS, TIM2_CH1/ETR—FT
PB0B0—TIM1_CH2N, TIM3_CH3, TIM8_CH2N, OTG_HS_ULPI_D1ADC1/2_IN8Analog
PB1B1—TIM1_CH3N, TIM3_CH4, TIM8_CH3N, OTG_HS_ULPI_D2ADC1/2_IN9Analog
PB3B3JTDO/SWOSPI1_SCK, SPI3_SCK, I2S3_CK, TIM2_CH2—SWO
PB4B4JTRSTSPI1_MISO, SPI3_MISO, I2S3ext_SD, TIM3_CH1—FT
PB5B5—SPI1_MOSI, SPI3_MOSI, I2S3_SD, TIM3_CH2—FT
PB6B6—I2C1_SCL, USART1_TX, TIM4_CH1, CAN2_TX—FT 5V
PB7B7—I2C1_SDA, USART1_RX, TIM4_CH2, FSMC_NL—FT 5V
PB8B8—I2C1_SCL, CAN1_RX, TIM4_CH3, TIM10_CH1—5V
PB9B9—I2C1_SDA, CAN1_TX, TIM4_CH4, TIM11_CH1—5V
PB10B10—I2C2_SCL, USART3_TX, TIM2_CH3, SPI2_SCK, I2S2_CK—5V
PB11B11—I2C2_SDA, USART3_RX, TIM2_CH4—5V
PB13B13—SPI2_SCK, I2S2_CK, USART3_CTS, TIM1_CH1N, OTG_HS_VBUS—5V
PB14B14—SPI2_MISO, I2S2ext_SD, TIM1_CH2N, TIM8_CH2N, OTG_HS_DM—5V
PB15B15—SPI2_MOSI, I2S2_SD, TIM1_CH3N, TIM8_CH3N, OTG_HS_DP—5V
PC0C0—OTG_HS_ULPI_STPADC1/2/3_IN10Analog
PC1C1—ETH_MDC, SPI2_MOSIADC1/2/3_IN11Analog
PC2C2—SPI2_MISO, I2S2ext_SD, OTG_HS_ULPI_DIRADC1/2/3_IN12Analog
PC3C3—SPI2_MOSI, I2S2_SD, OTG_HS_ULPI_NXTADC1/2/3_IN13Analog
PC4C4—ETH_MII_RXD0, ETH_RMII_RXD0ADC1/2_IN14Analog
PC5C5—ETH_MII_RXD1, USART3_RXADC1/2_IN15Analog
PC6C6—I2S2_MCK, TIM3_CH1, TIM8_CH1, USART6_TX, SDIO_D6—FT
PC7C7—I2S3_MCK, TIM3_CH2, TIM8_CH2, USART6_RX, SDIO_D7—FT
PC10C10—SPI3_SCK, I2S3_CK, USART3_TX, UART4_TX, SDIO_D2—FT
PC11C11—SPI3_MISO, I2S3ext_SD, USART3_RX, UART4_RX, SDIO_D3—FT
PC12C12—SPI3_MOSI, I2S3_SD, USART3_CK, UART5_TX, SDIO_CK—FT
PD0D0—CAN1_RX, FSMC_D2—5V
PD1D1—CAN1_TX, FSMC_D3—5V
PD5D5—USART2_TX, FSMC_NWE—5V
PD6D6—USART2_RX, FSMC_NWAIT—5V
PD12D12—TIM4_CH1, FSMC_A17—LED GREEN
PD13D13—TIM4_CH2, FSMC_A18—LED ORANGE
PD14D14—TIM4_CH3, FSMC_D0—LED RED
PD15D15—TIM4_CH4, FSMC_D1—LED BLUE
PE0E0—TIM4_ETR, FSMC_NBL0, DCMI_D2—ACCEL INT1
PE1E1—FSMC_NBL1, DCMI_D3—ACCEL INT2
PE3E3TRACE_D0FSMC_A19—ACCEL CS
PE9E9—TIM1_CH1, FSMC_D6—FT
PE11E11—TIM1_CH2, FSMC_D8—FT
PE13E13—TIM1_CH3, FSMC_D10—FT
PE14E14—TIM1_CH4, FSMC_D11—FT
PH0H0OSC_IN——HSE Crystal
PH1H1OSC_OUT——HSE Crystal
5V TOLERANT

5V Tolerant Pins (FT Pins)

Some STM32F407 GPIO pins are marked as FT (5V Tolerant) — they can accept 5V logic signals on their input even though the MCU runs at 3.3V. This allows direct interfacing with 5V devices like Arduino boards, old sensors, or 5V TTL logic chips without a level shifter.

⚠️ Important Caveat: FT pins tolerate 5V on their input. You cannot drive a 5V device’s input with a 3.3V STM32 output — 3.3V may not be recognized as logic HIGH by a 5V device. In that case, use a level shifter or open-drain with pull-up to 5V.

The following pins are 5V tolerant on the STM32F407VGT6 (100-pin package):

Diagram: 5V Tolerant Pins (FT Pins)
PA1
PA2
PA3
PA8
PA9
PA10
PA11
PA12
PA15
PB3
PB4
PB5
PB6
PB7
PB8
PB9
PB10
PB11
PB13
PB14
PB15
PC6
PC7
PC8
PC9
PC10
PC11
PC12
PD0
PD1
PD5
PD6
PD7
PD8
PD9
PD10
PD11
PE9
PE11
PE14

Legend: Dark Blue = 5V Tolerant

ANALOG PINS

Analog Pins — ADC Channels

STM32F407 has three 12-bit ADCs sharing 16 external channels. Analog pins cannot be used as 5V tolerant inputs — max input voltage is VDDA (3.3V). Do not enable pull-up/pull-down resistors on analog pins.

ADC ChannelPin (PA)Pin (PB)Pin (PC)Available on ADC
IN0PA0——ADC1, ADC2, ADC3
IN1PA1——ADC1, ADC2, ADC3
IN2PA2——ADC1, ADC2, ADC3
IN3PA3——ADC1, ADC2, ADC3
IN4PA4——ADC1, ADC2 only
IN5PA5——ADC1, ADC2 only
IN6PA6——ADC1, ADC2 only
IN7PA7——ADC1, ADC2 only
IN8—PB0—ADC1, ADC2 only
IN9—PB1—ADC1, ADC2 only
IN10——PC0ADC1, ADC2, ADC3
IN11——PC1ADC1, ADC2, ADC3
IN12——PC2ADC1, ADC2, ADC3
IN13——PC3ADC1, ADC2, ADC3
IN14——PC4ADC1, ADC2 only
IN15——PC5ADC1, ADC2 only

Additionally, there are internal channels available on ADC1 only:

  • IN16 — Internal temperature sensor
  • IN17 — Internal VREFINT (bandgap ~1.2V)
  • IN18 — VBAT voltage (1/4 of VBAT)
POWER PINS

Power Supply Pins

Pin NameTypeVoltage RangePurpose
VDD (×7)Power Input1.8V – 3.6VMain digital supply. Multiple VDD pins for decoupling. Each must have a 100nF bypass capacitor to VSS.
VSS (×7)Ground0VDigital ground reference
VDDAAnalog Power1.8V – 3.6VAnalog supply for ADC, DAC, comparators, PLL. Should be independently filtered from VDD.
VSSAAnalog Ground0VAnalog ground — keep separate from digital ground at the star point
VREF+ADC Reference1.8V – VDDAADC full-scale reference voltage. A reading of 0xFFF = VREF+ volts. On Discovery board, tied to VDDA (3.3V).
VBATBattery Backup1.65V – 3.6VPowers RTC, 4KB backup SRAM, and LSE oscillator when VDD is off. Connect to 3V coin cell or VDDA.
VDD_USBUSB Power3.0V – 3.6VUSB transceiver supply. Must be 3.3V for correct USB operation.
BASE ADDRESSES

GPIO Register Base Addresses

Every GPIO port has its own set of registers starting at a base address. When you write register-level code, you add the register offset to the base address to get the actual memory-mapped register location:

/* STM32F407 GPIO Base Addresses (from Reference Manual Table 1) */
#define GPIOA_BASE  0x40020000UL  /* AHB1 bus */
#define GPIOB_BASE  0x40020400UL
#define GPIOC_BASE  0x40020800UL
#define GPIOD_BASE  0x40020C00UL
#define GPIOE_BASE  0x40021000UL
#define GPIOF_BASE  0x40021400UL  /* Not on 100-pin */
#define GPIOG_BASE  0x40021800UL  /* Not on 100-pin */
#define GPIOH_BASE  0x40021C00UL  /* Only PH0,PH1 */
#define GPIOI_BASE  0x40022000UL  /* Not on 100-pin */

/* Register offsets (same for all ports) */
#define GPIO_MODER_OFFSET   0x00  /* Mode register */
#define GPIO_OTYPER_OFFSET  0x04  /* Output type register */
#define GPIO_OSPEEDR_OFFSET 0x08  /* Output speed register */
#define GPIO_PUPDR_OFFSET   0x0C  /* Pull-up/pull-down register */
#define GPIO_IDR_OFFSET     0x10  /* Input data register */
#define GPIO_ODR_OFFSET     0x14  /* Output data register */
#define GPIO_BSRR_OFFSET    0x18  /* Bit set/reset register */
#define GPIO_LCKR_OFFSET    0x1C  /* Configuration lock register */
#define GPIO_AFRL_OFFSET    0x20  /* Alternate function low (pins 0-7) */
#define GPIO_AFRH_OFFSET    0x24  /* Alternate function high (pins 8-15) */

/* Example: Access GPIOD_MODER using pointer arithmetic */
#define GPIOD_MODER (*((volatile uint32_t*)(GPIOD_BASE + GPIO_MODER_OFFSET)))

/* Or use a struct approach for cleaner code */
typedef struct {
    volatile uint32_t MODER;    /* offset 0x00 */
    volatile uint32_t OTYPER;   /* offset 0x04 */
    volatile uint32_t OSPEEDR;  /* offset 0x08 */
    volatile uint32_t PUPDR;    /* offset 0x0C */
    volatile uint32_t IDR;      /* offset 0x10 */
    volatile uint32_t ODR;      /* offset 0x14 */
    volatile uint32_t BSRR;     /* offset 0x18 */
    volatile uint32_t LCKR;     /* offset 0x1C */
    volatile uint32_t AFR[2];   /* AFRL [0], AFRH [1] */
} GPIO_TypeDef;

#define GPIOD  ((GPIO_TypeDef*)GPIOD_BASE)

/* Usage: */
/* GPIOD->MODER |= (1U << 24);  // Set PD12 as output */
/* GPIOD->BSRR   = (1U << 12);  // Set PD12 HIGH (atomic) */
Key Takeaways from Tutorial 02
  • STM32F407VGT6 has 100 pins — 82 GPIO, rest are power, reset, and crystal pins
  • Ports A through E are fully available (16 pins each); Port H has only 2 pins (crystal)
  • Each GPIO port has base address spaced 0x400 bytes apart on AHB1 bus
  • Analog pins (PA0–PA7, PB0–PB1, PC0–PC5) cannot tolerate 5V input
  • FT (5V tolerant) pins mainly on ports B, C, D — safe for 5V logic input
  • PA13/PA14 are permanently assigned to SWD debug — never reconfigure them

STM32F407 Discovery Tutorial Series — Tutorial 02: Pinout & GPIO Ports

Need Help or More Information?

Questions about this free C programming course, embedded C training or career guidance? Get in touch.

2 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *