Recall & Review
beginner
What does setting a bit in a register mean in embedded C?
Setting a bit means changing that bit to 1 without affecting other bits in the register. This is usually done using the OR operator (|) with a mask that has 1 at the bit position to set.
Click to reveal answer
beginner
How do you clear a specific bit in a register?
To clear a bit (set it to 0), use the AND operator (&) with the inverse (~) of a mask that has 1 at the bit position you want to clear. This keeps other bits unchanged.
Click to reveal answer
intermediate
Explain toggling a bit in a register.
Toggling a bit means flipping it: if it was 0, it becomes 1; if it was 1, it becomes 0. Use the XOR operator (^) with a mask that has 1 at the bit position to toggle.
Click to reveal answer
beginner
What is a bit mask and why is it important?
A bit mask is a binary number used to select or modify specific bits in a register. It helps isolate or change bits without affecting others, making bit manipulation safe and precise.
Click to reveal answer
beginner
How do you check if a specific bit is set in a register?
Use the AND operator (&) with a mask that has 1 at the bit position. If the result is not zero, the bit is set (1); if zero, the bit is clear (0).
Click to reveal answer
Which operator is used to set a bit in a register without changing other bits?
✗ Incorrect
The OR operator (|) sets bits to 1 where the mask has 1, leaving other bits unchanged.
How do you clear bit 3 of a register named REG?
✗ Incorrect
Using AND with the inverse mask clears bit 3 without affecting other bits.
What does toggling a bit mean?
✗ Incorrect
Toggling flips the bit: 0 becomes 1, and 1 becomes 0.
Which operator helps check if a bit is set?
✗ Incorrect
AND with a mask isolates the bit to check if it is set.
Why use a bit mask in register manipulation?
✗ Incorrect
Bit masks help target specific bits without affecting others.
Describe how to set, clear, toggle, and check a bit in a register using bitwise operators.
Think about how each operator affects bits when combined with a mask.
You got /4 concepts.
Explain the role of a bit mask in register bit manipulation and why it is important.
Consider how you can change one light bulb in a string without turning off others.
You got /4 concepts.