串口通讯,首先设置波特率,再设置串口模式,之后就可以收发数据了。比如:
init(){TMOD=0x20;TH1=0xfd;TL1=0xfd;TR1=1;SCON=0x50;}send(unsigned char dat){SBUF=dat;while(TI==0);TI==0;}unsigned char recive(){unsigned char dd;if(RI) { dd=SBUF; RI=0; } return(dd);}