Float value printing issue in PE

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Float value printing issue in PE

ソリューションへジャンプ
1,542件の閲覧回数
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

ラベル(1)
タグ(2)
0 件の賞賛
返信
1 解決策
1,323件の閲覧回数
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.

元の投稿で解決策を見る

0 件の賞賛
返信
2 返答(返信)
1,324件の閲覧回数
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.

0 件の賞賛
返信
1,323件の閲覧回数
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 件の賞賛
返信