关于USART串口与PC进行数据传输

发送open 可以回welcome
          发送close 可以回goodbye
        但是发送了close后回了goodbye之后我再发送open就没有反应了
#include "stm32f4xx.h"
#include "usart.h"
#include "delay.h"
#include "string.h"


int main(void)
{

    u16 time=0;
    NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
    usart_init(9600);
    delay_init(168);
    
    while(1)
    {
        if(USART_RX_STA&0x8000)
        {
            if(strcmp((char*)USART_RX_BUF,"open")==0)
            {
                printf("\r\nwelcome\r\n");
                USART_RX_STA=0;
            }
            else if(strcmp((char*)USART_RX_BUF,"close")==0)
            {
                printf("\r\ngoodbye\r\n");
                USART_RX_STA=0;
            }
            else USART_RX_STA=0;
        }
        else
        {
            time++;
            if(time%200==0)
            {
                printf("\r\n请输入数据\r\n");
            }
            delay_ms(10); 
        }
    }
}



接收中断的接收个数是不是没有清零呀

判断成功之后,应该要清空接收缓冲区吧,否则一直堆下去没法判断了。
如果发现接收出错也应该清零,否则再收到正确的也没法判断。

这是轮询扫描,建议使用接收中断呀...