为什么段选中加入delay运行会出错?求解惑在子函数void sanmiao(uchar bai,uchar shi,uchar ge)中加注释的地方
#include <reg52.h>
#define uchar unsigned char
#define uint unsigned int
uchar t = 0;
uchar bai,shi,ge;
sbit dula = P2^6;
sbit wela = P2^7;
void delay(uint z);
void sanmiao(uchar bai,uchar shi,uchar ge);
uchar code table[]={
0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d,
0x7d, 0x07, 0x7f, 0x6f, 0x77, 0x7c,
0x39, 0x5e, 0x79, 0x71
};
void main(void)
{
uchar temp = 0;
wela = 0;
dula = 0;
TMOD = 0X01;
TH0 = (65536-50000)/256;
TL0 = (65536-50000)%256;
TR0 = 1;
ET0 = 1;
EA = 1;
while(1)
{
if(t == 20)
{
t = 0;
temp++;
if (temp == 100)
temp = 0;
bai = temp/100;
shi = temp%100/10;
ge = temp%10;
}
sanmiao(bai,shi,ge);
}
}
void delay(uint z)//延时程序
{
uchar i,j;
for(i=z;i>0;i--)
for(j=110;j>0;j--);
}
//显示动态扫描三个数码管
void sanmiao(uchar bai,uchar shi,uchar ge)
{
dula = 1;
P0 = table[bai];
dula = 0;
//delay(1); //段选加上延时函数后为什么会出错??
wela = 1;
P0 = 0xfe;
wela = 0;
delay(5);
dula = 1;
P0 = table[shi];
dula = 0;
//delay(1);
wela = 1;
P0 = 0xfd;
wela = 0;
delay(5);
dula = 1;
P0 = table[ge];
dula = 0;
//delay(1);
wela = 1;
P0 = 0xfb;
wela = 0;
delay(5);
}
void timer0() interrupt 1
{
TH0 = (65536-50000)/256;
TL0 = (65536-50000)%256;
t++;
}
|