main.c

来自「12887+1602drive goode luck!!」· C语言 代码 · 共 139 行

C
139
字号
#include <AT89X52.H>
#include "LCD1602.H"
#include "DS12C887.H"

char ch[9];
//---------------------------------
void ISRex1(void) interrupt 2
{
 unsigned char i,j; 
 GetTime();
 if(t_hour<100)
  {
    i=t_hour/10;
    j=t_hour%10;
    ch[0]=i+0x30;
    ch[1]=j+0x30;
    ch[2]=':';
  } 
 if(t_minute<100)
  {
    i=t_minute/10;
    j=t_minute%10;
    ch[3]=i+0x30;
    ch[4]=j+0x30;
    ch[5]=':';
  } 
 if(t_second<100)
  {
    i=t_second/10;
    j=t_second%10;
    ch[6]=i+0x30;
    ch[7]=j+0x30;
  }
 ch[8]=0;
 LCDclearLine(0);
 LCDdisplayStr("Time=");
 LCDdisplayStr(ch);

 GetDate();
 LCDclearLine(1);
 LCDdisplayStr("20");
 if(d_year<100)
  {
    i=d_year/10;
    j=d_year%10;
    LCDdisplayChar(i+0x30);
    LCDdisplayChar(j+0x30);
    LCDdisplayChar(0);
  } 
 if(d_month<100)
  {
    i=d_month/10;
    j=d_month%10;
    LCDdisplayChar(i+0x30);
    LCDdisplayChar(j+0x30);
    LCDdisplayChar(1);
  } 
 if(d_day<100)
  {
    i=d_day/10;
    j=d_day%10;
    LCDdisplayChar(i+0x30);
    LCDdisplayChar(j+0x30);
    LCDdisplayChar(2);
  }

 GetWeek();
 switch(week)
 {
  case 1: LCDdisplayStr(" Sun");
          LCDdisplayChar(2);
          break;
  case 2: LCDdisplayStr(" Mon");
          LCDdisplayChar(3);
          break;
  case 3: LCDdisplayStr(" Tue");
          LCDdisplayChar(4);
          break;
  case 4: LCDdisplayStr(" Wed");
          LCDdisplayChar(5);
          break;
  case 5: LCDdisplayStr(" Thu");
          LCDdisplayChar(6);
          break;
  case 6: LCDdisplayStr(" Fri");
          LCDdisplayChar(7);
          break;
  case 7: LCDdisplayStr(" Sat");
          break;
  default: break;
 } 

//清除中断申请 
 DS12C887_Data_Port=0xc; //锁存寄存器C地址
 ALE(); //锁存地址
 ReadEn();
 DS12C887_DS=1;
}

void main(void)
{
 LCDreset();
 LCDlight(1);
 IT1=1;
 EX1=1;
 EA=1;
/*
 t_second=0;
 t_minute=0;
 t_hour=0;
 At_second=0;
 At_minute=0;
 At_hour=0;
 week=0;
 d_day=25;
 d_month=10;
 d_year=10;
 DS12C887_init();
*/
/*
 t_second=0;
 t_minute=52;
 t_hour=19;
 At_second=0xff;
 At_minute=0xff;
 At_hour=0xff;
 week=7;
 d_day=25;
 d_month=10;
 d_year=8;
 SetTime();
 SetDate();
 SetWeek();
*/
 while(1);

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?