新聞中心

EEPW首頁 > 嵌入式系統(tǒng) > 設計應用 > STM32中用printf代替uart打印數據的方法

STM32中用printf代替uart打印數據的方法

作者: 時間:2016-11-11 來源:網絡 收藏
.在程序中添加:(頭文件需要添加#include)

#ifdef__GNUC__
#definePUTCHAR_PROTOTYPEint__io_putchar(intch)
#else
#definePUTCHAR_PROTOTYPEintfputc(intch,FILE*f)
#endif
PUTCHAR_PROTOTYPE
{

本文引用地址:http://2s4d.com/article/201611/316696.htm

USART_SendData(USART1,(u8)ch);
while(USART_GetFlagStatus(USART1,USART_FLAG_TC)==RESET);

returnch;
}

IAR:出現(xiàn)identifier "FILE" is undefined,工程option中,如下選折:

需要在的Options -> General Options ->Library Configuration里設置一下函數庫,不然printf函數不對,將Library Configuration 中的Library 設置由"Normal"改為"Full"就可以了。


KEIL:在工程屬性的 “Target" -> "Code Generation" 選項中勾選 "Use MicroLIB"”


評論


技術專區(qū)

關閉