方案二 使用默认C库:
这种方案要注意一点,程序不能使用半主机模式,据说半主机模式是STM32的默认模式,用调试器时会用到,所以在程序中要明确加上以下语句
- #pragma import(__use_no_semihosting)
- _sys_exit(int x)
- {
- x = x;
- }
- struct __FILE
- {
- int handle;
- /* Whatever you require here. If the only file you are using is */
- /* standard output using printf() for debugging, no file handling */
- /* is required. */
- };
- /* FILE is typedef’ d in stdio.h. */
- FILE __stdout;
然后再重写putchar函数,可参考上面的。
|