Register maps: reading a byte
Where everything so far pays off: a single byte is a chip's control panel. Learn to read it, and you can bring up almost any chip from its datasheet.
Built from first principles. This is the bridge to understanding microcontrollers.
Before you start
What you need first
- Number bases & place value — the bit positions in a byte.
- Base conversions — turning a hex byte into its 8 bits.
What you'll be able to do
- Say what a register and a register map are.
- Decode a byte into the settings of a bit-field table.
- Avoid the three classic beginner mistakes.
A chip's control panel
Think of a chip as a tiny machine with a control panel inside. Each switch turns one feature on or off — and in real silicon those switches are just bits. A small group of bits is a register.
A register map is the table in the datasheet that says what each bit does. To configure the chip you write the right bit pattern into the right register; to see what it's doing you read a register and decode its bits.
0xD8 shows all 8 switches at a glance.Example: a desk fan's control register
Real sensors, motor drivers and displays all work this way — but let's use a familiar device. One 8-bit register holds all of a desk fan's settings, and the datasheet says what each bit (or group of bits) does:
| Bit(s) | Name | What it controls |
|---|---|---|
| 7 | POWER | 1 = fan ON, 0 = OFF |
| 6–5 | SPEED | 00 low · 01 medium · 10 high · 11 turbo |
| 4 | SWING | 1 = swing left–right, 0 = still |
| 3 | TIMER | 1 = auto-off timer on |
| 2 | BEEP | 1 = beep on button press |
| 1–0 | — | unused (leave as 0) |
You read 0xD8 from the fan. What is it doing?
| POWER (7) | SPEED (6–5) | SWING (4) | TIMER (3) | BEEP (2) |
|---|---|---|---|---|
| 1 → ON | 10 → high | 1 → swing | 1 → on | 0 → off |
0xD8 means: fan ON, running high, swinging, timer
set, beep off — five settings packed into one byte.✏️ Try it yourself
You read 0xA4 from the same fan. What is it doing?
0xA4 = 1010 0100.
Decode: POWER 1 = ON; SPEED 01 = medium; SWING 0 = not swinging; TIMER 0 = off; BEEP 1 = on.
In words: ON at medium speed, not swinging, no timer, beeps on button press.
Three things beginners get wrong
- Which end is bit 0? Most tables put bit 0 on the right (the smallest place value), but always check the datasheet's own picture before counting.
- Leave "unused"/"reserved" bits as 0. Setting them to 1 can make the device behave strangely.
- To change one switch, don't wipe the others. Read the current byte, change just that one bit, then write the whole byte back. This read–modify–write habit is essential.
0xD8
and you want to turn the beep on (bit 2). Writing 0x04 would switch
everything else off. Instead, take 0xD8, set bit 2, and write that
whole new byte (0xDC).Why this skill matters
Every modern chip — a sensor, an ADC, a motor driver, a microcontroller peripheral — is configured and read through registers exactly like this. Whatever you build, the same skill applies: convert fluently between hex and bits, and read a bit-field table.
Recap — the whole topic on one screen
| Idea | What you own now |
|---|---|
| Register | A small group of bits (usually 8/16/32) inside a chip |
| Register map | The datasheet table saying what each bit does |
| Decode a byte | Hex → bits → match each bit-field to the table |
| Pitfalls | Bit-0 end · reserved bits stay 0 · read–modify–write |