变量好像么有用处。请问问题出现哪里
#include<reg52.h>
#define uint unsigned int
#define uchar unsigned char
uchar code table[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e};
void display(uint);
void delay(uint);
void num();
uint count;
void main()
{
TMOD = 0x01;
TH0 = (65535-46080)/256;//50ms
TL0 = (65535-46080)%256;
TR0 = 1;
while(1)
{
num();
display(count);
}
}
void display(uint count)
{
P1 = 0xfe;
P0 = table[count/1000];
delay(5);
P1 = 0xff;
delay(5);
P1 = 0xfd;
P0 = table[count/100%10];
delay(5);
P1 = 0xff;
delay(5);
P1 = 0xfb;
P0 = table[count/10%10];
delay(5);
P0 = 0xff;
delay(5);
P1 = 0xf7;
P0 = table[count%10];
delay(5);
P1 = 0xff;
delay(5);
}
void num()
{
uint i;
if(TF0 == 1)
{
TF0 = 0;
TH0 = (65535-46080)/256;//50ms
TL0 = (65535-46080)%256;
i++;
if(i == 20)
{
i = 0;
count++;
}
}
}
void delay(uint z)
{
uint x,y;
for(x = z;x>0;x--)
for(y = 110;y>0;y--);
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
您好,谢谢你的建议,不过,我没有用中断。
一周热门 更多>