微型打印机C51控制程序

来源:本站
导读:目前正在解读《微型打印机C51控制程序》的相关信息,《微型打印机C51控制程序》是由用户自行发布的知识型内容!下面请观看由(电工技术网 - www.9ddd.net)用户发布《微型打印机C51控制程序》的详细说明。
简介:本文给大家提供一个微型打印机C51控制程序。

/*本程序为新荣达微型打印机的控制程序 , 通过计算机串行通讯控制输入要打印的信息,打印信息用长度为36的数组保存,在根据数组中的数据打印相应的结果,第一位为起始位,第二位为命令位,第三~五位为地址位,第六位为器件类型,第七~二十二位为位置描述,第二十三位为事件类型,后面的是时间,最后一位是校验位。*/#include#define UCHAR unsigned char#define UINT unsigned int#define TIME1 1000#define TIME2 200#define LEN 35.......extern UCHAR sd[36]={0x9a,0x01,0x30,0x30,0x31,0x01,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,"050707000000"};void Delay(UCHAR m){ while(--m);}void DelayInt(UINT n){ while(--n);}void Out(char sa){ STB=1; while(BUSY); Delay(5); P0 = sa; STB = 0; Delay(4); STB = 1;}void Outs(char ss[]){ char i=0; while(ss[i]!=0x00) {  Out(ss[i]); i++; }}void Outn(char ss[],UCHAR x,UCHAR y){ char i; for(i=x-1;i  {  Out(ss[i]); }}void OutSerial(char sb){ ES = 0; SBUF = sb; while(!TI); TI = 0; ES = 1;}void main(){ UCHAR j; for(j=1;j<=TIME2;j++) {  DelayInt(TIME1); } SCON = 0x50; T2CON = 0x34; RCAP2H = 0xff; RCAP2L = 0xb2; PS = 1; IE = 0xb1;             //设置SFR和波特率 while(1) {  if(SEL == 1)  {   YLW = 1;   if(PE == 0)  {     RED = 1;    Out(0x1b);    Out(0x40);     Out(0x1b);    Out(0x4E);    Out(0x03); //装订长3行    Out(0x1b);    Out(0x38);    Out(0x00); //16*16点阵汉字    Out(0x1b);    Out(0x56);    Out(0x02);     Outn(sd,3,5);     Outs("# ");    Out(0x1b);    Out(0x57);    Out(0x01);     if(sd[5] == 0x01)     {      Outs("双波段");     }     else if(sd[5] == 0x02)     {      Outs("光截面");     }     else     {      Outs("其他");     }     Outs("探测器");    Out(0x0a);    Out(0x0d);      Outn(sd,7,22);    Out(0x0a);    Out(0x0d);      if(sd[22] == 0x01)     {      Outs("火警");     }     else if(sd[22] == 0x02)     {      Outs("故障");     }     else     {      Outs("待定");     }    Out(0x0a);    Out(0x0d);        Out(0x1b);    Out(0x56);    Out(0x02);     Out(sd[23]);     Out(sd[24]);     Outs("-");     Out(sd[25]);     Out(sd[26]);     Outs("-");     Out(sd[27]);     Out(sd[28]);     Outs(" ");     Out(sd[29]);     Out(sd[30]);     Outs(":");     Out(sd[31]);     Out(sd[32]);     Outs(":");     Out(sd[33]);     Out(sd[34]);    Out(0x1b);    Out(0x57);    Out(0x01);    Out(0x0a);    Out(0x0d);     Outs("********************");    Out(0x0a);    Out(0x0d);  }  else  {   RED = 0;  }  }  else  {   YLW = 0;  } } }void SerialInt() interrupt 4 //using 1{ char sum,sa; char i; ES = 0;   if(RI)   {     RI = 0;     for(i=0;i      {     sd[i] = sd[i+1];     }     sd[LEN] = SBUF;     sa = 0x9a;     if(sd[0] == sa)     {        sum = 0;        for(i=1;i         {          sum=sum+sd[i];        }        if(sum == sd[LEN])        {                 OutSerial(0xa0);            }             }    }   if(TI)   {     TI = 0;   } ES = 1;}

提醒:《微型打印机C51控制程序》最后刷新时间 2024-03-14 01:07:38,本站为公益型个人网站,仅供个人学习和记录信息,不进行任何商业性质的盈利。如果内容、图片资源失效或内容涉及侵权,请反馈至,我们会及时处理。本站只保证内容的可读性,无法保证真实性,《微型打印机C51控制程序》该内容的真实性请自行鉴别。