I'm receiving 2 bytes from a communication and then i need to merge these 2 values to obtain a 16 bit value.
Now suppose that I expect to receive the number 200, then the two characters are a and b
char a=0x00;
char b=0xc8;
int cw = (a << 8) | b ;
printf("cw= %d\n",cw);
Doing the merge the variable cw becomes -56 instead of 200
If i change char by unsigned char i got the correct value 200 How can i fix that? i expect to receive both positive and negative numbers and of course the number 200