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

hex 2 dec

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



Joined: 19 Jul 2009
Posts: 11

View user's profile Send private message

hex 2 dec
PostPosted: Mon Aug 03, 2009 6:32 pm     Reply with quote

Well there is a slight problem for me.
Can I convert a hex value (which I get as char byte) to decimal value and then transmit that as my output ?
I am using C to program my 16F76.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Aug 04, 2009 12:17 am     Reply with quote

Quote:
Can I convert a hex value (which I get as char byte)


1. What device sends the "hex value" to your PIC ?

2. Explain what you mean by a "char byte".
myumair



Joined: 19 Jul 2009
Posts: 11

View user's profile Send private message

PostPosted: Tue Aug 04, 2009 3:41 am     Reply with quote

well ad7705 which is operating with pic in SPI mode sends that data and it is 16 bit long so PIC reads that twice from the adc register and store that in a stack [2] each 8 bits long.
so i wanted to converted that data in a decimal form. it is possible?
as i hv to send this to a bluetooth transmitter in UART mode.
mkuang



Joined: 14 Dec 2007
Posts: 257

View user's profile Send private message Send e-mail

PostPosted: Tue Aug 04, 2009 8:21 am     Reply with quote

myumair wrote:
well ad7705 which is operating with pic in SPI mode sends that data and it is 16 bit long so PIC reads that twice from the adc register and store that in a stack [2] each 8 bits long.
so i wanted to converted that data in a decimal form. it is possible?
as i hv to send this to a bluetooth transmitter in UART mode.


Let's call your high byte High_Byte, your low byte Low_Byte, and the assembled value Final_Value for example. You can try something like:



Code:

long Final_Value;
char High_Byte = stack[0];
char Low_Byte = stack[1];

Final_Value = 256*High_Byte + Low_Byte;

printf("%lu", Final_value);
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