View previous topic :: View next topic |
Author |
Message |
alecrp
Joined: 08 Aug 2006 Posts: 3
|
byte and nibbles |
Posted: Thu Sep 07, 2006 8:17 am |
|
|
hi someone can help me?
i read two byte from the serial port of my pic in two variable
.....
int value,value1;
value = getc();
value1=getc();
.....
i must put the high nibble of value and the low nibbe of value1 (4 bit and 4 bit) in value3;
how?
thanks. |
|
 |
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Thu Sep 07, 2006 8:51 am |
|
|
Did you try it ?
If so, please show us to see how you do it and we will help you.
Humberto |
|
 |
CCS JIM Guest
|
|
Posted: Thu Sep 07, 2006 8:54 am |
|
|
Use an and to clear out the lower nibble of value and then or it with the lower nibble of value1.
Code: |
value3 = (value & 0xf0) | (value1&0x0f);
|
If I mixed up the nibbles, just switch value and value 1. |
|
 |
|