Bitwise operators: Whats the difference ^= vs &= ~(smthg)?
^= x is XOR. It flips the state of bits.

&amp;= ~x is AND NOT. It clears bits.
^= x is only correct if toggling the bits is what you want to do every time this code runs. This might be correct if you wanted to flash an LED, for example, but it shouldn't be used if you want to ensure that the register ends up in a specific state.