I think there is a mistake in the reference manual describing the compound |=. It reads:
Consequently - to set bits 0 & 1 of a variable, while leaving the rest of the variable unchanged, use the compound bitwise AND operator (&=) with the constant B00000011
It is a bit misleading the OR operation allows you to set bits with out affecting other bits while the AND operation allows you to clear bits without affecting anything else.
For the OR a 0 in the mask leaves the bit alone
a 1 in the mask sets a bit.
For and AND operation a 1 in the mask leaves the bit alone
a 0 in the mask clears a bit.
"Warning
Make sure you don't mistake the boolean AND operator, && (double ampersand) for the bitwise AND operator & (single ampersand). They are entirely different beasts.
Similarly, do not confuse the boolean || (double pipe) operator with the bitwise OR operator | (single pipe).
The bitwise not ~ (tilde) looks much different than the boolean not ! (exclamation point or "bang" as the programmers say) but you still have to be sure which one you want where. The example you posted is showing a bitwise OR operator."
A boolean operator ends up with just a true or false result, a bitwise operator ends but changing or not changing bits in the variable depending on the mask value and operator used.
I think the important word in the original post is the word AND.
Consequently - to set bits 0 & 1 of a variable, while leaving the rest of the variable unchanged,
use the compound bitwise AND operator (&=) with the constant B00000011
1 0 1 0 1 0 1 0 variable
0 0 0 0 0 0 1 1 mask
----------------------
1 0 1 0 1 0 1 1
How is the lsb ANDed to 1?
Or am I barking up the wrong tree.
The page in error is Arduino - Home, right? It looks to me like the section on compound bitwise OR may have been copied from the compound bitwise AND section, and not all text was updated.
Consequently - to set bits 0 & 1 of a variable, while leaving the rest of the variable unchanged, use the compound bitwise AND operator (&=) with the constant B00000011
should be changed to this:
Consequently - to set bits 0 & 1 of a variable, while leaving the rest of the variable unchanged, use the compound bitwise OR operator (|=) with the constant B00000011