Hi all, I just want to ask why I cannot use this in C51:
... sbit INPUT1 = P0 ^ 0; sbit INPUT2 = P0 ^ 1; #define CHECK_INPUT ((INPUT1 << 7) | (INPUT2 << 6))
When try using it:
while(1) { ... unsigned char temp; temp = CHECK_INPUT; ... }
When compiled, the error: *** ERROR C193 IN LINE 40 OF xxx.c: '<<' : bad operand type
What should be the best thing to do? And why the error occur?
regards gee
Even if you could do it (which, evidently, you can't), what is the point of it?
#define CHECK_INPUT ((INPUT1 << 7) | (INPUT2 << 6))
The shift makes absolutely no difference whatsoever to the true/false value; so the above is exactly equivalent to:
#define CHECK_INPUT ((INPUT1) | (INPUT2))
Hi Andy, Thanks for your quick reply.
I actually want that two bits place in the upper nibble (MSB) of a byte.
thanks for your good suggestion.
View all questions in Keil forum