Float value printing issue in PE

cancel
Showing results for 
Search instead for 
Did you mean: 

Float value printing issue in PE

Jump to solution
323 Views
syed_idris
Contributor III

Hi,
I know this issue is already discussed in another questions, but when I follow the steps to get float value I am unable to get that.
using KDS3.1.0 + PE

chip: KL03

 

there is nothing special in my code I am just writing

 

while(1)
{
PRINTF("\r\n %f",1.234);
OSA_TimeDelay(1000);
}

 

and it is giving me output as: f

 

I got two solutions after reading previous questions.

  • SOLUTION-1: Adding symbol for float in Cross ARM C Compiler>>Preprocessor

160322_160322.PNGflaot.PNG

After adding this "PRINTF_FLOAT_ENABLE" symbol when I build my code, it is showing error as follows

160323_160323.PNGfloat2.PNG

 

  • SOLUTION-2: checking for "-u_printf_float" in Cross ARM C++ Linker>>Miscellaneous

160324_160324.PNG3.PNG

It is printing the output as 'f' only.

 

I am also attaching here my project file, 

why the float value is not getting printed?

Original Attachment has been moved to: float_30082016.zip

Labels (1)
Tags (2)
0 Kudos
1 Solution
104 Views
DavidS
NXP Employee
NXP Employee

Hi Syed,

Attached is updated project that I got to work on my FRDM-KL03Z4 Freedom board to output floating point using printf as in your case #1 above.

I did have to change UART pinout to switch the RX/TX to make it work but I did not have the errors you indicate when I added the "PRINTF_FLOAT_ENABLE" to the Preprocessor Defined symbols.  Note I used "" around the define.  Your picture does not.  My would compile fine without it but maybe it makes a difference on your system...

I did alter your code to have OS_Task Component so that more tasks could be added to the PE project.  Just look for "//DES" to see where I made code changes.

My Terminal Output:

1.234000
1.234000
1.234000
1.234000
1.234000
1.234000

Regards,

David 

PS

Please make sure your KDS has had updates applied.

View solution in original post

0 Kudos
2 Replies
105 Views
DavidS
NXP Employee
NXP Employee

Hi Syed,

Attached is updated project that I got to work on my FRDM-KL03Z4 Freedom board to output floating point using printf as in your case #1 above.

I did have to change UART pinout to switch the RX/TX to make it work but I did not have the errors you indicate when I added the "PRINTF_FLOAT_ENABLE" to the Preprocessor Defined symbols.  Note I used "" around the define.  Your picture does not.  My would compile fine without it but maybe it makes a difference on your system...

I did alter your code to have OS_Task Component so that more tasks could be added to the PE project.  Just look for "//DES" to see where I made code changes.

My Terminal Output:

1.234000
1.234000
1.234000
1.234000
1.234000
1.234000

Regards,

David 

PS

Please make sure your KDS has had updates applied.

View solution in original post

0 Kudos
104 Views
syed_idris
Contributor III

Thanks David,
you are correct I forgot to use Quotation marks " " while adding "PRINTF_FLOAT_ENABLE" to the Preprocessor Defined symbols.

Idris

0 Kudos