Page 1 of 1

splitting 1 byte into 2 bytes

Posted: Tue Aug 11, 2009 3:40 am
by Ron
Hi,

I want to read analog input 10 bit, 0 - 1023. I need to separate the high nibble from the low nibble and and put each into it's own byte.

How would I do this?

Thanks

Ron

Re: splitting 1 byte into 2 bytes

Posted: Tue Aug 11, 2009 7:11 am
by Steve
Hi Ron,

I just want to clear up some terminology first... A byte is 8 bits of data and a nibble is half a byte (4 bits of data).

So your question should probably be "How to split up a 10-bit value into 8-bit bytes".

The answer is to use the MOD and / functions as below:

Code: Select all

HiByte = My10BitVal / 256
LoByte = My10BitVal MOD 256

Re: splitting 1 byte into 2 bytes

Posted: Tue Aug 11, 2009 7:46 pm
by Ron
Hi,

yes.... Boy, did I mess that one up......

10 bits.... yep...

Good thing these guys believe in the old saying.... Give me the answer I need, not for what I actually asked...

Thanks,

Ron