计数器60秒数码管显示
时间:10-02
整理:3721RD
点击:
#include<reg52.h>
unsigned char code dispcode[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71,0x00};
unsigned char Second;
unsigned char tcount;
void main(void)
{
TMOD=0x01;
TH0=0x4c;
TL0=0x00;
TR0=1;
ET0=1;
EA=1;
tcount=0;
Second=0;
P0=dispcode[Second/10];
P2=dispcode[Second%10];
while(1);
}
void t0(void) interrupt 1 using 0
{
tcount++;
if(tcount==20)
{
tcount=0;
Second++;
if(Second==60)
{
Second=0;
}
P0=dispcode[Second/10];
P2=dispcode[Second%10];
}
TF0=0;
TH0=0x4c;
TL0=0X00;
}
帮忙看看为什么无法显示!
unsigned char code dispcode[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71,0x00};
unsigned char Second;
unsigned char tcount;
void main(void)
{
TMOD=0x01;
TH0=0x4c;
TL0=0x00;
TR0=1;
ET0=1;
EA=1;
tcount=0;
Second=0;
P0=dispcode[Second/10];
P2=dispcode[Second%10];
while(1);
}
void t0(void) interrupt 1 using 0
{
tcount++;
if(tcount==20)
{
tcount=0;
Second++;
if(Second==60)
{
Second=0;
}
P0=dispcode[Second/10];
P2=dispcode[Second%10];
}
TF0=0;
TH0=0x4c;
TL0=0X00;
}
帮忙看看为什么无法显示!
求大神指教啊!
没电路图,而且为什么段码要送给P2?位选中了没有?
我也不清楚,这是我下的程序!但是不好使!也不知道为什么!
你的段码是要送P2口显示还是P0口显示,还是你用的是两个两位的数码管?还没有选位?仿真图也没有?
