Hardware interview practice
Clear a write-one-to-clear interrupt
STATUS bits are write-one-to-clear. Bit 2 is pending, and other bits may become pending between the firmware read and write. Which write clears only bit 2 without clearing newly pending unrelated bits?
Choose one
Answer choices
- A. Write zero to bit 2 and ones to every other bit so only bit 2 changes.
- B. Write `1u << 2` directly to STATUS.
- C. Read STATUS twice and write the bitwise OR of both readings back.
- D. Read STATUS, clear bit 2 in the read value, and write the modified full word back.
