AVR串口通信问题,用STC的下载软件带的串口助接收数据总是出错。不知道为什么,希望大侠们帮帮忙
void star_com()//初始化串口
{
// UBRRH=(F_CPU/BAUD/16-1)/256;
// UBRRL=(F_CPU/BAUD/16-1)%256;
UBRR=207;
UCSRB|=BIT(3);//
UCSRB|=BIT(4);
}
void send_onedata(unsigned char a)
{
while(!(UCSRA&BIT(5)))
{;}
UDR=a;
}
void main()
{
star_com();
while(1)
{
send_onedata(0X00);
delay(2000);
send_onedata(0X02);
delay(2000);
send_onedata(0X03);
delay(2000);
send_onedata(0X11);
delay(2000);
send_onedata(0X22);
delay(2000);
send_onedata(0X33);
delay(2000);
send_onedata(0X44);
delay(2000);
send_onedata(0X55);
delay(2000);
send_onedata(0X66);
delay(2000);
send_onedata(0X77);
delay(2000);
send_onedata(0X88);
delay(2000);
send_onedata(0X99);
delay(2000);
send_onedata(0Xaa);
delay(2000);
}
}
|