关于STM32串口printf输出调试信息问题
By Sky.J 2018.06.01
1,遇到的问题(使用HAL库)
在STM32使用过程中,我们程序调试时一般都会用到printf重定向串口输出调试信息来进行程序开发调试,从网上我们找到了重定向的代码部分加入到串口代码文件中,如下:
UART_HandleTypeDef husart_printf;
#ifdef __GNUC__
/* With GCC/RAISONANCE, small printf (option LD Linker->Libraries->Small printf
set to 'Yes') calls __io_putchar() */
#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
#else
#define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
#endif /* __GNUC__ */
PUTCHAR_PROTOTYPE
{
/* Place your implementation of fputc here */
/* e.g. write a character to the USART2 and Loop until the end of transmission */
HAL_UART_Transmit(&husart_printf, (uint8_t *)&ch, 1, 0xFFFF);
return ch;
}
程序编辑好,本以为可以直接打印出消息从串口输出,但是程序下进去并未打印出任何信息到串口,这就奇怪了,难道是上面重定向部分不对吗?
2,找到问题<