Stage 1 · Lesson 3 of 6
Bitwise operations and masks
are controlled by , and each bit or small group of bits in a register means something: enable the clock, set a pin as output, choose a speed. Bitwise operators let you change one bit without disturbing the others. OR with a mask sets bits, AND with an inverted mask them, XOR toggles them, and AND tests whether they are set.
Shifts build the mask, as in 1U << 5 for bit 5, and extract fields, as in (reg >> 4) & 0x0F for a 4-bit field. Practise reading hexadecimal (base 16) quickly, because datasheets write masks in hex.
Common trapwriting reg = mask when you meant reg |= mask, which wipes every other setting in the register and produces a bug that looks like a hardware fault.
A question to check yourself, an AI practice session and 1 cheat sheet entry come with the full roadmap. Unlock
Resources for this stage
Start with· follow one of these
- VideoFreeModern Embedded Systems Programming (video course)
Quantum Leaps (Miro Samek) · Intermediate
Free lessons that step down to the machine level: watch the first segment on C, bits, pointers and memory
- CourseFreeCS50: Introduction to Computer Science
Harvard University · Beginner
The weeks on C and memory give you pointers, arrays and malloc explained clearly, free