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.

[General] Problem Displaying a Signed Value with Decimals in LCD

Status
Not open for further replies.

Jayakumar.azetech

Newbie level 2
Joined
Oct 30, 2013
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
27
Hi,

I am new to the programming, I facing a with a problem to display the signed valued on the LCD, I get the correct output with the GCC simulation, but unfortunately on to the hardware I get some garbage value.

just to display any signed value, like -156 on the 16x2

>>when it tried to display it on the display i get, (+0

any help!!!

- - - Updated - - -

my code,


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
l_Current_Signed_Value = -850; 
  Display_Decimal((float)l_Current_Signed_Value);
--------------------------------------------------------------
 void Display_Decimal(int32 value)
   {
      if((value/100000000)!=0)       Decimal(value,9);
      else if((value/10000000)!=0)       Decimal(value,8);
      else if((value/1000000)!=0)       Decimal(value,7);
      else if((value/100000)!=0)       Decimal(value,6);
      else if((value/10000)!=0)       Decimal(value,5);
      else if((value/1000)!=0)    Decimal(value,4);
      else if((value/100)!=0)    Decimal(value,3);
      else if((value/10)!=0)       Decimal(value,2);
      else if(value!=0)          Decimal(value,1);
      else                   LCD_Data('0');
   }
------------------------------------------------
 
 void Decimal(int32 value,int8 digit)
   {
      switch(digit)
      {
         case 9:    LCD_Data((value/100000000)+0x30);    value%=100000000;
         case 8:    LCD_Data((value/10000000)+0x30);    value%=10000000;
         case 7:    LCD_Data((value/1000000)+0x30);    value%=1000000;
         case 6:    LCD_Data((value/100000)+0x30);    value%=100000;
         case 5:    LCD_Data((value/10000)+0x30);    value%=10000;
         case 4:    LCD_Data((value/1000)+0x30);    value%=1000;
         case 3:    LCD_Data((value/100)+0x30);    value%=100;
         case 2:    LCD_Data((value/10)+0x30);       value%=10;
         case 1:    LCD_Data(value+0x30);
      }
   }


-------------------------------------------------------------
any help would be appreciate!!!!!!!!!!!!!!!!!!!!!!!!!!
 
Last edited by a moderator:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top