PROTUS仿真51單片機(jī)測(cè)頻程序
void main()
{
lcd_init();
EA=1;
PT1=1;
time=0;
TMOD=0X51;
TH0=(65535-20000)/256;
TL0=(65535-20000)%256;
TH1=0;
TL1=0;
while(1)
{
shift=0;
TH0=(65535-20000)/256;
TL0=(65535-20000)%256;
ET0=1;
TR0=1;
TH1=0;
TL1=0;
TR1=1;
while(time!=25);
ET0=0;
TR0=0;
TR1=0;
time=0;
num=(TH1*256+TL1)*2;
TH1=0;
TL1=0;
qian=num%10000/1000;
bai=num%1000/100;
shi=num%100/10;
ge=num%10;
lcd_1602xy(1,0,qian+0x30);
lcd_1602xy(1,1,bai+0x30);
lcd_1602xy(1,2,shi+0x30);
lcd_1602xy(1,3,ge+0x30);
lcd_1602xy(1,4,H);
lcd_1602xy(1,5,Z);
shift=1;
TH0=(65535-20000)/256;
TL0=(65535-20000)%256;
ET0=1;
TR0=1;
TH1=0;
TL1=0;
TR1=1;
while(time!=25);
ET0=0;
TR0=0;
TR1=0;
time=0;
num=(TH1*256+TL1)*2;
TH1=0;
TL1=0;
qian=num%10000/1000;
bai=num%1000/100;
shi=num%100/10;
ge=num%10;
lcd_1602xy(2,0,qian+0x30);
lcd_1602xy(2,1,bai+0x30);
lcd_1602xy(2,2,shi+0x30);
lcd_1602xy(2,3,ge+0x30);
lcd_1602xy(2,4,H);
lcd_1602xy(2,5,Z);
}
}
void time0() interrupt 1
{
TH0=(65535-20000)/256;
TL0=(65535-20000)%256;
time++;
}
PTOTEUS仿真結(jié)果如下:
評(píng)論