Embedded systems and IoT

Stage 1 · Lesson 6 of 6

Flash, RAM, stack and heap

C for embedded

A has , which keeps your program and constants when power is off, and a small amount of RAM for everything that changes. Initialised globals are copied from flash into RAM at start-up, zero-initialised globals are cleared, local variables live on the , and malloc takes memory from the heap.

A classic Arduino Uno has 2 KB of RAM; an or STM32 has far more, but still thousands of times less than a laptop. The build output tells you how much flash and RAM you used, and a map file shows where each item went. Keep large tables so they stay in flash.

Common trapputting a big array inside a function, which overflows the stack and corrupts other variables with no error message, causing crashes that look unrelated.

A question to check yourself, an AI practice session and 2 cheat sheet entries come with the full roadmap. Unlock

Resources for this stage

Start with· follow one of these

Practise

  • Compile and run C for a microcontroller in the browser before your board arrives

Keep handy

Also worth your time

Mark this stage as not done?