Question.1
A timer peripheral's 8-bit config register has a 3-bit prescaler field at bits 2–4:
The register currently holds 0xFF. A developer clears the prescaler field:
0xFF
reg &= ~(0x0F << 2);
What's wrong?
Select Answer
Nothing — it correctly clears bits 2–4
The mask 0x0F is 4 bits wide but the field is only 3 bits — bit 5 is also cleared, corrupting the adjacent field
0x0F
The shift should be 3, not 2
The ~ operator is unnecessary for clearing
~