All paths

Embedded C that survives

The rules that keep C alive on a chip with 2 KB of RAM, each one broken on the Uno first: 16-bit int overflow, a missing volatile on an interrupt flag, F() and PROGMEM saving SRAM, out-of-bounds writes and signed shifts, String running the heap dry, MISRA-style rules, and a satellite sketch to audit.

Arduino Uno R3Free7 lessons6 h3 chapters2,118 XPEmbedded engineering · Advanced+250 XP

0 of 7 done

What you will build

2 projects, built step by step

7 lessons in 3 chapters, about 6 hours on a simulated Arduino Uno R3. Free, in your browser, every step checked by the simulator.

Chapter 1 project

const and flash

The Uno has 32 KB of flash and only 2 KB of SRAM, and every string literal is copied into SRAM at boot. A sine table in PROGMEM costs nothing, and F() on one help text gives back 308 bytes.

Open it in the simulator
Chapter 2 project

Coding standards

A heater’s command parser written to MISRA-style rules: fixed-width types, named limits, every input range-checked, a static_assert, no heap, and a switch whose impossible case finally says something.

Open it in the simulator
The map

Chapter by chapter

Each lesson opens when the one before it is done, and each chapter ends in a project.

Chapter 1

Data on a small chip

What an int really is, what volatile does, and where const data lives.

  1. Open265 XP

    Fixed-width types

    An int is 16 bits on an Uno: five minutes in milliseconds comes out negative, a uint8_t counter wraps to 4, and a millis() interval stays right across the 49-day wrap. Fixed-width types say what you mean.

    0 of 6 steps

  2. Locked204 XP

    volatile

    The button’s interrupt runs, toggles the lamp and sets a flag, and loop() never sees it, because the optimizer kept the flag in a register. One keyword fixes it, and noInterrupts() makes a 4-byte read safe.

    0 of 5 steps

  3. ProjectLocked408 XP

    const and flash

    The Uno has 32 KB of flash and only 2 KB of SRAM, and every string literal is copied into SRAM at boot. A sine table in PROGMEM costs nothing, and F() on one help text gives back 308 bytes.

    0 of 5 steps

5 questions, graded as you go.
Chapter 2

Code that cannot surprise you

Undefined behavior, the heap, and rules a tool can check.

  1. Locked227 XP

    Undefined behavior

    A loop that runs one step too far writes the knob reading over the alarm limit next door, so the alarm can never fire; a shift into the sign bit goes negative. Both compile cleanly; both are undefined behavior.

    0 of 5 steps

  2. Locked227 XP

    Static allocation

    A telemetry log built with String eats the heap line by line until concat() fails at line 120; the same log in a fixed buffer, sized at compile time, runs for ever with the same largest free block.

    0 of 5 steps

  3. ProjectLocked484 XP

    Coding standards

    A heater’s command parser written to MISRA-style rules: fixed-width types, named limits, every input range-checked, a static_assert, no heap, and a switch whose impossible case finally says something.

    0 of 6 steps

4 questions, graded as you go.
Chapter 3

Boss project

Audit a satellite telemetry sketch with three hidden bugs.

  1. Locked303 XP

    Boss: audit the satellite

    A CubeSat telemetry sketch that compiles without a warning and has three bugs: a mission clock that overflows, a ground station call that loop() never sees, and a checksum written one byte past its buffer into the battery reading. Find each one, then fix it.

    0 of 7 steps

3 questions, graded as you go.
Syllabus

Every lesson in the course

All 7 lessons, in order, each with what it covers. Any of them opens in the editor right away.

Chapter 1

Data on a small chip

  1. Fixed-width typesAn int is 16 bits on an Uno: five minutes in milliseconds comes out negative, a uint8_t counter wraps to 4, and a millis() interval stays right across the 49-day wrap. Fixed-width types say what you mean.
  2. volatileThe button’s interrupt runs, toggles the lamp and sets a flag, and loop() never sees it, because the optimizer kept the flag in a register. One keyword fixes it, and noInterrupts() makes a 4-byte read safe.
  3. const and flashThe Uno has 32 KB of flash and only 2 KB of SRAM, and every string literal is copied into SRAM at boot. A sine table in PROGMEM costs nothing, and F() on one help text gives back 308 bytes.
Chapter 2

Code that cannot surprise you

  1. Undefined behaviorA loop that runs one step too far writes the knob reading over the alarm limit next door, so the alarm can never fire; a shift into the sign bit goes negative. Both compile cleanly; both are undefined behavior.
  2. Static allocationA telemetry log built with String eats the heap line by line until concat() fails at line 120; the same log in a fixed buffer, sized at compile time, runs for ever with the same largest free block.
  3. Coding standardsA heater’s command parser written to MISRA-style rules: fixed-width types, named limits, every input range-checked, a static_assert, no heap, and a switch whose impossible case finally says something.
Chapter 3

Boss project

  1. Boss: audit the satelliteA CubeSat telemetry sketch that compiles without a warning and has three bugs: a mission clock that overflows, a ground station call that loop() never sees, and a checksum written one byte past its buffer into the battery reading. Find each one, then fix it.
Kits

Build it on your bench too

Every lesson runs in the simulator with nothing to buy. When you want the real thing, these kits have the parts.

Have a kit already?

Find your kit

Pick the starter kit you own and run every lesson in its manual with the same parts on the same pins.

See every kit
Questions

About Embedded C that survives

Is Embedded C that survives free?

Yes. All 7 lessons of Embedded C that survives are free and run in your browser, with nothing to install and no parts to buy before you start.

Do I need a real Arduino Uno R3?

No. Every lesson runs on a simulated Arduino Uno R3 with its parts on the canvas, and the simulator checks each step as you go. When you want to build it for real, the same wiring and code work on a real board.

How long does Embedded C that survives take?

About 6 hours: 7 lessons in 3 chapters, each one a few short steps. Your progress is kept, so you can stop after any lesson and pick up where you left off.

What will I build?

Each chapter ends in a project that puts it together: const and flash and Coding standards.

Where do I start?

With "Fixed-width types", and each lesson builds on the one before it. New to circuits? Electronics basics is the course that starts from zero.