How to make two 8bit numbers from a 10bit number?


hi group,

i have ten bit number need split 2 8 bit numbers.  the first 8 bit number needs have 3 zeros followed first 5 bits of 10 bit number.  the second 8 bit number needs start last 5 bits of 10 bit number, followed 3 zeros.  like example below:

original 10 bit number:  b1101111101
turn into:  b00011011   &   b11101000

this serial transmission (spi) program i'm working on.

any suggestions?

thanks,
patrick

patrick,

i haven't tested this, think work:
code: [select]
int tenbits = 0x37d;  // b1101111101
byte b1;
byte b2;

b1 = (tenbits >> 5) & 0x1f;
b2 = (tenbits << 3) & 0xf8;


regards,

-mike


Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > How to make two 8bit numbers from a 10bit number?


arduino

Comments

Popular posts from this blog

CAN'T INSTALL MAMBELFISH 1.5 FROM DIRECTORY - Joomla! Forum - community, help and support

error: expected initializer before 'void'

CPU load monitoring using GPIO and leds - Raspberry Pi Forums