IT lexicon › Hardware › Write-one-to-clear (W1C)

Write-one-to-clear (W1C)

Hardware På svenska → Updated: 2026-11-04

Register bits that are cleared by writing a one to them, while writing a zero leaves them alone.

Peripheral status flags are set by hardware — byte received, transfer complete, interrupt pending — and acknowledged by firmware. If clearing meant writing a zero, you would have to read the register, mask and write it back, and a flag that arrived in between could vanish. With W1C you write a mask of exactly the flags you handled. The operation becomes atomic without disabling interrupts.

The trap is the habit of writing REG |= FLAG;. That reads every flag currently set and writes ones back to all of them, acknowledging events nobody has looked at yet. STM32 reference manuals label such bits rc_w1; to keep you alert there is also rc_w0, where it is the zero that clears.

← Back to the lexicon