微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 硬件工程师文库 > 基于ds1302的电子日历系统

基于ds1302的电子日历系统

时间:09-19 来源:互联网 点击:

e_1602dat(‘N’);

  break;

  }

  }

  //*键盘扫描有关函数 void keyscan()

  {

  if(key1==0)

  {

  delay(9);

  if(key1==0)

  {

  delay(20);

  while(!key1);

  key1n++;

  if(key1n==9) key1n=1;

  switch(key1n)

  {

  case 1:

  TR0=0;

  write_1602com(er+0x09);

  write_1602com(0x0f);

  temp=(miao)/10*16+(miao)%10;

  write_1302(0x8e,0x00);

  write_1302(0x80,0x80|temp);

  write_1302(0x8e,0x80);

  break; case 2: write_1602com(er+6);

  break;

  case 3:

  write_1602com(er+3);

  break;

  case 4:

  write_1602com(yh+0x0e);

  break;

  case 5:

  write_1602com(yh+0x0a);

  break;

  case 6:

  write_1602com(yh+0x07);

  break;

  case 7:

  write_1602com(yh+0x04);

  break;

  case 8:

  write_1602com(0x0c);

  TR0=1;

  temp=(miao)/10*16+(miao)%10;

  write_1302(0x8e,0x00);

  write_1302(0x80,0x00|temp);

  write_1302(0x8e,0x80);

  break;

  }

  }

  }

  if(key1n!=0)

  {

  if(key2==0)

  {

  delay(10);

  if(key2==0)

  {

  delay(20);

  while(!key2);

  switch(key1n) {

  case 1:miao++;

  if(miao==60)

  miao=0;

  write_sfm(0x08,miao);

  temp=(miao)/10*16+(miao)%10;

  write_1302(0x8e,0x00);

  write_1302(0x80,temp);

  write_1302(0x8e,0x80);

  write_1602com(er+0x09);

  break;

  case 2:fen++;

  if(fen==60)

  fen=0;

  write_sfm(0x05,fen);

  temp=(fen)/10*16+(fen)%10;

  write_1302(0x8e,0x00);

  write_1302(0x82,temp);

  write_1302(0x8e,0x80);

  write_1602com(er+6);

  break; case 3:shi++;

  if(shi==24)

  shi=0;

  write_sfm(2,shi);

  temp=(shi)/10*16+(shi)%10;

  write_1302(0x8e,0x00);

  write_1302(0x84,temp);

  write_1302(0x8e,0x80);

  write_1602com(er+3);

  break; case 4:week++;

  if(week==8) week=1;

  write_1602com(yh+0x0C);

  write_week(week);

  temp=(week)/10*16+(week)%10;

  write_1302(0x8e,0x00);

  write_1302(0x8a,temp);

  write_1302(0x8e,0x80);

  write_1602com(yh+0x0e);

  break; case 5:ri++;

  if(ri==32)

  ri=1;

  write_nyr(9,ri);

  temp=(ri)/10*16+(ri)%10;

  write_1302(0x8e,0x00);

  write_1302(0x86,temp);

  write_1302(0x8e,0x80);

  write_1602com(yh+10);

  break;

  case 6:yue++;

  if(yue==13)

  yue=1;

  write_nyr(6,yue);

  temp=(yue)/10*16+(yue)%10;

  write_1302(0x8e,0x00);

  write_1302(0x88,temp);

  write_1302(0x8e,0x80);

  write_1602com(yh+7);

  break;

  case 7:nian++;

  if(nian==100) nian=0;

  write_nyr(3,nian);

  temp=(nian)/10*16+(nian)%10;

  write_1302(0x8e,0x00);

  write_1302(0x8c,temp);

  write_1302(0x8e,0x80);

  write_1602com(yh+4);

  break;

  }

  }

  }

  if(key3==0)

  {

  delay(10);

  if(key3==0)

  {

  delay(20);

  while(!key3);

  switch(key1n)

  {

  case 1:miao--;

  if(miao==-1)

  miao=59;

  write_sfm(0x08,miao);

  temp=(miao)/10*16+(miao)%10;

  write_1302(0x8e,0x00);

  write_1302(0x80,temp);

  write_1302(0x8e,0x80);

  write_1602com(er+0x09);

  break; case 2:fen--;

  if(fen==-1)

  fen=59;

  write_sfm(5,fen);

  temp=(fen)/10*16+(fen)%10;

  write_1302(0x8e,0x00);

  write_1302(0x82,temp);

  write_1302(0x8e,0x80);

  write_1602com(er+6);

  break;

  case 3:shi--;

  if(shi==-1)

  shi=23;

  write_sfm(2,shi);

  temp=(shi)/10*16+(shi)%10;

  write_1302(0x8e,0x00);

  write_1302(0x84,temp);

  write_1302(0x8e,0x80);

  write_1602com(er+3);

  break; case 4:week--;

  if(week==0)

  week=7;

  write_1602com(yh+0x0C);

  write_week(week);

  temp=(week)/10*16+(week)%10;

  write_1302(0x8e,0x00);

  write_1302(0x8a,temp);

  write_1302(0x8e,0x80);

write_1602com(yh+

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top