本帖最后由 小恩GG 于 2020-5-19 17:42 编辑
如何在MCUXpresso中实现SDK工程打印出浮点数
本文以SDK_2.7.0_EVKB-IMXRT1050中的hello_world工程为例,介绍如何实现工程打印浮点数功能,测试硬件为:MIMXRT1050开发板。
hello_world工程修改后的代码如下,期望能打印出浮点数变量:test_num1与test_num2。
- #include "fsl_device_registers.h"
- #include "fsl_debug_console.h"
- #include "board.h"
- #include "pin_mux.h"
- #include "clock_config.h"
- /*******************************************************************************
- * Definitions
- ******************************************************************************/
- /*******************************************************************************
- * Prototypes
- ******************************************************************************/
- /*******************************************************************************
- * Code
- ******************************************************************************/
- /*!
- * @brief Main function
- */
- int main(void)
- {
- char ch;
- /* Init board hardware. */
- BOARD_ConfigMPU();
- BOARD_InitPins();
- BOARD_InitBootClocks();
- BOARD_InitDebugConsole();
- float test_num1= -3.14;
- float test_num2 = 3.15;
- PRINTF("hello world.\r\n");
- PRINTF("x_value: %f, y_value: %f\n", test_num1, test_num2);
- while (1)
- {
- ch = GETCHAR();
- PUTCHAR(ch);
- }
- }
复制代码 测试①:默认情况(工程设置未做任何修改),结果表明浮点数未被成功打印出来
图 1
测试②:修改工程设置(Project > properties > C/C++ Build > Setiings > Tool Settings > MCU C Compiler > Preprocessor)如下,成功地打印出浮点数。 测试③修改工程设置(Project > properties > C/C++ Build > Setiings > Tool Settings > MCU C Compiler > Managed Linker Script)如下,同样能打印出浮点数。
|