最近用STC12C5A60S2用到第二串口,接收數(shù)據(jù)好好地,但是發(fā)送數(shù)據(jù),串口助手接收不到。搞了很久也沒弄明白!求高手指點
#include<stc12c5as2.h>
unsigned char list[ ]={0x09, 0x80, 0x07, 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00};
void UartInit() //9600bps@11.0592MHz
{
AUXR &= 0xf7; //波特率不倍速
S2CON = 0x50; //8位數(shù)據(jù),可變波特率
BRT = 0xDC; //設(shè)定獨立波特率發(fā)生器重裝值
AUXR |= 0x04; //獨立波特率發(fā)生器時鐘為Fosc,即1T
AUXR |= 0x10; //啟動獨立波特率發(fā)生器
}
void main()
{
unsigned char i;
UartInit();
for(i = 0; i< 10; i++)
{
S2BUF = list;
while(!(S2CON & 0x02)); //發(fā)送數(shù)據(jù)
S2CON &= 0xfd;
}
while(1)
{
}
}
| 歡迎光臨 (http://www.raoushi.com/bbs/) | Powered by Discuz! X3.1 |