Unable to print double or float values in MCUXpresso IDE

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Unable to print double or float values in MCUXpresso IDE

Jump to solution
1,215 Views
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 Kudos
Reply
1 Solution
767 Views
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

 

View solution in original post

0 Kudos
Reply
10 Replies
1,142 Views
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 Kudos
Reply
1,125 Views
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 Kudos
Reply
1,027 Views
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 Kudos
Reply
1,006 Views
sushmasan
Contributor II

Hello @Habib_MS ,

Please find my complete work space for your reference.

Regards,
San

0 Kudos
Reply
902 Views
sushmasan
Contributor II

Hello @Habib_MS ,

Did you get a chance to look into this?

Regards,

San

0 Kudos
Reply
881 Views
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 Kudos
Reply
876 Views
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 Kudos
Reply
768 Views
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 Kudos
Reply
755 Views
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 Kudos
Reply
1,166 Views
sushmasan
Contributor II

Hello Team,

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

 

Regards,
San

0 Kudos
Reply