I've been working trying to read some C code and I've found some operators that I don't know:
What's the use of
|= operators when used for microprocessors programming?
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It only takes a minute to sign up.Sign up to join this community
These statements are equivalent:
x = x & 0x01;
x &= 0x01;
It means to perform a bitwise operation with the values on the left and right-hand side, and then assign the result to the variable on the left, so a bit of a short form. If you're not familiar with bitwise operations, I suggest you start getting familiar with those first - the
& being a bitwise AND and the
| being a bitwise OR.
Hope that helps!