This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Logical bit operation

Hello,

I have following code:
Unsigned int freq;
int N_counter[24]
freq=248;

N_Counter[15]=(freq& 0x0001); N_Counter[14]=(freq & 0x0002); N_Counter[13]=(freq & 0x0004); N_Counter[12]=(freq & 0x0008); N_Counter[11]=(freq & 0x0010); N_Counter[10]=(freq & 0x0020); N_Counter[9]=(freq & 0x0040); N_Counter[8]=(freq & 0x0080);

Since freq is equal to 11111000 then by doing and operation " N_Counter[15]=(freq & 0x0001);"for example "0" is coppied to N_counter[15] and so on all the way to N_counter[8].I expect these binaries to be coppied into N_counter[15] to N_counter[8] and I used this code with Micro vision 2 8051 compiler in the past but it's not working with MDK-ARM, For example "N_Counter[8]=(freq & 0x0080);" should result 1 copied to N_counter[8] but instead 0 is copied into N_counter[8].Can you help me with this problem?

0