發表於 2018-12-24 14:25:12
首先,要包含頭文件「stdio.h」
第二:printf()函數使用了int fputc(int ch,FILE *f)完成其功能。
要使用printf,就需要重寫這個函數。
第三,在工程選項的Target裡邊勾選USE MicroLIB項。
fputc示例如下:
int fputc(int ch,FILE *f)
{
/* 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;
}
打開APP閱讀更多精彩內容
聲明:本文內容及配圖由入駐作者撰寫或者入駐合作網站授權轉載。文章觀點僅代表作者本人,不代表電子發燒友網立場。文章及其配圖僅供工程師學習之用,如有內容圖片侵權或者其他問題,請聯繫本站作侵刪。 侵權投訴