太平天国中的东西南北王各是谁?( 六 )


求文档: <<单片机与PLC的串行通讯>>过幼南

太平天国中的东西南北王各是谁?

文章插图
【太平天国中的东西南北王各是谁?】#include#defineucharunsigned char#defineuintunsigned int#defineOLEN32// size of serial transmission bufferidataunsigned charoutbuf[OLEN];//storage for transmission bufferunsigned char idata*outlast=outbuf;//最后由中断传输出去的字节位置unsigned char idata*putlast=outbuf;//最后放入发送缓冲区的字节位置#defineILEN12// size of serial receiving bufferidataunsigned charinbuf[ILEN];unsigned char idata *inlast=inbuf;//最后由中断进入接收缓冲区的字节位置unsigned char idata *getlast=inbuf;//最后取走的字节位置bitoutbufsign0;//最后一个数据覵BUF发完标志发完=0bitoutbufsign;//输出缓冲区非空标志有=1bitinbufsign;//接收缓冲区非空标志有=1bitinbufful;//输入缓冲区满标志满=1#define CR putstring("rn")//CR=回车换行//延时n x 100nsvoid delay(unsigned char d)//在源程序开头定义是否用w77e58或22 。1184M晶振{unsigned char j;do{ d--;//110592 & 89c52#ifndef cpuw77e58#ifndef xtal221184j=21;//k=38 cpu80320100us k=21 cpu 8052#elsej=42;#endif#else#ifndef xtal221184j=38;#elsej=76;#endif#endifdo {j--;} while(j!=0);}while(d!=0);}//放入一个字节到发送缓冲区putbyte(char c){uchar i,j;ES=0;//暂停串行中断,以免数据比较时出错?//if (outlast=putlast)while ( (((outlast-putlast)==2) && (outlast > putlast )) || ((outlast < putlast) && (OLEN-(putlast-outlast)==2))){ES=1; c++;c--;ES=0;//i=(0-TH1);do{i--;j=39; do {j--;}while(j!=0); }while(i!=0);//i=39}*putlast=c;//放字节进入缓冲区putlast++;//发送缓冲区指针加一if (putlast==outbuf+OLEN) putlast=outbuf;//指针到了顶部换到底部outbufsign=1;if (!outbufsign0){outbufsign0=1;TI=1;}//缓冲区开始为空置为有,启动发送ES=1;}//放一串数据到发送缓冲区putbytes(unsigned char *outplace,unsigned char j){int i;for(i=0;i>4)&0