自己制作的一个隔离下载器,顺便做了一个时钟显示,分享出来 大家一起来研究学习,由于我的DS12C887内部电池坏了,所以不得以拆开做了一个外科手术,换了一个电池,内部原来的晶振就是这种,其实也是挺简单的,外壳使用的是8838壳子,T12电烙铁专用的,看这个盒子挺漂亮的就配套做了一个,用光耦隔离了TXD和RXD,输出的时候就不用调换线了,光耦已经转换过来了.两个拨码器是用来转换外部下载和板子自身的89C52下载程序调试用的,后面的琴键开关是切换电源用的,可以使用USB的5V输出,也可以从后面的两个DC座子给需要下载的板子芯片供电.带冷启动功能,原理是串口下载时CH340G的RTS引脚会变低电平,单片机只需要检测这个引脚的电平变化就可以了,缺点是使用串口调试时也回触发一次冷启动
另外提示一下,有些人搞不明白列地址的高位和低位,低位地址是00H~0FH,也就是1-16,最多也就只能定位到16列,而一块屏幕有128列,而高位地址是10H~1FH,高位地址+低位地址就能准确定位到128列了,当然SSD1306不只应用在12864上,(0~127)/16就是高位地址,(0~127)%16就是低位地址,和定时器的初值一个意思,我是这么理解的,如有不对,欢迎指正
电路原理图如下:
单片机源程序如下:- #include<STC89C5xRC.H>
- #include<intrins.h>
- #define uint unsigned int
- #define uchar unsigned char
- sbit SDA=P1^1;
- sbit SCL=P1^0;
- sbit RW=P2^5;
- sbit AS=P2^3;
- sbit CS=P2^4;
- sbit DS=P2^6;
- sbit km=P2^2;
- sbit jia=P2^1;
- sbit qh=P2^0;
- sbit k=P1^4;
- sbit RTS=P3^6;
- sbit j1=P1^7;
- sbit j2=P1^5;
- sbit led=P1^3;
- uchar t,tt;
- uchar smiao;
- bit ts;
- uchar code num[10][48]={
- {0x00,0x00,0x00,0x80,0xE0,0xF0,0x78,0x38,0x18,0x38,0xF0,0xF0,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x80,0xFF,0xFF,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x07,0x07,0x0E,0x0C,0x0E,0x07,0x07,0x03,0x00,0x00,0x00},/*"0",0*/
- {0x00,0x00,0x00,0x00,0x80,0xC0,0xE0,0xF0,0xF8,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x00,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x07,0x07,0x00,0x00,0x00,0x00,0x00,0x00},/*"1",0*/
- {0x00,0x00,0x00,0xC0,0xF0,0xF0,0x38,0x18,0x18,0x38,0xF8,0xF0,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0xE0,0xF0,0x7C,0x1F,0x0F,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x07,0x07,0x07,0x05,0x04,0x04,0x04,0x04,0x04,0x04,0x00,0x00},/*"2",0*/
- {0x00,0x00,0x00,0xC0,0xE0,0xF0,0x38,0x18,0x18,0x18,0xF8,0xF0,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x0C,0x0C,0x1C,0x3F,0xFF,0xF3,0xC0,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x07,0x0E,0x0C,0x0C,0x0E,0x07,0x07,0x03,0x00,0x00,0x00},/*"3",0*/
- {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xE0,0xF0,0xF8,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xE0,0xF8,0xFC,0xDF,0xC7,0xC3,0xFF,0xFF,0xFF,0xC0,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x07,0x07,0x00,0x00,0x00,0x00},/*"4",0*/
- {0x00,0x00,0x00,0x00,0xF0,0xF0,0xF0,0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00,0x00,0x00,0x00,0x80,0x8E,0x8F,0x0F,0x06,0x02,0x06,0x06,0x9E,0xFE,0xFC,0x60,0x00,0x00,0x00,0x00,0x00,0x03,0x07,0x07,0x0C,0x0C,0x0C,0x0E,0x07,0x07,0x03,0x00,0x00,0x00},/*"5",0*/
- {0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xE0,0xF8,0x78,0x18,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0xFC,0xFF,0x0F,0x07,0x06,0x06,0x0E,0xFC,0xFC,0xF8,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x07,0x0E,0x0C,0x0C,0x0C,0x0E,0x07,0x07,0x01,0x00,0x00},/*"6",0*/
- {0x00,0x00,0x00,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0xD0,0xF0,0xF0,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xF0,0xFC,0x7F,0x0F,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x07,0x07,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"7",0*/
- {0x00,0x00,0x00,0xC0,0xF0,0xF0,0x38,0x18,0x18,0x18,0xF0,0xF0,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0xF1,0xFF,0xFF,0x1E,0x0C,0x0C,0x1E,0x1F,0xFF,0xF3,0xE0,0x00,0x00,0x00,0x00,0x00,0x03,0x07,0x07,0x0E,0x0C,0x0C,0x0C,0x0E,0x07,0x03,0x01,0x00,0x00},/*"8",0*/
- {0x00,0x00,0x00,0xE0,0xF0,0xF0,0x38,0x18,0x18,0x38,0xF0,0xF0,0xE0,0x80,0x00,0x00,0x00,0x00,0x01,0x0F,0x1F,0x1E,0x38,0xB0,0xF0,0xF8,0xFF,0x3F,0x0F,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x0E,0x0F,0x07,0x01,0x00,0x00,0x00,0x00,0x00,0x00},/*"9",0*/
- };
- uchar code mao[ ]={0x00,0x00,0x60,0xF0,0xF0,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x0F,0x0F,0x06,0x00,0x00};//"::::"
- uchar code tuo[ ]={0x10,0x10,0x10,0x10,0x38,0x38,0x38,0x38,0x7C,0x7C,0x7C,0x7C,0xFE,0xFE,0xFE,0xFE,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x7F,0x7F,0x7F,0x7F,0x3E,0x3E,0x3E,0x3E,0x1C,0x1C,0x1C,0x1C,0x08,0x08,0x08,0x08};/*"<-->",0*/
- uchar code zi[3][88]={
- {0xFF,0x01,0x01,0xF9,0xF9,0x19,0xD9,0x99,0x19,0x99,0xD9,0x19,0x81,0xE1,0xF9,0xDD,0xC1,0xC1,0xC1,0xC1,0xC1,0x01,0x01,0x01,0x01,0xF9,0xF9,0x19,0x99,0xD9,0x79,0x09,0x01,0xF1,0xF1,0x31,0x31,0x31,0x31,0xF1,0xF1,0x11,0x01,0x01,0x01,0x01,0x01,0x01,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x31,0x31,0x31,0x31,0x31,0x31,0xF1,0xF1,0x31,0x31,0x31,0x31,0x39,0x39,0x01,0x01,0x01,0x01,0x01,0xFF},
- {0xFF,0x00,0x00,0xFF,0xFF,0x00,0xE1,0x79,0x1F,0x1F,0xF1,0x60,0x01,0x81,0xE0,0x7C,0x7E,0xC6,0x80,0x03,0x01,0x00,0x00,0x00,0x00,0xFF,0xFF,0x82,0x83,0xCE,0xFE,0x60,0x00,0xFF,0xFF,0x18,0x18,0x18,0x18,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x06,0x06,0x06,0x86,0xC6,0xE6,0x76,0x1E,0x06,0x06,0x06,0x46,0xC6,0x86,0x06,0x07,0x07,0x07,0x00,0x00,0x00,0x0C,0x0C,0x0C,0x0C,0x0C,0xCC,0x6C,0x3F,0x0F,0x1C,0x6C,0xCC,0x8C,0x0C,0x0C,0x0E,0x0C,0x00,0x00,0x00,0xFF},
- {0xFF,0x80,0x80,0x8F,0x8F,0x8C,0x8C,0x8C,0x8C,0x8C,0x80,0x8C,0x8E,0x83,0x81,0x80,0x80,0x81,0x83,0x86,0x8C,0x88,0x80,0x80,0x80,0xBF,0xBF,0x81,0x81,0x80,0x80,0x80,0x80,0x8F,0x87,0x86,0x86,0x86,0x86,0x87,0x8F,0x80,0x80,0x80,0x80,0x90,0x98,0x8C,0x8F,0x8F,0x8D,0x8C,0x8C,0x8C,0x8C,0x8C,0x8C,0x8C,0x8C,0x8D,0x8F,0x9C,0x98,0x90,0x80,0x80,0x90,0x98,0x98,0x8C,0x86,0x83,0x81,0x80,0x80,0x80,0x80,0x80,0x80,0x83,0x87,0x84,0x8C,0x9C,0x98,0x90,0x80,0xFF},
- };
- uchar code zizuo[2 ][32]={
- {0x00,0x60,0x78,0x58,0x50,0xFC,0xFC,0x50,0x50,0x40,0xF0,0xF0,0x00,0xFC,0xFC,0x00,0x00,0x80,0xC0,0xF0,0xFC,0x4C,0x60,0x38,0x1C,0xF4,0xF0,0x10,0x90,0x90,0x90,0x10},
- {0x00,0x00,0x1F,0x1F,0x01,0x3F,0x3F,0x19,0x1F,0x07,0x07,0x07,0x20,0x3F,0x3F,0x00,0x00,0x00,0x00,0x3F,0x3F,0x00,0x00,0x00,0x00,0x3F,0x3F,0x09,0x09,0x0C,0x04,0x00},
- };
- void delay(uint z)
- {
- uint x,y;
- for(x=z;x>0;x--)
- for(y=115;y>0;y--);
- }
- void start( )
- {
- SCL = 1;
- SDA = 1;
- SDA = 0;
- _nop_( );
- _nop_( );
- SCL = 0;
- _nop_( );
- _nop_( );
- }
- void stop( )
- {
- SCL=0;
- SDA=0;
- _nop_( );
- SCL=1;
- _nop_( );
- SDA=1;
- _nop_( );
- }
- void writebyte(uchar date)
- {
- uchar i;
- for(i=8;i>0;i--)
- {
- date<<=1;
- SDA=CY;
- SCL=1;
- _nop_( );
- _nop_( );
- SCL=0;
- _nop_( );
- _nop_( );
- }
- SDA=1;
- SCL=1;
- _nop_( );
- SCL=0;
- }
- void writedat(uchar date1)
- {
- start();
- writebyte(0x78);
- writebyte(0x40); //write data
- writebyte(date1);
- stop();
- }
- void writecomd(uchar comd)
- {
- start();
- writebyte(0x78);
- writebyte(0x00); //写指令
- writebyte(comd);
- stop();
- //led=~led;
- }
- void initoled( )
- {
- uchar x,y;
- writecomd(0xae); //--关闭oled面板
- writecomd(0x00); //---设置低列地址
- writecomd(0x10); //---设置高列地址
- writecomd(0x40); //--设置起始行地址设置映射RAM显示起始行 (0x00~0x3F)
- writecomd(0x81); //--设置对比度控制寄存器
- writecomd(0xFF); // 设置SEG输出电流亮度
- writecomd(0xa1); //--设置SEG/列映射 0xa0左右反置 0xa1正常
- writecomd(0xc8); //设置COM/行扫描方向 0xc0上下反置 0xc8正常
- writecomd(0xa6); //--设置正常显示
- writecomd(0xa8); //--设置多路复用率(1 to 64)
- writecomd(0x3f); //--1/64 duty
- writecomd(0xd3); //-设置显示偏移 移位映射RAM计数器 (0x00~0x3F)
- writecomd(0x00); //-不抵消
- writecomd(0xd5); //--设置显示时钟分频比/振荡器频率
- writecomd(0x80); //--设置分频比,将时钟设置为100帧/秒
- writecomd(0xd9); //--设定预充电时间
- writecomd(0xf1); //将预充电设置为15个时钟,放电设置为1个时钟
- writecomd(0xda); //--设置com引脚硬件配置
- writecomd(0x12);
- writecomd(0xdb); //--set vcomh
- writecomd(0x30); //设置VCOM取消选择级别
- writecomd(0x20); //-设置页面寻址模式 (0x00/0x01/0x02)
- writecomd(0x02); //
- writecomd(0x8d); //--设置电荷泵启用/禁用
- writecomd(0x14); //--set(0x10) 使能
- writecomd(0xa4); // 在屏幕上禁用整个显示 (0xa4/0xa5)
- writecomd(0xa6); // 禁用反转显示打开 (0xa6/a7)
- for(x=0;x<8;x++)
- {
- writecomd(0xb0+x);
- writecomd(0x00);
- writecomd(0x10);
- for(y=0;y<128;y++)
- {
- writedat(0x00); //清屏
- }
- }
- writecomd(0xaf); //--打开oled面板 //先清屏再开显示,否则容易显示断电前上一次的图像
- }
- void display( )
- {
- uchar x1,y1;
- for(y1=0;y1<8;y1++)
- {
- writecomd(0xb0+y1);
- writecomd(0x00);
- writecomd(0x10);
- for(x1=0;x1<128;x1++)
- {
- if(y1==0)
- {
- if(x1<2||x1>125)
- writedat(0xff);
- else
- writedat(0x03);
- }
- if(y1>0&&y1<7)
- {
- if(x1<2||x1>125)
- writedat(0xff);
- else
- writedat(0x00);
- }
- if(y1==7)
- {
- if(x1<2||x1>125)
- writedat(0xff);
- else
- writedat(0xc0);
- }
- }
- }
- }
- void writezi(bit s,uchar addrs,uchar nu) //写入一个数字24*16 正常/反白显示 列地址(0~127) 数据
- {
- uchar i,j;
- uchar n=0;
- for(j=0;j<3;j++)
- {
- writecomd(0xb2+j); //循环三次+起始页,需要3个页面显示16*24数字 固定显示从第2页开始
- writecomd(0x00+(addrs%16)); //起始地址低位 00H~0FH
- writecomd(0x10+(addrs/16)); //起始地址高位 10H~1FH
- if(nu<10) //小于10为数字
- {
- for(i=0;i<16;i++)
- {
- if(s==0)
- {
- writedat(num[nu][n]); //调用数字表格 ,正常显示
- }
- if(s==1)
- {
- writedat(~(num[nu][n])); //调用数字表格,反白显示
- }
- n++; //一组数字表格为48字节,单独用一个数字记录,for循环结束时N不被清零,第二次for循环时才能从第17个数字开始调用
- }
- }
- else //否则为冒号
- {
- if(nu==10) //=10用冒号
- {
- for(i=0;i<8;i++)
- {
- writedat(mao[n]); //调用冒号表格
- n++;
- }
- }
- else //否则清除冒号显示
- {
- for(i=0;i<8;i++)
- {
- writedat(0x00); //空白显示,即擦除冒号
- n++;
- }
- }
- }
- }
- }
- void tuoji(bit b) //脱机标志
- {
- uchar i;
- writecomd(0xb6);
- writecomd(0x04);
- writecomd(0x12);
- if(b==0) //1 显示脱机标志
- {
- for(i=0;i<56;i++)
- {
- writedat(tuo[i]);
- }
- }
- if(b==1) //0 清除脱机标志
- {
- for(i=0;i<56;i++)
- {
- writedat(0x00);
- }
- }
- }
- void writetime(uchar add,uchar date) // 地址 数据 P0口数据
- {
- CS=0; //片选
- DS=1;
- RW=1;
- AS=1;
- P0=add;
- _nop_();
- AS=0;
- RW=0;
- P0=date;
- _nop_();
- RW=1;
- AS=1;
- CS=1;
- }
- uchar readtime(uchar add) //读数据
- {
- uchar a;
- CS=0;
- RW=1;
- DS=1;
- AS=1;
- P0=add;
- AS=0;
- DS=0;
- P0=0xff;
- _nop_();
- a=P0;
- DS=1;
- AS=1;
- CS=1;
- return a;
- }
- /*9void inittime( )
- {
- writetime(0X0A,0X20); //开启时钟振荡器
- writetime(0X0B,0X06); //不开启闹钟使能中断,二进制数据,24小时格式
- writetime(0,7);
- writetime(1,0);
- writetime(2,54);
- writetime(3,0);
- writetime(4,10);
- writetime(5,0);
- writetime(6,3);
- writetime(7,16);
- writetime(8,7);
- writetime(9,19); //初始化芯片,仅须1次
- } */
- void timedisplay( ) //显示时间
- {
- uchar shi,fen,mia;
- uchar a1,a2,a3,a4,a5,a6;
- shi=readtime(4);
- fen=readtime(2);
- mia=readtime(0); //读时间
- if(smiao!=mia) //秒针有变化,没有变化的时候就不用去刷新屏幕了
- {
- a1=shi/10;
- a2=shi%10;
- a3=fen/10;
- a4=fen%10;
- a5=mia/10;
- a6=mia%10;
- writezi(0,8,a1);
- writezi(0,24,a2); //时
- writezi(0,40,10); //10代表:冒号
- writezi(0,48,a3);
- writezi(0,64,a4); //分
- writezi(0,88,a5);
- writezi(0,104,a6); //秒
- writezi(0,80,10);
- smiao=mia; //备份秒数,以便下一秒比较
- SBUF=mia; //串口查看秒针更新
- TI=0;
- TH0=0X4C;
- TL0=0X00;
- TR0=1;
- }
- }
- void setup(uchar add,uchar num1,uchar num2,uchar num3)
- {
- uchar n1,n2,n3,n4,n5,n6;
- n1=num1/10;
- n2=num1%10;
- n3=num2/10;
- n4=num2%10;
- n5=num3/10;
- n6=num3%10;
- switch(add)
- {
- case 1:
- {
- writezi(1,8,n1);
- writezi(1,24,n2); //时
- writezi(0,40,10); //10代表:冒号
- writezi(0,48,n3);
- writezi(0,64,n4); //分
- writezi(0,80,10);
- writezi(0,88,n5);
- writezi(0,104,n6); //秒
- };break;
- case 2:
- {
- writezi(0,8,n1);
- writezi(0,24,n2); //时
- writezi(0,40,10); //10代表:冒号
- writezi(1,48,n3);
- writezi(1,64,n4); //分
- writezi(0,80,10);
- writezi(0,88,n5);
- writezi(0,104,n6); //秒
- };break;
- case 3:
- {
- writezi(0,8,n1);
- writezi(0,24,n2); //时
- writezi(0,40,10); //10代表:冒号
- writezi(0,48,n3);
- writezi(0,64,n4); //分
- writezi(0,80,10);
- writezi(1,88,n5);
- writezi(1,104,n6); //秒
- };break;
- default:break;
- }
- }
- void initdisplay( )
- {
- uchar h,v;
- for(h=0;h<2;h++)
- {
- writecomd(0xb1+h);
- writecomd(0x00); //起始地址低位 00H~0FH
- writecomd(0x13); //起始地址高位 10H~1FH
- for(v=0;v<32;v++)
- {
- writedat(zizuo[h][v]);
- }
- }
- for(h=0;h<3;h++)
- {
- writecomd(0xb3+h);
- writecomd(0x04); //起始地址低位 00H~0FH
- writecomd(0x11); //起始地址高位 10H~1FH
- for(v=0;v<88;v++)
- {
- writedat(zi[h][v]);
- }
- }
- }
- void timer ( )
- {
- TMOD = 0x21;
- PCON = 0x00;
- SCON = 0x50;
- TH1 = 0xFd; //设置波特率 9600
- TL1 = 0xFd;
- TR1 = 1; //启动定时器1
- TH0=0X4C;
- TL0=0X00;
- EA=1;
- ET0=1;
- }
- void main( )
- {
- uchar sshi,sfen,smia,she;
- uchar as,ag;
- bit key,set;
- bit xz,lj;
- smiao=0x62;
- set=0;
- xz=0;
- lj=0;
- timer( );
- initoled( );
- initdisplay( );
- delay(4000);
- display( );
- //inittime( ); //DS12C887芯片初始化
- tuoji(lj);
- j1=j2=0;
- while(1)
- {
- if(set==0) //非设置状态,正常显示时间
- {
- timedisplay( );
- delay(50);
- }
- if(ts==1) //冒号闪烁,秒针更新后启动定时器0.5S以后定时器把ts置1,在主程序里面擦除冒号
- {
- //writezi(0,40,11);
- writezi(0,80,11);
- ts=0;
- }
- if(km==0&&key==0) //设置键
- {
- delay(10);
- if(km==0)
- {
- key=1;
- if(set==0) //设置之前读一次就可
- {
- sshi=readtime(4);
- sfen=readtime(2);
- smia=readtime(0);
- }
- set=1;
- she++;
- if(she>3)
- {
- she=0;
- set=0; //清除设置状态
- writetime(4,sshi);
- writetime(2,sfen);
- writetime(0,smia); //把设置好的参数写入时钟
- }
- setup(she,sshi,sfen,smia);
- }
- }
- if(jia==0&&key==0&&set==1) //设置状态加键允许操作
- {
- delay(10);
- if(jia==0)
- {
- key=1;
- t=100;
- while(jia==0)
- {
- while(jia==0&&t>0)
- {
- t--;
- delay(10); //10毫秒1次,100次即1秒后仍未松手判定为长按
- } //反之没到1秒松手,只能运行一次加操作
- switch(she)
- {
- case 1:
- {
- sshi++;
- if(sshi==24)
- {
- sshi=0;
- }
- as=sshi/10;
- ag=sshi%10;
- writezi(1,8,as);
- writezi(1,24,ag); //时
- };break;
- case 2:
- {
- sfen++;
- if(sfen==60)
- {
- sfen=0;
- }
- as=sfen/10;
- ag=sfen%10;
- writezi(1,48,as);
- writezi(1,64,ag); //分
- };break;
- case 3:
- {
- smia++;
- if(smia==60)
- {
- smia=0;
- }
- as=smia/10;
- ag=smia%10;
- writezi(1,88,as);
- writezi(1,104,ag); //秒
- };break;
- default:break;
- }
- delay(60); //长按状态60毫秒加一次,直到松手为止
- }
- }
- }
- if(qh==0&&key==0&&set==1) //取消键
- {
- delay(10);
- if(qh==0)
- {
- key=1;
- set=0;
- she=0;
- }
- }
- if(key==1) //按键松手检测
- {
- if(km==1&&jia==1&&qh==1&&k==1)
- {
- delay(10);
- if(km==1&&jia==1&&qh==1&&k==1)
- {
- key=0;
- }
- }
- }
- if(RTS==0&&xz==0&&lj==0) //联机状态,下载允许状态 lj=1脱机状态不会触发冷启动
- {
- delay(5);
- if(RTS==0)
- {
- j1=j2=1;
- delay(1800);
- j1=j2=0; //断电冷启动
- xz=1; //下载标志位,联机下载过程中RTS一直为0,避免下载完成之前再次触发冷启动
- }
- }
- if(xz==1) //检测RTS恢复高电平后,解除下载标志
- {
- if(RTS==1)
- {
- delay(10);
- if(RTS==1)
- {
- xz=0;
- }
- }
- }
- if(k==0&&key==0) //面板按键 短按开关电源,长按脱机/联机切换
- {
- delay(10);
- if(k==0)
- {
- t=100;
- while(k==0&&t>0)
- {
- delay(10);
- t--;
- if(t==0) //超过1秒长按识别
- {
- lj=~lj; //联机/脱机状态
- tuoji(lj); //屏幕显示联机/脱机图标
- }
- }
- key=1;
- if(t>0) //小于1秒短按识别
- {
- j1=~j1;
- j2=~j2;
- }
- }
- }
- }
- }
- void aa( ) interrupt 1
- {
- TH0=0X4C;
- TL0=0X00;
- tt++;
- if(tt==10)
- {
- TR0=0;
- ts=1;
- tt=0;
- }
- }
复制代码
附件里面是Gerber文件下载:
Gerber文件与原理图.7z
(285.41 KB, 下载次数: 16)
|