查看: 5129|回复: 0

[原创] 如何在MCUXpresso中实现SDK工程打印出浮点数

[复制链接]

该用户从未签到

715

主题

6374

帖子

0

超级版主

Rank: 8Rank: 8

积分
25213
最后登录
2025-8-18
发表于 2020-5-19 17:38:36 | 显示全部楼层 |阅读模式
本帖最后由 小恩GG 于 2020-5-19 17:42 编辑

如何在MCUXpresso中实现SDK工程打印出浮点数       

本文以SDK_2.7.0_EVKB-IMXRT1050中的hello_world工程为例,介绍如何实现工程打印浮点数功能,测试硬件为:MIMXRT1050开发板。
  hello_world工程修改后的代码如下,期望能打印出浮点数变量:test_num1与test_num2。
  1. #include "fsl_device_registers.h"
  2. #include "fsl_debug_console.h"
  3. #include "board.h"

  4. #include "pin_mux.h"
  5. #include "clock_config.h"
  6. /*******************************************************************************
  7. * Definitions
  8. ******************************************************************************/


  9. /*******************************************************************************
  10. * Prototypes
  11. ******************************************************************************/

  12. /*******************************************************************************
  13. * Code
  14. ******************************************************************************/
  15. /*!
  16. * @brief Main function
  17. */
  18. int main(void)
  19. {
  20.     char ch;

  21.     /* Init board hardware. */
  22.     BOARD_ConfigMPU();
  23.     BOARD_InitPins();
  24.     BOARD_InitBootClocks();
  25.     BOARD_InitDebugConsole();

  26.     float test_num1= -3.14;
  27.     float test_num2 = 3.15;
  28.     PRINTF("hello world.\r\n");
  29.     PRINTF("x_value: %f, y_value: %f\n", test_num1, test_num2);

  30.     while (1)
  31.     {
  32.         ch = GETCHAR();
  33.         PUTCHAR(ch);
  34.     }
  35. }
复制代码
测试①:默认情况(工程设置未做任何修改),结果表明浮点数未被成功打印出来
S1.png

图 1

测试②:修改工程设置(Project > properties > C/C++ Build > Setiings > Tool Settings > MCU C Compiler > Preprocessor)如下,成功地打印出浮点数。
S2.png
图 2
S3.png
图 3
测试③修改工程设置(Project > properties > C/C++ Build > Setiings > Tool Settings > MCU C Compiler > Managed Linker Script)如下,同样能打印出浮点数。
S4.png
图 4
S5.png
图 5





回复

使用道具 举报

您需要登录后才可以回帖 注册/登录

本版积分规则

关闭

站长推荐上一条 /3 下一条

Archiver|手机版|小黑屋|恩智浦技术社区

GMT+8, 2025-8-20 03:44 , Processed in 0.081157 second(s), 20 queries , MemCache On.

Powered by Discuz! X3.4

Copyright © 2001-2024, Tencent Cloud.

快速回复 返回顶部 返回列表