新聞中心

EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > PROTUS仿真51單片機(jī)測(cè)頻程序

PROTUS仿真51單片機(jī)測(cè)頻程序

作者: 時(shí)間:2016-11-30 來(lái)源:網(wǎng)絡(luò) 收藏

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é)果如下:


上一頁(yè) 1 2 下一頁(yè)

評(píng)論


技術(shù)專(zhuān)區(qū)

關(guān)閉