I am having a very strange problem with masking bits.
1 uint8_t lsb, msb;
2 uint16_t zac;
3 zac = (uint16_t)(lsb|(msb<<8));
4 // if((zac & 0x0001) == 0) TODO
5 // return false;
6 zac = zac >> 0x0001UL;
I put a break point at line 6 and I see the original zac which is 18827, but then I step over one line (so that line 6 is executed) and I get
a wrong result: 9246.
9246 : 0010010000011110
The result I would expect is: 0010010011000101 = 9413.
I tried changing 0x0001UL with 0x01, 1... Does not help.
Also lines 4 and 5 don't execute properly. The code is suppose to check the lsb bit, and return false if it is zero. But it returns false for zac = 18827.
I am using Atmel ATMEGA256RFR2 Xplained pro board in Atmel Studio 7.8.
Thank you for your help.