STM32 MDK工程中使用printf


首先,要包含頭文件"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;
}

Technorati 標記: MDK, STM32, printf


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM