数码管的动态计数问题

2019-03-24 19:16发布

先上仿真图,, 我现在只想让数码管动态计数,从0到60计数,,仿真的时候怎么啥都没有啊?调试的时候发现好像进不去while的大循环,,
  以下是我纠结的程序,,   #include<reg52.h>
#define uint unsigned int
#define uchar unsigned char
sbit wela1=P2^0;
sbit wela2=P2^1;
void delay(uint z);
void init();
uchar aa,shi,ge,temp;
uchar code table[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71 };
void display(uchar shi,uchar ge);
void main()
{
 init();
 while(1)
 {
  if(aa==20)
  {
   aa=0;
   temp++;
   if(temp==60)
    {
     temp=0;
    }
   shi=temp/10;
   ge=temp%10;
      
  }
  display(shi, ge);
 }
} void delay(uint z)       //延迟函数
{
 uint x,y;
 for(x=z;x>0;x--)
  for(y=110;y>0;y--);
}
void init()        //初始化函数
{
 P0=0x00;
 aa=0;
 wela1=0;
 wela2=0;
 temp=0;
 TMOD=0x01;
 TH0=(65536-50000)/256;
 TL0=(65536-50000)%256;
 EA=1;
 ET0=1;
 TR0=1;
} void dispaly(uchar temp)   //显示子函数
{
 shi=temp/10;
 ge=temp%10;
 
 P0=table[shi];
 wela1=0;
 wela2=1;
 delay(5);
   P0=table[ge];
 wela2=0;
 wela1=1;
 delay(5);
}
void timer0() interrupt 1
{
  TH0=(65536-50000)/256;  //把数据装入高八位
  TL0=(65536-50000)%256;
  aa++; 
}       编译之后没有错误,但是有三个警告,,好像是说我的display函数有问题,,我看不出来有什么问题,,
此帖出自小平头技术问答
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
7条回答
kobe1941
2019-03-25 11:54
确实是写错了,后来发现除了这个还有temp的问题,,现在已经可以了,,看完程序不容易,还能找着这个错误更不容易,以后还是不贴这种程序了,还是谢谢你

一周热门 更多>