#include <reg51.h>
unsigned char code SEG7[10]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90};
/*===================================*/
void delay(unsigned int k);
//-----------------------------------------------------------
void main(void)
{
unsigned char val1=1,val2=1,i;
while(1)
{
for(i=0;i<250;i++)
{
P1= SEG7[val1%10];
P2=0xf7;
delay(1);
P1= SEG7[val1/10];
P2=0xfb;
delay(1);
P1= SEG7[val2%10];
P2=0xfd;
delay(1);
P1= SEG7[val2/10];
P2=0xfe;
delay(1);
}
val1=val1+1;
if(val1>99){val1=1;}
val2=val2+2;
if(val2>99){val2=1;}
}
}
//----------------------------------------------------
void delay(unsigned int k)
{
unsigned int i,j;
for(i=0;i<k;i++){
for(j=0;j<121;j++)
{;}}
}
这个程序是两个局部变量显示实验,在KEIL3上不能编译,形成HEX文件。请各位大侠看看错在什么地方。
|
|