Can anyone please show me a sample C code to convert floating point and integer to BCD/ASCII? I want to display it on alphanumeric LCD.
For ex. I want to display "0.5" etc. on LCD which are in float data types.
if you have sprintf available on you C compiler is good, but make attention of code space required by sprintf function. You can compare with (an example for one digit for integer part and one digit for fraction):
This is more than easy, use the 8051 ANSI C Compiler from www.wickenhaeuser.de They have included drivers for own printf() formaters, with an example how to write an own 'lcd_printf()' Routine, that can even output floating point numbers.
There is a free 8kB code size limited demo... I tried it, nice product. The only problem (for them) is: the code is so dense, you have really to work hard until you get over the 8 kB
Thanks for your suggestions guys. I've tried uC51. It has quite good library functions but it takes no time for the compiler to generate 8kb code for just a few lines of C code
:?: I think if you use the "%f" formater option, the code will get 1-2kB larger, because the full formater libs will be linked.
I am using a LCD on a 89S8252 with only integers "%d", "%u", for a RF-ID system (school project). Works fine and still half of the CPU (exactly 8k) is unused...
Maybe this could help you?: Use Fixedpoint formats:
You can use 'lcdprint("%d.%02u",val/100,(uint)(val%100))' to get a "pseudo" floating point output (with 2 digits).