STM32F407 DiscoveryBoard Overview-Embedded C Training for Freshers

Need Help or More Information?

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

Tutorial 01 — Board & Hardware

STM32F407 Discovery
Board Overview

A complete walkthrough of every component on the STM32F4-Discovery board — MCU specs, on-board peripherals, power system, and debug interface.

📖 Beginner Friendly⏱ ~20 min read📌 STM32F407VGT6⚡ 168 MHz Cortex-M4
INTRO

What is the STM32F4-Discovery Board?

The STM32F4-Discovery (official part number: STM32F407VGT6) is a low-cost evaluation board from STMicroelectronics designed to help developers learn and prototype with the ARM Cortex-M4 processor family. It costs around $15–20 USD and packs a tremendous amount of hardware for that price.

This board is widely used in universities, embedded systems courses, and professional prototyping because it gives you direct access to all major peripherals — GPIO, UART, SPI, I2C, CAN, USB, ADC, DAC, Timers, and DMA — without needing external components to get started.

Why learn register-level programming on this board?

While STM32 HAL library is convenient, register-level programming teaches you exactly how hardware works. You eliminate abstraction layers, write tighter code, debug hardware issues faster, and deeply understand the ARM Cortex-M4 architecture — skills that transfer to any microcontroller.

MCU SPECS

STM32F407VGT6 MCU Specifications

The heart of the board is the STM32F407VGT6 — a 32-bit ARM Cortex-M4 processor with hardware floating-point unit (FPU). Let’s break down every specification:

ParameterValueNotes
CoreARM Cortex-M432-bit RISC, includes FPU (single-precision), DSP instructions
Max Clock Speed168 MHzWith PLL from 8 MHz external crystal
Flash Memory1 MB (1024 KB)Divided into 8 sectors, 16KB × 4 + 64KB + 128KB × 7
SRAM192 KB totalSRAM1: 112 KB + SRAM2: 16 KB + CCM RAM: 64 KB
Package100-pin LQFPLow-profile Quad Flat Package, 0.5 mm pitch
Supply Voltage1.8V – 3.6VTypical 3.3V; 5V tolerant I/O pins available
GPIO PinsUp to 82 I/OPorts A, B, C, D, E (full), H (2 pins on 100-pin package)
Timers17 timers2× advanced (TIM1,TIM8), 10× general purpose, 2× basic, 2× watchdog, 1× SysTick
UART/USART6 interfacesUSART1/2/3/6 + UART4/5
SPI3 interfacesSPI1/2/3, up to 42 Mbps
I2C3 interfacesI2C1/2/3, up to 400 kHz (Fast Mode)
CAN2 interfacesCAN1/CAN2, 2.0A/B compliant
USB OTG2 interfacesUSB OTG FS (12 Mbps) + USB OTG HS (480 Mbps)
ADC3 × 12-bitADC1/2/3, up to 2.4 MSPS, 24 channels
DAC2 × 12-bitDAC1/DAC2 on PA4, PA5
DMA2 controllersDMA1 (7 streams) + DMA2 (8 streams), 8 channels each
I2S3 interfacesFor audio (used by on-board CS43L22 codec)
SDIO1 interfaceFor SD cards
DCMI1 interfaceDigital Camera Interface
Ethernet MAC1 (with PHY)IEEE 802.3 compliant
Operating Temp-40°C to +85°CIndustrial grade
💡 CCM RAM (Core Coupled Memory): The 64 KB CCM RAM is directly connected to the CPU — no bus sharing. Code and data placed here runs at full 168 MHz without wait states or bus contention. It cannot be used by DMA directly. Ideal for ISRs, real-time control loops.
BOARD DIAGRAM

Board Diagram Walkthrough

Here is a labeled diagram of the STM32F4-Discovery board showing the location and function of every major component:

STM32F4-DISCOVERY BOARD LAYOUT (Top View)
ST-LINK / V2 Area (TOP)
■ STM32F103C8T6 (Debug MCU)
■ USB Mini-B (CN1) — ST-LINK
■ JP1 — JTAG/SWD selector
■ LD1 (COM), LD2 (PWR) LEDs
STM32F407VGT6
ARM Cortex-M4 @ 168 MHz
1MB Flash 192KB SRAM FPU 100-LQFP 82 GPIO 17 Timers
Audio & Sensors (TOP-RIGHT)
■ CS43L22 Audio DAC (I2C3+I2S3)
■ LIS302DL/LIS3DSH Accelerometer
■ MP45DT02 MEMS Microphone
■ 3.5mm Audio Jack (CN6)
User LEDs & Button
● LD4 Green — PD12
● LD3 Orange — PD13
● LD5 Red — PD14
● LD6 Blue — PD15
■ B1 USER Button — PA0 (active HIGH)
USB OTG
■ CN5 USB OTG FS (Micro-B) — PA11/PA12
■ CN4 USB OTG HS — ULPI chip PB14/PB15
■ ID pin support
Power
■ 3V3 LDO — LD3985
■ VDD = 3.3V
■ VDDA = 3.3V (ADC ref)
■ JP2 — power source select
P1 Connector (Left)
GPIOE, GPIOD, GPIOC pins + power
P2 Connector (Right)
GPIOA, GPIOB pins + power
SWD Header (CN3)
SWDIO, SWDCLK, GND, VDD, NRST
Crystals
8 MHz HSE (Y1)
32.768 kHz LSE (Y2)
ST-LINK

ST-LINK V2 Debugger

The top portion of the Discovery board contains a complete ST-LINK V2 debugger built around a second STM32 MCU — the STM32F103C8T6. This means you only need a USB cable to program and debug your application — no separate JTAG programmer needed.

How ST-LINK Works

When you connect the board to your PC via the USB Mini-B connector (CN1), the STM32F103 enumerates as a USB HID device and exposes the SWD (Serial Wire Debug) interface to the target STM32F407. STM32CubeIDE (or OpenOCD) communicates with it to:

  • Flash your compiled binary to Flash memory
  • Set hardware breakpoints (up to 6 simultaneously)
  • Inspect/modify registers and memory in real time
  • Use ITM/SWO for printf() without UART (Virtual COM Port)
SWD PinSignalDescription
PA13SWDIOBidirectional data line for SWD protocol
PA14SWDCLKClock signal for SWD protocol
PB3SWO / TRACESWOSingle Wire Output — used for ITM printf and trace
NRSTRESETActive-low system reset
⚠️ PA13/PA14 are reserved! Do not configure PA13 or PA14 as normal GPIO in your application — they are permanently connected to the ST-LINK and doing so will lose your debug connection.

The CN3 header (5-pin SWD connector on the board edge) lets you use the on-board ST-LINK to program an external STM32 board. This makes the Discovery board useful as a standalone programmer.

LEDS

On-Board User LEDs

The STM32F4-Discovery has four user-controllable LEDs — a perfect “Hello World” for any embedded systems course. Each LED is connected to a GPIOD pin through a 470Ω current-limiting resistor.

Diagram: On-Board User LEDs
LD4
GREEN
PD12
LD3
ORANGE
PD13
LD5
RED
PD14
LD6
BLUE
PD15

All four LEDs are connected between the MCU pin and VDD (3.3V) through resistors. The LEDs are active HIGH — setting the GPIO pin HIGH turns the LED ON. Here is the minimal bare-metal code to blink the green LED:

/* Bare-metal LED blink — no HAL, no libraries */
#include <stdint.h>

/* Base addresses from STM32F407 reference manual */
#define RCC_BASE   0x40023800
#define GPIOD_BASE  0x40020C00

/* Register offsets */
#define RCC_AHB1ENR (*((volatile uint32_t*)(RCC_BASE   + 0x30)))
#define GPIOD_MODER (*((volatile uint32_t*)(GPIOD_BASE + 0x00)))
#define GPIOD_ODR   (*((volatile uint32_t*)(GPIOD_BASE + 0x14)))

int main(void) {
    /* Step 1: Enable GPIOD clock (bit 3 of RCC_AHB1ENR) */
    RCC_AHB1ENR |= (1U << 3);

    /* Step 2: Set PD12 as output (MODER bits [25:24] = 01) */
    GPIOD_MODER &= ~(0x3U << 24);  /* clear bits */
    GPIOD_MODER |=  (0x1U << 24);  /* set output mode */

    while(1) {
        GPIOD_ODR |=  (1U << 12);   /* PD12 HIGH — LED ON  */
        for(volatile int i = 0; i < 500000; i++);

        GPIOD_ODR &= ~(1U << 12);  /* PD12 LOW  — LED OFF */
        for(volatile int i = 0; i < 500000; i++);
    }
}
✅ We use the BSRR register in real code instead of ODR for atomic set/reset operations (no read-modify-write needed). This is covered in full detail in Tutorial 03 — GPIO Registers.
BUTTON

User Push Button (B1)

There is one user-accessible push button on the board labeled B1 (sometimes marked as USER). It is connected to PA0 (Port A, Pin 0).

Button Electrical Connection

Active HIGH — When the button is not pressed, PA0 reads LOW (0V). When pressed, it connects to VDD (3.3V) so PA0 reads HIGH (1). This is opposite to many other boards that use active-low buttons.

The pin has a hardware pull-down resistor on the board (RC2 = 10kΩ to GND), so you do not need to enable the internal pull-down via the PUPDR register for this specific pin. However, enabling it in software does no harm.

/* Read button state — PA0 is active HIGH */
#define GPIOA_BASE  0x40020000
#define RCC_AHB1ENR (*((volatile uint32_t*)0x40023830))
#define GPIOA_MODER (*((volatile uint32_t*)(GPIOA_BASE + 0x00)))
#define GPIOA_IDR   (*((volatile uint32_t*)(GPIOA_BASE + 0x10)))

void button_init(void) {
    RCC_AHB1ENR |= (1U << 0);    /* enable GPIOA clock */
    /* MODER bits [1:0] for PA0 = 00 (input mode, default) */
    GPIOA_MODER &= ~(0x3U << 0);
}

uint8_t button_read(void) {
    return (GPIOA_IDR >> 0) & 0x1;  /* returns 1 if pressed */
}
ACCELEROMETER

MEMS Accelerometer

The STM32F4-Discovery includes a MEMS 3-axis accelerometer. Original boards use the LIS302DL (discontinued); newer revisions use the LIS3DSH. Both communicate via SPI1.

SignalMCU PinDescription
SPI1_SCKPA5SPI clock (up to 10 MHz)
SPI1_MISOPA6Master In Slave Out (accel → MCU)
SPI1_MOSIPA7Master Out Slave In (MCU → accel)
SPI1_CS (NSS)PE3Chip select (active LOW)
INT1PE0Interrupt 1 from accelerometer
INT2PE1Interrupt 2 from accelerometer

The accelerometer measures ±2g / ±4g / ±8g. You can tilt the board and read X, Y, Z acceleration values. This is commonly used to demonstrate SPI communication (Tutorial 14) and interrupt-driven sensor reading (Tutorial 08).

AUDIO

Audio Codec (CS43L22)

The CS43L22 is a 24-bit, 96kHz stereo DAC from Cirrus Logic. It’s connected to the STM32F407 via two interfaces:

  • I2C3 — for control/configuration (register writes to set volume, sample rate, etc.)
  • I2S3 (I2S protocol over SPI3 pins) — for streaming audio data (PCM samples)
SignalMCU PinInterface
I2C3_SCLPA8I2C control clock
I2C3_SDAPC9I2C control data
I2S3_MCKPC7Master clock (12.288 MHz for 48kHz audio)
I2S3_SCKPC10Bit clock
I2S3_SDPC12Serial audio data
I2S3_WSPA4Word select (L/R channel)
RESETPD4Hardware reset (active LOW)

The 3.5mm stereo audio output jack (CN6) is driven by the CS43L22. The I2C address is 0x94 (write) / 0x95 (read).

USB

USB OTG Connectors

The STM32F407 has two full USB OTG controllers. The Discovery board exposes both:

ConnectorControllerSpeedPinsUse Cases
CN5 (Micro-B)USB OTG FSFull Speed 12 MbpsPA11 (D−), PA12 (D+), PA9 (VBUS)USB Device (HID, CDC, MSC), USB Host
CN4 (Type-A)USB OTG HSHigh Speed 480 MbpsVia ULPI PHY chip on PORTBHigh-speed USB Host (mouse, keyboard, USB drive)
POWER

Power Supply System

Understanding the power system prevents frustrating “my board doesn’t work” scenarios. The Discovery board can be powered in multiple ways:

SourceConnectorVoltageNotes
USB ST-LINK (CN1)Mini-B5V USB → 3.3V LDOMost common — plug into PC for programming & power
USB OTG FS (CN5)Micro-B5V USB → 3.3V LDOUse when board acts as USB device powered by host
External VDDP1/P2 pins1.8V – 3.6VDirect power via expansion connectors, bypass LDO
External 5VP1/P2 pins5V → LDO → 3.3VUse when running from battery or external supply
⚠️ 3.3V Logic! The STM32F407 operates at 3.3V. While some pins are 5V tolerant (FT pins), the VDD supply must stay within 1.8V–3.6V. Never connect 5V directly to a non-5V-tolerant GPIO pin — it will damage the MCU.

Power domains on the STM32F407:

  • VDD (1.8–3.6V): Main digital power for CPU, Flash, peripherals
  • VDDA (1.8–3.6V): Analog power for ADC, DAC, comparators, oscillators. Should be filtered separately.
  • VBAT (1.65–3.6V): Battery backup domain — powers RTC, backup SRAM, LSE oscillator when main VDD is off
  • VDD_USB: Regulated separately for USB transceiver (typically from a 3.3V LDO fed by 5V USB)
CLOCKS

On-Board Crystals

The Discovery board has two crystal oscillators:

CrystalFrequencyPinsPurpose
Y1 (HSE)8 MHzPH0 / PH1 (OSC_IN / OSC_OUT)High-Speed External oscillator. PLL source to reach 168 MHz. More accurate than internal 16 MHz RC (HSI).
Y2 (LSE)32.768 kHzPC14 / PC15 (OSC32_IN / OSC32_OUT)Low-Speed External oscillator. Powers the RTC (Real Time Clock) for accurate timekeeping. This exact frequency divides evenly to 1 Hz (2^15 = 32768).
💡 Why 32.768 kHz for RTC? This frequency is exactly 215. A 15-bit binary counter at 32768 Hz overflows exactly once per second — making it trivial to implement a 1-second RTC tick without any division logic. This standard goes back to wristwatch quartz oscillators.
CONNECTORS

Extension Connectors (P1 and P2)

Two 50-pin expansion connectors (P1 and P2) break out all user-accessible STM32F407 pins. These are the connectors you use to wire up external sensors, displays, and modules on a breadboard.

ConnectorSideKey Pins Available
P1Left edgeGPIOE (PE0–PE15), GPIOD (PD0–PD15), PC0–PC7, GND, VDD
P2Right edgeGPIOA (PA0–PA15), GPIOB (PB0–PB15), PC8–PC15, GND, VDD, VBAT

Pin numbering on the connectors starts from pin 1 (marked with a dot on the PCB silkscreen). The pitch is 2.54mm (0.1 inch), compatible with standard jumper wires and breadboards.

What You’ve Learned in This Tutorial
  • The STM32F407VGT6 is a 168 MHz Cortex-M4 with 1MB Flash and 192KB SRAM
  • The on-board ST-LINK V2 uses SWD to program/debug without extra hardware
  • 4 user LEDs on PD12–PD15, user button on PA0 (active HIGH)
  • LIS3DSH accelerometer uses SPI1; CS43L22 audio codec uses I2C3 + I2S3
  • 8 MHz HSE crystal feeds the PLL to reach 168 MHz; 32.768 kHz LSE for RTC
  • Two 50-pin expansion connectors provide access to all GPIO
NAVIGATION ep-wrap

STM32F407 Discovery Tutorial Series — Tutorial 01: Board Overview

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 *