关于keil下调用sprintf配置

发布时间 2023-10-20 09:52:32作者: 周总在纽约

1.需要在keil的Target1->target下勾选microlib
2.在main函数前面

ifdef GNUC /* GNUC */

define PUTCHAR_PROTOTYPE int __io_putchar(int ch)

else

define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)

endif /* GNUC */

3.在main下面
PUTCHAR_PROTOTYPE
{
/* Place your implementation of fputc here /
/
e.g. write a character to the USART1 and Loop until the end of transmission */
HAL_UART_Transmit(&huart3, (uint8_t *)&ch, 1, 0xFFFF);
return ch;
}