自己在面包板上弄的单片机电子时钟为什么不运行程序?但是在proteus模拟没有任何问题?求大神帮忙
是哪里出问题了呢?1602液晶只亮但是不运行程序,单片机的IO口电位都是5v不变,求大神帮忙指点一下问题出在哪了,只有这些财富值了,多谢多谢程序是:#include<re...
是哪里出问题了呢?1602液晶只亮但是不运行程序,单片机的IO口电位都是5v不变,求大神帮忙指点一下问题出在哪了,只有这些财富值了,多谢多谢
程序是:
#include<reg52.h>
#define uint unsigned int
#define uchar unsigned char
sbit rs =P2^7;
sbit lcden=P2^5;
sbit rd=P2^6;
uchar miao,shi,fen,count,a=23,b=59,c=50;
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void write_com(uchar com)
{
rs=0;
lcden=0;
P0=com;
delay(5);
lcden=1;
delay(5);
lcden=0;
}
void write_date(uchar date)
{
rs=1;
lcden=0;
P0=date;
delay(5);
lcden=1;
delay(5);
lcden=0;
}
void write_sfm(uchar add,uchar date)
{
uchar shi,ge;
shi=date/10;
ge=date%10;
write_com(0x80+0x40+add);
write_date(0x30+shi);
write_date(0x30+ge);
}
void init()
{
rd=0;
lcden=0;
fen=50;
miao=59;
shi=23;
count=0;
write_com(0x38);
write_com(0x0c);
write_com(0x06);
write_com(0x01);
write_com(0x80);
write_com(0x80+0x40+6);
write_date(':');
delay(5);
write_com(0x80+0x40+9);
write_date(':');
delay(5);
miao=c;
fen=b;
shi=a;
write_sfm(10,miao);
write_sfm(7,fen);
write_sfm(4,shi);
TMOD=0x01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
EA=1;
ET0=1;
TR0=1;
}
main()
{
init();
while(1);
}
void timer()interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
count++;
if(count==20)
{
count=0;
miao++;
if(miao==60)
{
miao=0;
fen++;
if(fen==60)
{
shi++;
fen=0;
if(shi==24)
{
shi=0;
}
write_sfm(4,shi);
}
write_sfm(7,fen);
}
write_sfm(10,miao);
}
} 展开
程序是:
#include<reg52.h>
#define uint unsigned int
#define uchar unsigned char
sbit rs =P2^7;
sbit lcden=P2^5;
sbit rd=P2^6;
uchar miao,shi,fen,count,a=23,b=59,c=50;
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void write_com(uchar com)
{
rs=0;
lcden=0;
P0=com;
delay(5);
lcden=1;
delay(5);
lcden=0;
}
void write_date(uchar date)
{
rs=1;
lcden=0;
P0=date;
delay(5);
lcden=1;
delay(5);
lcden=0;
}
void write_sfm(uchar add,uchar date)
{
uchar shi,ge;
shi=date/10;
ge=date%10;
write_com(0x80+0x40+add);
write_date(0x30+shi);
write_date(0x30+ge);
}
void init()
{
rd=0;
lcden=0;
fen=50;
miao=59;
shi=23;
count=0;
write_com(0x38);
write_com(0x0c);
write_com(0x06);
write_com(0x01);
write_com(0x80);
write_com(0x80+0x40+6);
write_date(':');
delay(5);
write_com(0x80+0x40+9);
write_date(':');
delay(5);
miao=c;
fen=b;
shi=a;
write_sfm(10,miao);
write_sfm(7,fen);
write_sfm(4,shi);
TMOD=0x01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
EA=1;
ET0=1;
TR0=1;
}
main()
{
init();
while(1);
}
void timer()interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
count++;
if(count==20)
{
count=0;
miao++;
if(miao==60)
{
miao=0;
fen++;
if(fen==60)
{
shi++;
fen=0;
if(shi==24)
{
shi=0;
}
write_sfm(4,shi);
}
write_sfm(7,fen);
}
write_sfm(10,miao);
}
} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询