Unable to print double or float values in MCUXpresso IDE

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

Unable to print double or float values in MCUXpresso IDE

跳至解决方案
1,099 次查看
sushmasan
Contributor II

Hello Team,

I am seeing an issue while printing double or float values.

I am using LPC55S69 custom board.

This is the IDE version used => MCUXpresso IDE v24.12

The library used => NewlibNano (no host)

I am able to print the debug messages using "PRINTF".

I tried to print value of double or float I am just seeing blank message on the console.

Later I just realized that, PRINTF_FLOAT_ENABLE needs to be set to 1, in order to print values of double or float. I set "PRINTF_FLOAT_ENABLE" to 1 in the LPC core.

But as soon I enabled the macro, none of the debug messages are displayed on the console.

I even tried enabling "Enable printf float" option, that also didn't help.

Just FYI, I have used these format specifiers -> %f, %lf, %.4Lf, %.4f

Also FYI, In the debug mode, I can able to see the values in that particular double variable, only issue is with printing.

Can someone please let me know, what is missing?

Regards,
San

0 项奖励
回复
1 解答
651 次查看
Habib_MS
NXP Employee
NXP Employee

Hello @sushmasan,
I have successfully enabled float printing in your project. To achieve this, I made several configuration changes. Please review the following settings and apply them if needed:
In the LMC_target project:
Enable these options:

Habib_MS_0-1749596149866.png

MCU C++ Compiler -> Preprocessor: Add the macro: __USE_CMSIS

Habib_MS_6-1749596653508.png

MCU C Compiler -> Preprocessor: Add the macro: __USE_CMSIS

Habib_MS_5-1749596618540.png
In the FreeRTOS_lib project:

Architecture & Headers: Set the option to: NewlibNano (auto)

Habib_MS_2-1749596264679.png
Preprocessor: Remove the macro: PRINTF_FLOAT_ENABLE=0

Habib_MS_3-1749596459320.png

In the FreeRTOS_lib project:

Architecture & Headers: Set the option to: NewlibNano (auto)

Habib_MS_7-1749596692613.png

 

BR
Habib

 

在原帖中查看解决方案

0 项奖励
回复
10 回复数
1,026 次查看
Habib_MS
NXP Employee
NXP Employee

Hello @sushmasan,
Please check if your project has the next configurations:
1. The macro called "SDK_DEBUGCONSOLE" enabled:

Habib_MS_0-1748464468345.png

 

2. These options enabled:

Habib_MS_1-1748464480027.png

 

3. The macro called "PRINTF_FLOAT_ENABLE" set to 1:

Habib_MS_2-1748464486239.png

 



BR
Habib

0 项奖励
回复
1,009 次查看
sushmasan
Contributor II

Hi @Habib_MS ,

SDK_DEBUGCONSOLE was already enabled, and "Enable Printf Float" also.

Where as "PRINTF_FLOAT_ENABLE" I just enabled in fsl_str.h, but there is no impact with this.

With all above 3 changes, there is no change in the behavior, which means I am not able to print double value.

But there is one compiler option under settings, when this is set to 1, the code under this flag is getting enabled (Inside this function -> int StrFormatPrintf(const char *fmt, va_list ap, char *buf, printfCb cb))

sushmasan_0-1748529046438.png

As I already mentioned in my initial message, when I set "PRINTF_FLOAT_ENABLE" to 1 under settings, none of the PRINTF messages are displayed.

Regards,
San

 

0 项奖励
回复
911 次查看
Habib_MS
NXP Employee
NXP Employee

Hello @sushmasan,
To better support you, could you please share your project? That way, I can take a closer look and better understand the issue you are encountering.
BR
Habib

0 项奖励
回复
890 次查看
sushmasan
Contributor II

Hello @Habib_MS ,

Please find my complete work space for your reference.

Regards,
San

0 项奖励
回复
786 次查看
sushmasan
Contributor II

Hello @Habib_MS ,

Did you get a chance to look into this?

Regards,

San

0 项奖励
回复
765 次查看
Habib_MS
NXP Employee
NXP Employee

Hello @sushmasan 
I found that it is encountering a hardfault at the ASM instruction vldr d0, [r7, #48], as shown in the image below:

Habib_MS_0-1749248460592.png


This instruction uses the FPU (Floating Point Unit) built into the core, which appears to be disabled. Please make sure that the FPU is correctly configured in your project, the function called "system_init" of CMSIS could be helpful with this issue. Please make sure that you declared the macro called __USE_CMSIS.

BR
Habib

0 项奖励
回复
760 次查看
sushmasan
Contributor II

Hello @Habib_MS ,

This "__USE_CMSIS " macro was already enabled. If you see the settings I have shared in my previous message you can see that macro.

When you say this "Please make sure that the FPU is correctly configured in your project, the function called "system_init" of CMSIS could be helpful with this issue. " what do you think might be missing?

Regards,
San

0 项奖励
回复
652 次查看
Habib_MS
NXP Employee
NXP Employee

Hello @sushmasan,
I have successfully enabled float printing in your project. To achieve this, I made several configuration changes. Please review the following settings and apply them if needed:
In the LMC_target project:
Enable these options:

Habib_MS_0-1749596149866.png

MCU C++ Compiler -> Preprocessor: Add the macro: __USE_CMSIS

Habib_MS_6-1749596653508.png

MCU C Compiler -> Preprocessor: Add the macro: __USE_CMSIS

Habib_MS_5-1749596618540.png
In the FreeRTOS_lib project:

Architecture & Headers: Set the option to: NewlibNano (auto)

Habib_MS_2-1749596264679.png
Preprocessor: Remove the macro: PRINTF_FLOAT_ENABLE=0

Habib_MS_3-1749596459320.png

In the FreeRTOS_lib project:

Architecture & Headers: Set the option to: NewlibNano (auto)

Habib_MS_7-1749596692613.png

 

BR
Habib

 

0 项奖励
回复
639 次查看
sushmasan
Contributor II

Hello @Habib_MS ,

Thank you so much for your support.

I didn't realize that, the other dependent project pointing to RedLib library and I missed few build configurations too.

With these configuration changes, now I am able to print double value.

Regards,
San

0 项奖励
回复
1,050 次查看
sushmasan
Contributor II

Hello Team,

Can someone please check it and let me know what is missing?

 

Regards,
San

0 项奖励
回复