正点原子stm32--串口通信实验讲解里关于USART_RX_STA的问题与思考https://blog.csdn.net/milu_yu/article/details/108523888
SET,是标志位满足的情况。
RESET,是标志位未满足的情况。
为什么printf能通过串口1发送到电脑。
只要修改 fputc里的USART1中的1即可更改接收的串口。
#if 1
#pragma import(__use_no_semihosting)
//标准库需要的支持函数
struct __FILE
{
int handle;
};
FILE __stdout;
//定义_sys_exit()以避免使用半主机模式
void _sys_exit(int x)
{
x = x;
}
//重定义fputc函数
int fputc(int ch, FILE *f)
{
while((USART1->SR&0X40)==0);//循环发送,直到发送完毕
USART1->DR = (u8) ch;
return ch;
}
#endif