《IAP15W413AS串口通信程序.docx》由会员分享,可在线阅读,更多相关《IAP15W413AS串口通信程序.docx(4页珍藏版)》请在三一办公上搜索。
IAP15W413AS串口通信程序#includereg51.h#includeintrins.htypedef unsigned char BYTE;#define FOSC 11059200L#define BAUD 9600sfr AUXR =0x8e;sfr T2H =0xd6;sfr T2L =0xd7;sfr P2M1=0x95;sfr P2M0=0x96;char buffer;int flag=0;bit busy;sbit LED=P25;void send(BYTE dat)while(busy);busy=1;SBUF=dat;void mainP2M0=0xff;P2M1=0x00;SCON=0x50;T2L=(65536-(FOSC/4/BAUD);T2H=(65536-(FOSC/4/BAUD)>>8;AUXR=0x14;AUXR|=0x01;ES=1;EA=1;send(q);LED=0;while(1)/LED=1;if(flag=1)/LED=0;flag=0;send(buffer); void Uart interrupt 4 using 1if(RI)RI=0;buffer=SBUF;flag=1;LED=LED;if(TI)TI=0;busy=0;