Bhavana Yarlagadda

sprintf

Discussion created by Bhavana Yarlagadda on Dec 14, 2006
Latest reply on Dec 18, 2006 by Bhavana Yarlagadda
Hi Everybody..
 
I am new to this forum...
But i found it very useful as many people are helping each others....
 
I am working on MC9s12dt128 freescale 16 bit controller.
The problem is i am using sprintf function with floating point values.I am not getting output correctly.
I included both lib files(libi,libf.h12)
 
And my linker file is this..
where uyou can check my stack value also...

+seg .eeprom -b0x800 -nEEPROM -m0x7FF -sEEPROM # 2k EEPROM remapped from 0x0 in CRTSI.S
+seg .data -b 0x2000 -m 0x1FFF -n IRAM -s RAM   # 8K RAM for Variable storage
+seg .bss  -aIRAM  -sRAM
+def __sbss=@.bss
+def _INITEE=0x12
+def _ESTAT=0x115
+def _ECMD=0x116
+seg .text -b0xF8000 -o 0x4000 -m 0x4000  -nFIXED1  -sCODE 
+seg .const -aFIXED1           # Same as PPAGE = 0x3E offset 0x8000

+seg .text -b0xFC000 -o 0xC000 -m 0x3F80  -nFIXED2  -sCODE -ck  
+seg .const -aFIXED2  -nCFIXED2  -it                     

+seg .const -b 0xFFF80 -o 0xFF80
#+def __stack=0x2FFE  
+def __stack=0x3FFF   
 
I read many of our forums where people mentioned same kind of problem.
What ever the sugesstions u mentioned i tried but still not working....
and this is my code
u32floatval = 4.323;
 memset(u8Buf,'\0',sizeof(u8Buf));
 sprintf(u8Buf,"%0.3f",u32floatval);
 
in the u8Buf i am getting 2.270 instead of 4.323
 
Any one please guide me

Outcomes