Start here

What a Microcontroller Actually Is

A processor, its memory and a pile of peripherals sold as a part you solder down. Everything it can do reaches the outside world through pins — so that is where this explanation starts.

By The BenchChip Basics7 min readRead the explainer →
What a Microcontroller Actually Is
A processor, its memory and a pile of peripherals sold as a part you solder down.

The package, pin by pin

Fig. 1

Twenty-four pins, seven classes. Click any pin and the panel resolves to what that class of pin is for, what it needs from your board, and how many of them sit on a part like this one.

GENERIC QFP-24 01 · VDDPOWER class 02 · P0.0GPIO class 03 · P0.1GPIO class 04 · ADC0ANALOG class 05 · VREFANALOG class 06 · VSSGROUND class 07 · SWDIODEBUG class 08 · SWCLKDEBUG class 09 · NRSTRESET class 10 · P1.0GPIO class 11 · P1.1GPIO class 12 · VDDPOWER class 13 · P2.0GPIO class 14 · P2.1GPIO class 15 · ADC1ANALOG class 16 · VSSGROUND class 17 · P2.2GPIO class 18 · BOOT0BOOT class 19 · P3.0GPIO class 20 · BOOT1BOOT class 21 · VDDPOWER class 22 · VSSGROUND class 23 · SWODEBUG class 24 · P3.1GPIO class
Pin class · POWER

Supply

VDD / VCC

Every supply pin expects its own decoupling capacitor as close as the layout allows, because the pin is the end of a wire and every wire has inductance.

  • One capacitor per pin, not one per board
  • Bulk capacitance is a separate job
  • Analogue supplies often want their own filter
Typically two to six · 3 on this packageClick any pin →
Pin class · GROUND

Return

VSS / GND

On paper one symbol repeated forty times; on the board a network with geometry and impedance. Return current takes the easiest route home, not the one you drew.

  • Keep return paths short and under their signal
  • Separate analogue and digital returns where the part asks for it
  • Most drifting analogue readings are a ground problem
Typically two to six · 3 on this packageClick any pin →
Pin class · RESET

Reset

NRST

While reset is asserted the core executes nothing. How it is released, and how cleanly, decides whether the part starts at all.

  • Needs a defined level, not a floating pin
  • Watch the release slope
  • A brown-out detector is not optional in the field
Typically one · 1 on this packageClick any pin →
Pin class · BOOT

Boot strapping

BOOTn

Sampled once, at release of reset, to decide where the part starts executing. After that the same pin is usually something else entirely.

  • Read once, then repurposed
  • A pull resistor is cheaper than a mystery
  • Explains most ‘it works on my board’ failures
Typically one to three · 2 on this packageClick any pin →
Pin class · DEBUG

Debug and program

SWD / JTAG

The pins a programmer or debugger uses. Bring them to a header even on a board you think is final.

  • Two pins for SWD, four or five for JTAG
  • Keep them off anything that fights the debugger
  • A board with no debug header is a board you cannot rescue
Typically two to five · 3 on this packageClick any pin →
Pin class · GPIO

General purpose

Px.y

Everything else. Each is multiplexed onto several peripherals, and choosing which function lives where is a real design decision.

  • Check drive strength, not just voltage
  • Not every pin is 5 V tolerant
  • Peripheral conflicts are decided at pin-assignment time
Typically the remainder of the pins · 9 on this packageClick any pin →
Pin class · ANALOG

Analogue

ADC / VREF

Inputs that measure rather than switch, plus the reference they measure against. The reference is as important as the input.

  • A noisy reference is a noisy reading
  • Source impedance matters to the sampler
  • Keep switching currents away from these
Typically a few, varying by part · 3 on this packageClick any pin →

Fig. 1 — A generic package. These are pin classes, not a pinout. Work from the manufacturer’s documentation for any real part.

The Memory Types, Told Apart

Table 1

Five kinds of non-volatile memory that get used interchangeably in conversation and behave nothing alike. How a cell is written, and how much you must erase to change it, explains almost every other difference here.

Table 1 — five non-volatile memory types, told apart
TypeKeeps state unpoweredHow it’s writtenSmallest eraseWearWhat it’s for
Mask ROMYesAt manufacture, in the maskNot erasableNoneCode that will never change, at volume.
EEPROMYesByte at a time, in circuitOne byte~100k–1M cyclesSmall settings that change often.
NOR flashYesWord at a timeA whole sector~10k–100k cyclesProgram code you execute in place.
NAND flashYesA page at a timeA whole block~1k–100k cyclesBulk storage, with a controller managing wear.
FRAMYesByte at a time, fastNot required~10^12+ cyclesLogging, and anything written constantly.

For contrast: SRAM and DRAM are volatile. They hold your variables while the part is powered and forget everything the moment it is not. The full explainer →

Four Ways Firmware Gets In

Table 2

ISP, JTAG, SWD and a resident bootloader. The choice is usually made months before anyone flashes anything — on the schematic, when the pins are assigned.

Table 2 — the four ways firmware gets in
InterfaceWiresWhat it doesReach for it when
ISP3–4 + powerPrograms the part in circuit through a peripheral it already has.Production programming on a board with no debug need.
JTAG4–5Programs and debugs, and can chain several devices on one port.Boards with several programmable parts, or boundary-scan test.
SWD2 + powerPrograms and debugs over two wires — the usual choice on ARM parts.Almost always, on anything Cortex-M, if you have the pins.
Bootloader2 (a serial port) or noneThe part programs itself from code already resident in it.Field updates, or where no programmer will ever be attached.

Wire counts are the usual case, not a specification. When you would use each →

Firmware’s Journey

Walkthrough · 7 stages

From a text file to an instruction executing out of flash. Each stage produces something specific — and each has its own way of going wrong.

  1. 01

    Source

    Your .c and .h files, plus the vendor’s headers and startup code.

  2. 02

    Compile

    One object file per source file, with addresses still unresolved.

  3. 03

    Link

    A single image, symbols resolved, laid out by the linker script.

  4. 04

    Locate

    Sections placed at real addresses — code in flash, variables in RAM, constants where you said.

  5. 05

    Convert

    A hex or binary file: the bytes, and where each byte goes.

  6. 06

    Flash

    Those bytes written into non-volatile memory and verified.

  7. 07

    Reset

    The core released, the vector table read, and your first instruction executed.

Every stage in full, with what each one actually produces: From Source to Running Code →

On the bench

Newest first

Browse every section →

Also on the bench

Kept lit by

Makers and communities whose work shares space on this workbench.