PRINTF() and printf() on MIMXRT1170-EVKB?

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

PRINTF() and printf() on MIMXRT1170-EVKB?

195 次查看
VassiliN
Contributor III

I need to output some debug data from the MIMXRT1170-EVKB.

I tried to use PRINTF() and it gives me some troubles with negative values.  

I am using UART as a debug console. 

 

Data type is int16_t, so when I see the negative values in debugger, the data seems to be expanded to unsigned 32 bits before being output to the UART. 

 

VassiliN_0-1727811834259.png

The output code, I tried to apply different formats, %d, %hX, %hd: 

VassiliN_1-1727811931200.png

Output result: 

VassiliN_2-1727811993543.png

 

SDK version 2.15.100 

MCUXpresso IDE v11.9.1 [Build 2170] [2024-04-19]

PuTTY v. 0.74.0.0.

Windows 10 Pro

0 项奖励
回复
4 回复数

120 次查看
VassiliN
Contributor III

I found the solution here: https://community.nxp.com/t5/MCUXpresso-SDK/Printing-negative-floats-with-DbgConsole-Printf-in-mcuxp...

 

1. Use printf()  instead of PRINTF()

2. #include "stdio.h"

3. add SDK_DEBUGCONSOLE_UART=1 to preprocessor

 

191 次查看
VassiliN
Contributor III

So, I looked for the solution here: 

https://community.nxp.com/t5/MCUXpresso-SDK/Simple-printf-formatting-not-working/m-p/1244449#M3098

 

It recommends to use PRINTF_ADVANCED_ENABLE=1 in the project settings. 

VassiliN_3-1727812665817.png

I did that and  the project stopped building with multiple linker errors: 

 

VassiliN_1-1727812503223.png

VassiliN_2-1727812561481.png

 

 

 

 

 

0 项奖励
回复

154 次查看
EdwinHz
NXP TechSupport
NXP TechSupport

Hi @VassiliN,

I was able to reproduce the initial issue where the negative sign was lost, and in my case, I was able to fix it using the PRINTF_ADVANCED_ENABLE=1 macro definition without any linker errors.

Could you try changing the library as to Newlib as recomended on the following community post?: LPC54628 Printf Floating numbers doesnt have minus sign - NXP Community.

BR,
Edwin.

0 项奖励
回复

124 次查看
VassiliN
Contributor III

Edwin, 

 

I was not able to compile my code with newlib, with some other errors from linker. 

 

 

0 项奖励
回复