IAR for STM8 printf重定向到串口

文章目錄


在main.c中添加下面的代碼

#include <stdio.h>			// 包含頭文件

int fputc(int ch, FILE *f)	//STM8 printf函數重定向 
{ 
	while ( (USART2->SR&0x80) == 0 );
	
	USART2->DR = (uint8_t)ch;
	
	return ch; 
} 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章