SCON = 0x40; //uart work on 8bit async mode
SM2 = 0; //disable address discern(mode 2,3)
REN = 1; //enable receive
PCON &= ~0x40; //SM0 enable,FE disable(SCON register)
ES = 1; //open UART interrupt
EA = 1; //open globle interrupt
AUXR |= 0x40; // X12 mode
TH1 = 0x7E;
TL1 = 0x7E; //set Baud rate
TMOD = 0x20; //TM1 work on 8bit auto reload mode
TR1 = 1; //open timer1;
SBUF = 0x55;
while(1);
上面的是 2400 bps 的例子,10M的晶振,参考参考 |