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

How to send 10 bit ADC value as 2 bytes

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



Joined: 26 Feb 2004
Posts: 11

View user's profile Send private message

How to send 10 bit ADC value as 2 bytes
PostPosted: Thu May 20, 2004 1:04 pm     Reply with quote

I'm reading the PIC ADC in 10 bit mode and storing the result in an int16 type. I need to break up the 10 bit value into two bytes so I can send them over the network. At the other end I need to combine the two bytes back into a 10bit value and store in another int16 type. Problem is I can't get this to work. I tried the make8() and it's not doing the job. Does anyone have a solution for this?

for e.g. If my ADC = 504 the highByte should be 0x01 and lowByte should be 0xF8
But using the make8() returns highByte = 0x19 and lowByte = 0xBC

What's going on?
Thanks
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Thu May 20, 2004 1:32 pm     Reply with quote

You should be using make16().

int16 variable;
variable = make16(high_byte, low_byte);

Try that.

Ronald
doug_h



Joined: 26 Feb 2004
Posts: 11

View user's profile Send private message

Fixed
PostPosted: Thu May 20, 2004 1:45 pm     Reply with quote

Thx. I had a bug in my code in the calling function - all fixed now.
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