Technical requirements
You can find the code files for this chapter on GitHub at https://github.com/PacktPublishing/Embedded-Systems-Architecture-Second-Edition/tree/main/Chapter6.
Bitwise operations
The examples associated with this chapter make extensive use of bitwise operations for checking, setting, and clearing single bits within larger registers (in most cases, 32-bit long). You should already be familiar with bitwise logic operations in C.
The operations commonly used in the examples are the following:
- Setting the Nth bit in the register R via the assignment
R |= (1 << N)
: The new value of the register R will contain the result of the bitwiseOR
operation between its original value and a bitmask containing all zeros, except the bit corresponding to the value we want to set, which is set to the value one - Clearing (resetting) the Nth bit in the register R via the assignment
R &= ~(1 << N)
: The new value of the register is the result of a bitwise...