Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

display float on 16x2 LCD in PIC 16F877 using Hi-tech C compiler

Status
Not open for further replies.

ecaits

Member level 4
Member level 4
Joined
Jan 16, 2014
Messages
76
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Visit site
Activity points
579
Hi friends,

I want to display float value on LCD display in PIC16F877 using Hi-tech C compiler.

Can anybody help me???
 


Hi ecaits,
sprintf() can eat up more memory on PIC16F877. Fixed point arithmetic is good. But if you still want to use float, use the follwoing code to display on LCD.
Code:
#define DECIMAL_PLACES    (100)    // 2 digits after decimal

void displayFloat(float value)              // Assume value = 123.456
{
      unsigned long a = value;              // a = 123
      value = (value - (float)a) * (DECIMAL_PLACES);       // value = 45.6
      unsigned long b = value;              // b = 45

      display(a);
      display('.');
      display(b);
}


Raj Gunaseelan
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top