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

How a can putc ( hexa value ).....

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



Joined: 14 Jun 2010
Posts: 16

View user's profile Send private message

How a can putc ( hexa value ).....
PostPosted: Mon Jun 14, 2010 7:15 am     Reply with quote

Hello, I have a big question.... I need to put on a display a hex value with putc/puts and not printf. But i don't know how to. Can you explain me the solution.Thanks before.



int8 temp;
temp=0xA8;

fct_XXXXXXX(temp); // With utilisation 'putc' or 'puts'

------------------------------------------
result on display : 'A8'
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Mon Jun 14, 2010 8:03 am     Reply with quote

A typical school assignment.
Students understanding the matter will write the function in two minutes. The other students are found on this forum...
joseph



Joined: 14 Jun 2010
Posts: 16

View user's profile Send private message

PostPosted: Mon Jun 14, 2010 8:16 am     Reply with quote

Thank for you aid...... If i have wrote this message, it's because i haven't find the answer on forum. so if you have a link or a precision, don't keep the information !

thanks
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Mon Jun 14, 2010 8:37 am     Reply with quote

Come on, be creative!
There are at least four possible solutions that I can think of, one of these is short and very fast but the others do the job too.

How would you handle this question if you had to print the decimal value 23?

You would:
1) print 2
2) print 3

Now, in step 1, how do you get the 2 from the 23 value?
And then the 3?
joseph



Joined: 14 Jun 2010
Posts: 16

View user's profile Send private message

PostPosted: Mon Jun 14, 2010 8:59 am     Reply with quote

i think you have not correctly understand my question, so i try to explain better.

1.My pic read position (hexa value) in a motor stepper controller.
2.I will send this value on RS232 with a protocol.

> The protocol specifie to "print" the value like a ASCII caracter.
If the position is 0xA8; i would send A8 in ASCII whithout printf funtion but put or puts.
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Mon Jun 14, 2010 9:15 am     Reply with quote

The explanation does not really help, but if I understand correctly you can not use printf("%x). Right?
You mean you have to write your own implementation of the %x conversion?
If yes, then you are back at my simple '23' printing question.
joseph



Joined: 14 Jun 2010
Posts: 16

View user's profile Send private message

PostPosted: Mon Jun 14, 2010 9:25 am     Reply with quote

Exactly, i don't want use printf (it's embeded software), and i try to write my own function !

For the question of decimal value, the protocol say not decimal... only in hex
-> the value is 0xA8, the value must be send like :

putc('A');
putc('8');
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Mon Jun 14, 2010 9:32 am     Reply with quote

joseph wrote:
Exactly, i don't want use printf (it's embeded software), and i try to write my own function !
The CCS compiler is optimized for embedded software and very efficient. Only try to do optimization when your project has problems with memory usage or speed.

I know you need an answer for hexadecimal, but decimal is easier to understand. The step from decimal to hex is small.
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