We’re Officially Live — Lifetime Founding Membership Available for a Limited Time
Free preview

Inside an MCU

The block diagram demystified: a CPU core, flash and SRAM, and peripherals wired together by internal buses, and why peripherals working in parallel with the CPU is the whole point.

20 min read

In this lesson:


Three kinds of blocks

Open any MCU datasheet to the block diagram and you'll see dozens of boxes. They all fall into three categories:

  1. The CPU core, fetches, decodes, and executes instructions. On the chips in this course, an ARM Cortex-M core.
  2. Memory, flash (non-volatile, holds your program) and SRAM (volatile, holds your data/stack/heap).
  3. Peripherals, dedicated hardware blocks that do specific jobs: GPIO, UART, SPI, I²C, timers, ADC, DAC, DMA, and more.

They're connected by internal buses that carry addresses and data between them.

flowchart TB
  CPU["Cortex-M core<br/>(ALU, registers, NVIC)"]
  subgraph BUS["bus matrix"]
    direction LR
    AHB["AHB (fast)"] --- APB["APB (slower peripherals)"]
  end
  CPU --> BUS
  BUS --> FLASH["Flash<br/>(program)"]
  BUS --> SRAM["SRAM<br/>(data/stack)"]
  BUS --> PERIPH["Peripherals<br/>GPIO · UART · SPI · I2C<br/>Timers · ADC · DAC · DMA"]

The CPU core

The core is where instructions run. A Cortex-M core contains the arithmetic/logic unit, a small set of fast registers, an instruction pipeline, and, integrated right into the core, the NVIC (Nested Vectored Interrupt Controller) that manages interrupts, plus the SysTick timer. Higher-end cores add an FPU (floating-point unit) and an MPU (memory protection unit).

It executes your program by fetching instructions from flash, decoding them, and operating on data in registers and SRAM. Everything else on the chip exists to feed it or to act on its behalf.


Memory: flash vs SRAM

Flash SRAM
Volatile? No, keeps contents with power off Yes, lost on power-down
Holds program code, const data variables, stack, heap
Speed slower (may need wait-states at high clock) fast (single-cycle)
Writes slow, erase-before-write, limited cycles fast, unlimited
Size larger (tens of KB-MB) smaller (KB-hundreds of KB)

Your code runs from flash; your data lives in SRAM. We map this out in detail in the next lesson.


Peripherals: hardware that offloads the CPU

A peripheral is a dedicated hardware block that performs a specific function without the CPU doing the work bit-by-bit. This is the single most important idea in embedded:

Without peripherals:  CPU bit-bangs everything → no cycles left for real work
With peripherals:     CPU configures the block, then does other work
                      while the peripheral runs in PARALLEL

You interact with a peripheral by reading and writing its registers, special memory addresses that control it and report its status (next lesson). The CPU sets up the peripheral, then the peripheral runs autonomously and signals back via flags or interrupts.


Buses: AHB and APB

The core and peripherals don't all sit on one wire. ARM MCUs use a hierarchy:

This is why peripherals are grouped by bus in the datasheet and why each bus has its own clock prescaler (clock-tree lesson). Bus bandwidth is finite, the CPU and DMA can contend for the same bus, which matters for performance tuning.


Everything is memory-mapped

The crucial unifying concept: memory and peripheral registers all live in one flat address space. Reading address 0x2000_0000 might hit SRAM; reading 0x4002_0014 might read a GPIO input register. To the CPU it's all just loads and stores, which is exactly why C pointers can reach hardware (the registers lesson builds on this).


Gotchas


TL;DR

This is just the start

Sign up free to track progress on this lesson, get coding problems with the Run button, and unlock the full interview Q&A.

More in Embedded Systems Fundamentals

What Is an Embedded System?The Memory Map
Registers & Memory-Mapped I/O
GPIO: Digital I/O
Interrupts & ISRs
Timers & Counters