Register Bitfield Builder

Compose a register from named bit fields — or decode a value back. Click any bit to toggle.

namehilovalue
Bit map — click to toggle

Pack the bits, don't fight them

Configuring an MCU peripheral means packing several values into one register at specific bit positions. The value of one field sitting at bits [hi:lo] is shifted into place and OR-ed with the others:

reg = (ENABLE  << 0)
    | (MODE    << 1)
    | (PRESC   << 4)
    | (IRQ_EN  << 16);

Each field is masked to its width before shifting, so an out-of-range value can't spill into the neighbouring field. This tool does that both ways: edit a field and watch the hex assemble, or paste a register value and read off what every field decodes to — exactly the round-trip you do against a reference manual. Click any bit in the map to flip it and see which field it belongs to.