Bit manipulation in embedded C
Read bit masks, packed fields and byte ordering, and reason about how integer types affect firmware expressions.
Open free interactive lessonAll lessonsWhat the lesson covers
The course lesson is called The Sparrow board. One long night before a demo: a heater that kills the fan, a phantom alarm, a byte that reads as minus fifty-six, and the bit tricks that fix them.
- bits and hex
- two's complement
- masks and fields
- volatile and races
- endianness
- bitmaps
- XOR and CRC
Before you start
Question to think about: Which bits may change when updating a field inside a register value?
Preparation exercise: Draw a byte in binary, mark a field and compare the expected value before and after changing only that field.
This is an original public study prompt, not the paid lesson or its solution. The interactive course contains the walkthroughs, labs, exercises and recaps.
Related free reading
Test your understanding
Practice free firmware interview questions and mock interviews · Assess your readiness