pentral0311的笔记 https://bbs.21ic.com/?591061 [收藏] [复制] [RSS]

日志

关于printf在mcu中使用的问题

已有 7943 次阅读2018-1-17 14:16 |系统分类:单片机

printf在开发中,使用比较常见,但在MCU中,不能直接使用,需要重新注册
如下
/* retarget the C library printf function to the USART */
int fputc(int ch, FILE *f)
{
    usart_data_transmit(EVAL_COM1, (uint8_t) ch);
    while (RESET == usart_flag_get(EVAL_COM1,USART_FLAG_TBE));
    return ch;
}
此部分从GIGD那边复制,给个参考。
前提是串口初始化要弄好,根据选型的单片机。

路过

鸡蛋

鲜花

握手

雷人

评论 (0 个评论)