I'm attempting to write a (very) short code in C as revision.
According to both my education and other posts such as;
How do you set, clear, and toggle a single bit?
the following code should place the value "1" into the variable ready, and yet, it places the value 64. All the other articles indicate that just the value of the tested bit is placed, not simply the result of the two numbers (number and (1 << x) ) and'ed together - which would indeed be 64! Is this the case or am I simply making an erroneous step?
uart->status |= (1<<6); //Set bit 6 to 1
char input = 0;
int ready = (uart->status) & (1<<6); //Should mean ready = 1?, a
if(uart->status & (1<<6) == 1) { //ready actually = 64
input = uart->rx;
} else {
input = 0;
}
Thanks very much!
David