MDK中使用printf 直接发送汉字的方法。

来源:互联网 发布:淘宝新店盗图违规扣分 编辑:程序博客网 时间:2024/06/05 16:58

 网上有好多方法,都差不多现在记录一下。

1.只需要把下面的代码复制到程序中。

#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 USART */
USART_SendData(USART1, (uint8_t) ch);
/* Loop until the end of transmission */
while (USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET);
return ch;
}


然后在target设置中使用微库,就ok啦

0 0
原创粉丝点击