🔲

Bit Field Register Visualizer

Enter a 32-bit hex value to visualize individual bits. Click any bit to toggle it.

Hex Input
32-bit Visualization (click to toggle)
Binary
—
C Initialization Code Generator
—
Decoded Values
Decimal—
Hex—
Set Bits—
💡 Usage & Formula

Bit Field Visualizer breaks down 32-bit registers into readable binary grids, allowing engineers to quickly inspect register values.

Formulas:

  • Value: Sum(Bit_i * 2^i)

Usage: Input a hexadecimal register value. Click any bit in the grid to toggle it. The decimal, binary, and C macro initialization code will update instantly.

When you need it: Laying out or decoding an MCU peripheral register — packing flags and multi-bit fields into one word, or reading a hex value back into named fields while bringing up a driver.

Worked example: A control register with EN[0], MODE[2:1], PRESCALER[7:4]. To set EN=1, MODE=2, PRESCALER=3 → (1<<0) | (2<<1) | (3<<4) = 0x35. Reading it back, PRESCALER = (0x35 >> 4) & 0xF = 3.

Tips & gotchas:

  • Read with mask-after-shift: (v >> pos) & mask; write with read-modify-write and clear the field first.
  • Declare memory-mapped registers volatile so the compiler doesn't cache or reorder accesses.
  • Read-modify-write on a register shared with an ISR is a race — disable the interrupt or use bit-banding/atomic set-clear registers.
  • Preserve reserved bits: read them, keep their value, and don't blindly write zeros.