GrandAlf
Advanced Member level 2
keil variable types
I have an int variable that in certain parts of the program contains a number less than 255. I need to send this as a single byte to the serial port (SBUF=xx). Just before transmitting I copy the contents to a char variable and send that instead, at the other end the numbers 1,2,3 are received ok, but 4,5,6 etc are not. I cannot directly use a char variable, as in other parts of the program it need to be 16bits. Have also tried sending int variable directly. Also with AND to mask out upper byte, and with >>4 and <<4 to shift bits. None of these attempts seem to work correctly. I would be most appreciative of any advice.
I have an int variable that in certain parts of the program contains a number less than 255. I need to send this as a single byte to the serial port (SBUF=xx). Just before transmitting I copy the contents to a char variable and send that instead, at the other end the numbers 1,2,3 are received ok, but 4,5,6 etc are not. I cannot directly use a char variable, as in other parts of the program it need to be 16bits. Have also tried sending int variable directly. Also with AND to mask out upper byte, and with >>4 and <<4 to shift bits. None of these attempts seem to work correctly. I would be most appreciative of any advice.