Complete the code to write the value 0xFF to the hardware register.
volatile uint8_t *reg = (volatile uint8_t *)0x4000; *reg = [1];
The value 0xFF is the correct hexadecimal value to write all bits set to 1 in an 8-bit register.
Complete the code to set bit 3 of the hardware register without changing other bits.
volatile uint8_t *reg = (volatile uint8_t *)0x4000; *reg |= [1];
Bit 3 corresponds to the value 0x08 (binary 00001000). Using bitwise OR sets this bit without affecting others.
Fix the error in the code to clear bit 2 of the hardware register without changing other bits.
volatile uint8_t *reg = (volatile uint8_t *)0x4000; *reg &= [1];
To clear bit 2 (value 0x04), use bitwise AND with the complement of 0x04 (~0x04). This clears bit 2 and keeps others unchanged.
Fill both blanks to toggle bit 1 of the hardware register using XOR.
volatile uint8_t *reg = (volatile uint8_t *)0x4000; *reg [1]= [2];
Using XOR (^) with 0x02 toggles bit 1 without affecting other bits.
Fill all three blanks to write the value 0xAA to the register, then clear bit 7 and set bit 0.
volatile uint8_t *reg = (volatile uint8_t *)0x4000; *reg = [1]; *reg &= [2]; *reg |= [3];
First, write 0xAA to the register. Then clear bit 7 by ANDing with ~0x80. Finally, set bit 0 by ORing with 0x01.