用 STM32CubeIDE,将 printf 重新定位到 STM32F407 的 USART6。 MCU 的 USART6 链接到PC的虚拟com。已经使用函数“HAL_UART_Transmit(&huart6, ”A“, 1, 0xFFFF)”测试了 USART6 的连接正常,PC能够接受数据。已经在 main.cpp 中实现了 __io_putchar() 函数,如下所示: int __io_putchar(int ch) { /* Place your implementation of fputc here */ /* e.g. write a character to the EVAL_COM1 and Loop until the end of transmission */ HAL_UART_Transmit(&huart6, (uint8_t *)&ch, 1, 0xFFFF); return ch; } 然后用printf打印字符串到pc,一直不成功。
|