CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

byte and nibbles

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
alecrp



Joined: 08 Aug 2006
Posts: 3

View user's profile Send private message

byte and nibbles
PostPosted: Thu Sep 07, 2006 8:17 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Sep 07, 2006 8:51 am     Reply with quote

Did you try it ?
If so, please show us to see how you do it and we will help you.


Humberto
CCS JIM
Guest







PostPosted: Thu Sep 07, 2006 8:54 am     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group