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

Why this shift doesn't run?

Hi,

I've the following question about this code fragment:

...
char  BuffRX
xdata UCHAR BuffRX[10];
idata unsigned short ValCRCcomp;
idata unsigned short ValCRCappo;
idata unsigned short ValCRCappo2;

BuffRX[1] = 0x11;
BufRX[2] = 0x2A;
...
ValCRCappo = (unsigned short) (BuffRX[1] << 8);
ValCRCappo2 = (unsigned short) (BuffRX[2] | 0x0000);
ValCRCcomp = (unsigned short)  (ValCRCappo | ValCRCappo2);
...


Even the values in BuffRX[1] and BuffRX[2] are differents from zero, ValCRCcomp is always zero!

Any hints?

Thanks

Parents
  • ValCRCappo = (unsigned short) (BuffRX[1] << 8);
    Fix this as I said in my previous post above; otherwise, all bets are off.
    ValCRCappo2 = (unsigned short) (BuffRX[2] | 0x0000);
    ValCRCappo2 should hold the value 0x002A at this point.
    ValCRCcomp = (unsigned short)  (ValCRCappo | ValCRCappo2);
    Because of the undefined shift result, ValCRCcomp could have any value, but I simply can't imagine it being zero despite the bad shift.

Reply
  • ValCRCappo = (unsigned short) (BuffRX[1] << 8);
    Fix this as I said in my previous post above; otherwise, all bets are off.
    ValCRCappo2 = (unsigned short) (BuffRX[2] | 0x0000);
    ValCRCappo2 should hold the value 0x002A at this point.
    ValCRCcomp = (unsigned short)  (ValCRCappo | ValCRCappo2);
    Because of the undefined shift result, ValCRCcomp could have any value, but I simply can't imagine it being zero despite the bad shift.

Children
No data