本文包含原理图、PCB、源代码、封装库、中英文PDF等资源
您需要 登录 才可以下载或查看,没有账号?注册会员
×
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit E=P2^7;
sbit RS=P2^5;
sbit RW=P2^6;
uint a,i,n;
uchar miao,shi,fen;
uchar code table[]="2011-02-20";
uchar code table1[]="11-02-20";
uchar code table2[]={0x31,0x32,0x33,0x34,0x35,0x36,0x37};
void data_sfm(uchar,uchar);
void display();
void delay(uint x)
{
uint y;
while(x--)
for(y=0;y<148;y++);
}
void command(uchar num)
{
P0=num;
RS=0;
RW=0;
E=0;
delay(10);
E=1;
delay(10);
}
void date(uchar x)
{
P0=x;
RS=1;
RW=0;
E=0;
delay(10);
E=1;
delay(10);
}
void init()
{
command(0x38);
command(0x01);
command(0x0c);
command(0x06);
command(0x80);
for(i=0;i<10;i++)
{
date(table[i]);
delay(10);
}
command(0x80+0x0d);
date(table2[n]);
command(0x80+0x40);
for(i=0;i<8;i++)
{
date(table1[i]);
delay(10);
}
}
void main()
{
init();
while(1)
{
display();
}
}
void timer0() interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
a++;
if(a==20)
a=0;
}
void data_sfm(uchar add,uchar dig)
{
uchar sh,gg;
sh=dig/10;
gg=dig%10;
command(0x80+0x40+add);
date(0x30+sh);
date(0x30+gg);
}
void display()
{
if(a==18)
{
miao++;
if(miao==60)
{
miao=0;
fen++;
if(fen==60)
{
fen=0;
shi++;
if(shi==24)
{
shi=0;
}
data_sfm(0,shi);
}
data_sfm(3,fen);
}
data_sfm(6,miao);
}
}
效果有了 但跑的跟秒表似的 无语
高手帮我处理下时间的问题
先谢了 |