Question.4
A UART control register has the following 8-bit layout:
| 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|---|---|---|---|---|---|---|---|
| — | PARITY | BAUD | EN | ||||
The register currently holds 0x1F. A developer needs to change the BAUD field to 3 without affecting other bits.
Code A:
reg &= ~(0x07 << 1);
reg |= (3 << 1);Code B:
reg &= ~(0x07 << 1);
reg |= (3 << 2);Code C:
reg = (reg & 0xF1) | (3 << 1);Code D:
reg |= (3 << 1);Which code(s) is/are correct?
Note: Multiple options may be correct.