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

Problem with lcd representation of float (printf)

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



Joined: 09 Dec 2003
Posts: 13

View user's profile Send private message

Problem with lcd representation of float (printf)
PostPosted: Sun Dec 12, 2004 7:15 pm     Reply with quote

I initialize the LCD
//Initiate LCD
lcd_init();
delay_ms(6);
Later write the paratext
printf(lcd_putc,"\f 33\xDFC Control\nTemp.= 00.00\xDFC");
Then after that whe I read the temp value I refresh only the number
A_Temp=Acumu;
A_Temp*=50;
A_Temp/=1023;
lcd_gotoxy( 8, 2);
printf(lcd_putc,"%2.2f",A_Temp);

But why same time write a number with three character after point instead of two, only sometimes but is very frequent.

Thanks in advance

CCS v 3.212
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Dec 14, 2004 3:40 pm     Reply with quote

I have not tested your code on my demo board.
But here is a possible reason for your problem:

If your code sometimes writes

12.34

and then it writes

5.67

the last digit of the previous value could still be present.
So you would see:

5.674

Is this what you are seeing ? Is that your problem ?

If so, one easy solution is to clear all 5 character positions
before you write a new value. You could do this by setting
the X,Y position to the start of the field, and then send 5 space
characters.
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