keil軟件生成HEX文件,在proteus仿真實現
C程序
#include<reg51.h>
#define uint unsigned int
#define uchar unsigned char
uchar code num[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
uint i,c;
sbit ret=P3^0;
void main ()
{ i=0;c=0;
TMOD=0x10;
ET1=1;
EA=1;
TR1=1;
TH1=(65536-5000)/256;
TL1=(65536-5000)%256;
P0=num[0];P2=num[0];P1=num[0];
while(ret==0){
while(1)
{
if(ret==0){EA=0;}
else
{ EA=1;
if(c==20){c=0;i++;}
if(i<600){P0=num[i/100];P2=num[i%100/10];P1=num[i%10];}
else i=0;
}
}
}
}
void timer1 () interrupt 3
{ TH1=(65536-5000)/256;
TL1=(65536-5000)%256;
c++;
}
|