Reading Datasheets vs Reference Manuals
Embedded → Firmware Toolchain & Datasheets
Two different documents, two different jobs
A datasheettells you what a chip can survive and how it's wired. A reference manual tells you how to program it — every register, every bit field. The real job skill is knowing which one answers your question and skimming straight to it. The video covers this in depth.
Decoding a register table
Every register field is tagged with an access type — get this wrong and a driver silently fails:
| Access type | Meaning | Example |
|---|---|---|
| rw | normal read/write | a GPIO mode field |
| ro | hardware sets it, you only observe | a status flag |
| rc_w1 | hardware sets it, write 1 to clear | an interrupt-pending flag |
rc_w1 flag with REG &= ~(1u << n) silently does nothing — that write pattern is for plain rw bits, not write-1-to-clear ones.From register table to C, using GPIO as the worked example
GPIOx_MODER uses 2 bits per pin, so pin n's field sits at bit 2n: 00=input, 01=output, 10=alt-function, 11=analog. Setting PA5 to output means writing 01into bits 10-11 without disturbing every other pin's field:
#define GPIOA_MODER (*(volatile uint32_t *)0x40020000) // Clear PA5's 2-bit field first — MODER defaults every pin to input (00), // so a stray leftover value from a previous config could leave bit 11 set. GPIOA_MODER &= ~(0x3u << (5 * 2)); // Now write 01 (general-purpose output) into that same 2-bit field. GPIOA_MODER |= (0x1u << (5 * 2));
Try it — decode a register table by clicking its fields
Click a field in the mock GPIOA_MODER value below to see how the reference manual's table would describe it — this is the actual mental motion of reading a register table.
Practice
Completion saves automatically after you read through to the end.
Next lesson →