PRINTF floats

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

PRINTF floats

5,812件の閲覧回数
rudycoppens
Contributor III

Hello,

 

I am using the following hard and software:

- NXP MKE14F512

- Segger J-Link Edu

- MCUXpresso  10.1.1_606

- FREERTOS

I readed the following page to do this:

MCUXpresso SDK API Reference Manual: Debug Console 

To init the debug console I use:

BOARD_InitDebugConsole();

From the link above I tried running the following line of code:

PRINTF("Execution timer: %s\n\rTime: %u ticks %2.5f milliseconds\n\rDONE\n\r", "1 day", 86400, 86.4);

 

You would expect to see 85.4 milliseconds in the print console but I only get spaces. 

See attached file. 

タグ(4)
3 返答(返信)

5,204件の閲覧回数
lpcxpresso_supp
NXP Employee
NXP Employee

Just to add to Erich comment, if you are using the (default) Redlib library then integer only printf's are enabled by default - using the symbol CR_INTEGER_PRINTF (in the Preprocessor settings for your project). Remove this to get floating point printf's

For more information see section 15.5, "Use of printf" in the MCUXpresso IDE v10.2 User Guide for more details.

Regards,

MCUXpresso IDE Support

5,204件の閲覧回数
rudycoppens
Contributor III

Thanks! 

I did not change any of these settings, I was using Redlib (semihost-nf). 

It is now working with the solution of Erich Styger. I could not find the folder where the Redlib library is located. 

Regards,

Rudy

0 件の賞賛
返信

5,204件の閲覧回数
BlackNight
NXP Employee
NXP Employee

Depending on your library used, printf() for floating point is not turned on as this usually adds a lot of code overhead.

I assume you are using newlib-nano?

So you have to turn this on in the linker settings:

pastedImage_1.png

With this I get:

Time: 86400 ticks 86.40000 milliseconds

I hope this helps,

Erich

PS: there is a background article (with more points about using the GNU libraries) available here: printf() and scanf() with GNU ARM Libraries | MCU on Eclipse