如何在PSoc 4.2中使用printf
打算在CYPD3196上把printf重定向到SW_TX_UART进行调试。#include<stdio.h>以后调用printf()会出现以下错误:
d:/program files (x86)/cypress/psoc creator/4.2/psoc creator/import/gnu/arm/5.4.1/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/lib/armv6-m\libg_nano.a(lib_a-sbrkr.o): In function `_sbrk_r':
sbrkr.c:(.text._sbrk_r+0xc): undefined reference to `_sbrk'
collect2.exe: error: ld returned 1 exit status
The command 'arm-none-eabi-gcc.exe' failed with exit code '1'.
网上有说是底层库某些库函数没有实现导致,网上也看到有人可以正常使用printf():
这位仁兄设置可以用printf
此问题该如何解决?
最常用的方式是通过 C 语言标准库中的 stdio.h 头文件。 要在 PSoC 4.2 上使用 printf,您需要正确配置 UART,并在代码中包含必要的头文件。 你也可以在https://community.infineon.com搜索一下 printf 关键词, 我试了一下
我看到如下帖子可能有帮助 -
https://community.infineon.com/t5/Blogs/Using-the-retarget-io-library-to-enable-printf/ba-p/247044
https://community.infineon.com/t5/Blogs/Using-the-retarget-io-library-to-enable-printf/ba-p/247044
页:
[1]