Just added: Embedded C From Zero
All topics / Embedded C From Zero

Embedded C From Zero

Learn embedded C from zero: program a microcontroller and write bare-metal firmware for the AVR ATmega328P (Arduino Uno). Registers, GPIO, volatile, bit manipulation, interrupts, timers, PWM, and serial - read along and run every example in Wokwi, a free in-browser simulator, no hardware needed.

Download EPUB
  1. What "Embedded" Even Means What bare metal actually means: no operating system, no terminal, no printf, kilobytes of RAM, and a main() super-loop that never returns. Blink your first LED on the AVR ATmega328P in a browser with Wokwi, no hardware needed.
  2. The C That Changes The C subset that matters on a microcontroller: fixed-width types from stdint.h and why plain int has no guaranteed size, what volatile does and the exact bug you get without it, why malloc is avoided, and the flash-versus-RAM-versus-registers memory map of the AVR ATmega328P.
  3. Bit Manipulation, Properly Set, clear, toggle, and test individual bits in C with the four canonical patterns - x |= (1 << n), x &= ~(1 << n), x ^= (1 << n), and x & (1 << n). Masks, read-modify-write, and the operator-precedence gotcha that bites every embedded programmer.
  4. Talking to Hardware: Registers and GPIO What a hardware register actually is - a memory address wired to physical pins - and how to use one. Blink an LED and read a button on the AVR ATmega328P with DDRx, PORTx, and PINx, why floating inputs read noise, and how the internal pull-up resistor fixes it. Runs in the free Wokwi simulator.
  5. Timing and Interrupts Polling versus interrupts, and why busy-waiting wastes the CPU and misses fast events. What an interrupt service routine is and its rules, the volatile-flag pattern for sharing data with the main loop, why mechanical buttons bounce, and using a hardware timer instead of delay. A worked AVR external-interrupt example with ISR(INT0_vect), EIMSK, and sei() that runs in Wokwi.
  6. A Peripheral Tour: PWM, Serial, and Sensors The three peripherals that connect a microcontroller to the real world: PWM to fake an analog output and dim an LED, UART serial as your firmware's printf and main debug tool, and the ADC to read an analog sensor - one clear ATmega328P example each.
  7. The Toolchain and the Real Workflow How embedded development actually works day to day: cross-compiling with avr-gcc for a chip your PC can't run, flashing the binary with avrdude and the bootloader, living inside a 2 KB RAM budget, and debugging hardware you can't easily breakpoint.
  8. Where to Go Next The on-ramps out of the Uno: bare registers versus a vendor HAL or CMSIS, a one-page intro to what an RTOS task is and why FreeRTOS exists, and the real boards to graduate to - STM32, ESP32, and the Raspberry Pi Pico - plus the datasheets worth reading.