While bitwise operators are a core feature of the C language for anyone doing low level programming, people who know C mostly from application development sometimes struggle to come to grips with them. This quick primer explains some idioms commonly seen with microcontrollers as well as any other low level C programming.
So if you don’t really know what the bitwise operators are, or what they could possibly be good for, this is for you.
Table of Contents
00:00:40 Logical vs. bitwise operators
00:03:15 Left and right shift operators (<< and >>)
00:05:45 Using shift operators to manipulate individual bits in an integral type
00:07:05 Performance considerations, and what optimizing compilers do
00:08:20 Manipulating multiple bits simultaneously
00:09:00 Other not so obvious idioms
References
Follow-up is at BIVBlog #47: Better Ways to Manipulate Bits in C (not only) for Microcontrollers.