标题: [求助]proteus仿真 利用89c51 和 6位 led数码管 设计电子钟00.00.00,中间两个灯不知道怎么不亮。求解 [打印本页]

作者: 乐逍遥    时间: 2013-2-28 21:08
标题: [求助]proteus仿真 利用89c51 和 6位 led数码管 设计电子钟00.00.00,中间两个灯不知道怎么不亮。求解

 

 

 

 

 

#include<reg51.h>
#define U8 unsigned char
code U8 tab[]={0xa0,0xbb,0x62,0x2a,0x39,0x2c,0x24,0xba,0x20,0x28};
code U8 scn[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb};
U8 buf[]={0,0,0,0,0,0};
U8 cnt=0;
U8 h=12; //记小时
U8 m=58; //记分钟
U8 s=55; //记秒
void main(void)
{
 EA=1;
 ET0=1;
 TMOD=0x01;
 TH0=0xee;
 TL0=0;
 TR0=1;
 while(1);
}
void int0(void)interrupt 1
{
 U8 i=0,a;
 TH0=0xee;
 TL0=0;
 i=cnt&0x05;
 a=tab[buf];
 if((i==1)&&cnt<100)
 {
  a=a&0xdf; 
 }
 
 P0=a;
 P2=scn;
 if(cnt==200)
 {
  cnt=0;
  s++;
  if(s==60)
  {
   m++;
   s=0;
   if(m==60)
   {
    h++;
    m=0;
    if(h==24)
    {
     h=0;
    }
   }
  }
  buf[0]=h/10;
  buf[1]=h%10;
  buf[2]=m/10;
  buf[3]=m%10;
  buf[4]=s/10;
  buf[5]=s%10;
 
 }
 cnt++;
}

 

[此贴子已经被作者于2013-2-28 22:07:24编辑过]

作者: ahshmj    时间: 2013-3-1 19:04
“中间两个灯”指的是什么? 中间两个数码管? 你的数码管不是常见的型号?字型码看着不一样呢?




欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1