C foundations for hardware
Syllabus
Detailed content
Types, integer behavior, and bit operations
Embedded hardware exposes registers and data fields at exact widths. Use fixed-width integer types where width matters, and understand signedness, overflow, shifts, masks, and integer promotion. Set or clear bits with explicit masks, and verify operations with tests or register-value inspection.
Pointers, arrays, and memory
Pointers hold addresses; arrays occupy contiguous elements, while a pointer is a separate value. Stack storage is limited and short-lived; static storage persists for the program; dynamic allocation may be unavailable or risky in firmware. Check bounds, ownership, and alignment before accessing memory-mapped or externally supplied data.
Headers, compilation, and debugging
A C program is preprocessed, compiled, assembled, and linked into a target image. Headers declare interfaces; source files define them. Cross-compilers produce code for a different processor than the host. Enable warnings, inspect linker maps, and use a debugger or hardware probe to examine registers and execution.