本帖最后由 niupai0409 于 2015-7-9 20:42 编辑
求大神指点!!!!!急~
程序见附件!!!
#include<reg51.h>
#include<intrins.h>
#define LCDDATE P0
#define LCD P0
#define NOP()_nop_()
sbit RW=P2^5;
sbit RS=P2^6;
sbit LCDE=P2^7;
unsigned char string[]="I LOVE COMPUTER!";
unsigned char
time[]="TIME:15:35:42";
unsigned char hou=15,min=32,sec=36,num=0;
void LcdDelay(unsigned int i)
{
unsigned char a;
for(i;i>0;i--)
{
for(a=2;a>0;a--);
}
}
void LcdWriteCommand(unsigned char com)
{
LCDE=0;
RW=0;
RS=0;
LCD=com;
LcdDelay(5);
LCDE=1;
NOP();
NOP();
LCDE=0;
}
void LcdWriteData(unsigned char dat)
{
LCDE=0;
RW=0;
RS=1;
LCD=dat;
LcdDelay(5);
LCDE=1;
NOP();
NOP();
LCDE=0;
}
void LcdInit()
{
LcdWriteCommand(0x38);
LcdWriteCommand(0x0c);
LcdWriteCommand(0x06);
LcdWriteCommand(0x01);
}
void time0()interrupt 1
{
unsigned char num=0;
unsigned char i;
TH0=55536/256;
TL0=55536%256;
num=num+1;
if(num>99)
{
num=0;
sec=sec+1;
if(sec>59)
{
sec=0;
min=+1;
if(min>59)
{
min=0;
hou=+1;
if(hou>23)
{
hou=0;
}
}
}
Time[5]=hou/10+0x30;
Time[6]=hou%10+0x30;
Time[7]=min/10+0x30;
Time[8]=min%10+0x30;
Time[9]=sec/10+0x30;
Time[10]=sec%10+0x30;
LcdWriteCommand(0x80);
for(i=0;i<13;i++)
{
LcdWriteData(Time
);
}
}
}
void main()
{
unsigned char i;
TMOD=0x01;
TH0=55536/256;
TL0=55536%256;
ET0=1;
EA=1;
TR0=1;
LcdInit();
LcdDelay(100);
LcdWriteCommand(0x80);
for(i=0;i<13;i++)
{
LcdWriteData(Time);
}
LcdWriteCommand(0xc0);
for(i=0;i<16;i++)
{
LcdWriteData(string);
}
while(1);
}
-
-
程序.txt
下载积分: 积分 -1 分
1.58 KB, 下载次数: 16, 下载积分: 积分 -1 分
一周热门 更多>