-
Quick Question
Hi There,
I have a 16 bit number which is a reading from a register, i want to break it down so
bit 8 =ee8
bit7 = ee7
bit6 = ee6
etc
so can later in code simple go if(ee8 = 1) ........
whats the easiest way to asign the variables names to the specific bits in the orginal 1bit number
thanks
-
O_o
You can't directly address a single bit in C (or most hardware for that matter).
If you feel you must have this sugar, either write a macro or use a "bit field".
Soma
-
Or use a function to extract the relevant bit. To implement that function, look up bitwise operators.
I wouldn't use a bit field, as the layout of bit fields is implementation defined. Although that may be a moot point, as the location of particular registers is also well outside what the standard specifies.