View previous topic :: View next topic |
Author |
Message |
Bomba
Joined: 09 Dec 2003 Posts: 13
|
Problem with lcd representation of float (printf) |
Posted: Sun Dec 12, 2004 7:15 pm |
|
|
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
|
|
Posted: Tue Dec 14, 2004 3:40 pm |
|
|
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. |
|
|
|