程序代码如下
#include <reg52.h>
#define uchar unsigned char
#define uint unsigned int
//sbit DX1=P0^1;
uchar code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d, 0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
uchar code bitnum[]={0xe,0xd,0xb,0x7};
void display();
void delay(uint us);
void delay(uint us) //一次大约延时28us
{
while(us--);
}
void display(){
uint i;
for(i=0;i<4;i++)
{
P2=bitnum[0];
P0=table[2];
delay(50);
P2=bitnum[1];
P0=table[3];
delay(50);
P2=bitnum[2];
P0=table[4];
delay(50);
P2=bitnum[3];
P0=table[5];
delay(50);
}
}
void main(void)
{
display();
}
程序跑起来后数码管应该显示2345,为什么显示2348
将延时从delay(500)后,显示为
改了延时参数显示正常,这个问题是什么原因呢??
很困惑啊~~~~~~~
|