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 convert a binary #

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



Joined: 14 Jan 2008
Posts: 5

View user's profile Send private message

How to convert a binary #
PostPosted: Mon Jan 21, 2008 10:14 pm     Reply with quote

I'm new to C programing.

I was wondering if someone could give me a little direction on how to convert a 16 bit binary # into a form I can output to the lcd_putc() function which is in the lcd.c include file? Or maybe which function should I use to do this conversion ?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jan 21, 2008 10:48 pm     Reply with quote

Do it with printf. In CCS, printf has a special feature where its output
can be re-directed to another function. You can re-direct it to the
lcd_putc() function and it will be displayed on the LCD. Printf will do
the conversion from an integer to ASCII for you.

See this example program:
http://www.ccsinfo.com/forum/viewtopic.php?t=32168&start=1
This program displays a floating point number on the LCD.

If you want to display an 'int16' variable on the LCD, then use "%lu"
instead of "%f" in the printf statement.
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