PRINTING FLOAT

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

PRINTING FLOAT

1,608 次查看
kooroshhajiani
Contributor III

Hi,

My target is TWR-K54F10M and I'm using KSDK1.2 and KSDK1.3 and DSK3.0.

I'm not able to print float values using PRINTF macro(debug_printf).

I have turned on the switch -u  _printf_float  and it shows up in the linking phase of the build.

However It does not work.144154_144154.PNGprppert_capture.PNG

 

I would appreciate your help.

 

Regards,

Koorosh Hajiani

标签 (1)
标记 (1)
6 回复数

1,049 次查看
DavidS
NXP Employee
NXP Employee

Hi Koorosh,

You do want the -u _printf_float and -u _scanf_float checked.

Try increasing your task stack size.

If still having issue please post your project.

Regards,

David

1,049 次查看
kooroshhajiani
Contributor III

I found out you need to define  a macro in Build setting:

property_Capture.PNG

Now however I'm having issues with using sprintf  with floats.

Any Ideas,

Regards,

Koorosh Hajiani

0 项奖励

1,049 次查看
DavidS
NXP Employee
NXP Employee

Please also add the "SCANF_FLOAT_ENABLE" as you did with the "PRINTF_FLOAT_ENABLE".

Regards,

David

0 项奖励

1,049 次查看
kooroshhajiani
Contributor III

Hi David,

Regarding the sprintf not working with float, I noticed that in one of your posts regarding this issue that  -u _printf_float switch under the Linker Miscellaneous option , needs to be checked.

When I do this my code hits a trap when it tries to execute sprintf.

So without that option I get all zeros and with those option turned on ,I hit a trap.

Regards,

Koorosh Hajiani

1,049 次查看
DavidS
NXP Employee
NXP Employee

Hi Koorosh,

Please review these posts:

printf() with float values

float printing error in PE

Floating Point on KDS

Regards,

David

0 项奖励

1,049 次查看
kooroshhajiani
Contributor III

Thanks much. Printf issue is resolved by the solution proposed by Jennie Zhang in the post you provided.

However now I'm having issue with sprintf :

sprintf(out_buff,"%f", flt_val); with the following:

char out_buff[50];

float flt_val;

when I look at out_buff using debugger it is all zeros with flt_val displaying a float as I expect it to.

Can't figure this one out. Is this the GCC arm or KDS.I've used GCC ARM before and never had any issues.

I need to covert a float number to string and I always used sprintf for this purpose successfully until now.

Any ideas?

Thanks,

Koorosh Hajiani

0 项奖励