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 CCS Technical Support

Print Hex format issue

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



Joined: 01 Jan 2022
Posts: 13

View user's profile Send private message

Print Hex format issue
PostPosted: Sat Jan 01, 2022 4:47 am     Reply with quote

Hi All
I have a basic question.
I am using PIC16f877A along with CCS compiler.
I am stuck in a little thing.
I am serially out the following code
Code:

unsigned char command_send[] = "^P005ID";
unsigned int crc_low = 25;    // Hex is 19
unsigned int crc_high = 205;  // Hex is CD


Code:

printf("%S",command_send);
   printf("%X",crc_low);
   printf("%X",crc_high);
   printf("\r");


instead of getting (actual result) --> ^ P 0 0 5 I D 19 CD 0D

I am getting this --> ^ P 0 0 5 I D 31 39 43 44 0D

means 19 is break into 1 and 9, also same for CD.
How to tackle this?

Thanks
Ttelmah



Joined: 11 Mar 2010
Posts: 19496

View user's profile Send private message

PostPosted: Sat Jan 01, 2022 5:58 am     Reply with quote

That is what would be expected. %x prints the characters in _ASCII_ hex.
If you just want the character 19, then use %c.
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