stc12c5a60s2串口2发送不出数据
void SendData(unsigned char dat)
{
S2BUF = dat;
while(!(S2CON&S2TI)); //?S2TI=0,????
S2CON&=~S2TI; //S2TI=0
}
main:
PCON &= 0x7F; //波特率不倍速
SCON = 0x50; //8位数据,可变波特率
S2CON = 0x50; //??2?????1 10????? S2REN=1????
AUXR |= 0x04; //独立波特率发生器时钟为Fosc,即1T
BRT = 0xD9; //设定独立波特率发生器重装值
AUXR |= 0x01; //串口1选择独立波特率发生器为波特率发生器
AUXR |= 0x08;
AUXR |= 0x10; //启动独立波特率发生器
IE2 =0x01; //???2?? ES2=1
while(1)
{
SendData("l");
}
|