Embedded systems and IoT

Stage 1 of 10 · 7 lessons · ~6 weeks

C for embedded

Learn the C ideas every embedded engineer needs, bits, registers, pointers and memory, and set up Python properly on Raspberry Pi OS for the application code you will write.

Start: Why C still runs the hardware

Lessons· one lesson for each topic, in this order

  1. 1Why C still runs the hardware
  2. 2Fixed-width integer types
  3. 3Bitwise operations and masks
  4. 4Pointers and memory-mapped registers
  5. 5volatile and compiler optimisation
  6. 6Flash, RAM, stack and heap
  7. 7Python on the Pi, and when C matters

Do this

  • Write set, clear, toggle and test macros for a bit and use them on a variable.
  • Rewrite an old exercise using only stdint.h types.
  • Trace five pointer snippets on paper, then run them to check.
  • Build a program for your board or a simulator and read its flash and RAM use.
  • Break a program by removing volatile from an interrupt flag with optimisation on, then fix it.

Start with· follow one of these

Keep handy

Also worth your time

Before moving on: A small C program, compiled for your board or a simulator, that sets, clears and tests bits in a variable standing in for a register, uses only stdint types, and prints its memory use from the build output.

Tauseef's advice
You will write Python on the Pi, but do not skip this stage. Registers, masks and memory explain what gpiozero and every driver are doing, and you will need C the day you add a Pico or read a sensor's register map.

Mark this stage as not done?