#include<reg51.h>
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
uchar int_time;
uchar second;
uchar minute;
uchar hour;
uchar code date[]=" H.I.T. CHINA ";
uchar code time[]=" TIME 23:59:55 ";
uchar second=55,minute=59,hour=23;
void clock_init()
{
uchar i,j;
for(i=0;i<16;i++)
{
write_data(date[i]);
}
write_com(0x80+0x40);
for(j=0;j<16;j++);
{
write_data (time[j]);
}
}
void clock_write(uint s,uint m, uint h)
{
write_sfm(0x47,h);
write_sfm(0x4a,m);
write_sfm(0x4d,s);
}
void main
{
lcd _initial();
clock_init();
TMOD=0X01;
EA=1;
ET0=1;
TH0=(65536-46483)/256;
TL0=(65536-46483)%256;
TR0=1;
int_time=0;
second=55;
minute=59;
hour=23;
while(1)
{
clock_write(second,minute,hour);
}
}
void T0_interserve(void) interrupt 1 using 1 //
{
int_time++;
if(int_time==20)//
{
int_time=0; //
second++; //
}
if(second==60)//
{
second=0;
minute ++;
}
if(minute==60)
{
minute=0;
hour ++;
}
if(hour==24)
{
hour=0;
}
TH0=(65536_46083)/256;
TL0=(65536_46083)%256;
}
|