PORTB.B2 = Temp & 0b00000010;
It will return 2 or 0. Some compilers when casting a byte to a bit simple use the bottom bit and so this will also be wrong.
This is exactly the thing that was puzzling me. I've never liked the "PORTB.2" notation because I don't know exactly how the compiler handles it.
Of course it would be easy to read the compiler specs.. or the generated assembly. But I think the code itself should be unambiguous.
Last edited: