void produce()/*扫频产生程序*/
{
n3=sett1*100000+sett2*10000+sett3*1000+sett4*100+sett5*10+sett6;
if(flag1==1&flag2==1)/*使用定时器0*/
{
a1=0;b1=0;c1=0;
n2=low;
while(n2<high)
{
n1=50000/n2;
c=n1;
chuzhi();
COM0=h;
COM0=e;
ET0=1;
TR0=1;
display1(n2);
while(n<50)
{
keyscan();
}
n=0;
ET0=0;
TR0=0;
n2=n2+n3;
if(star==0)
break;
}
n2=high;
while(n2>low)
{
n1=50000/n2;
c=n1;
chuzhi();
COM0=h;
COM0=e;
ET0=1;
TR0=1;
display1(n2);
while(n<50)
{
keyscan();
}
n=0;
ET0=0;
TR0=0;
n2=n2-n3;
if(star==0)
break;
}
}
if(flag1==2&flag2==2)/*使用定时器1*/
{
a1=1;b1=0;c1=0;
n2=low;
while(n2<high)
{
n1=1000000/n2;
c=n1;
chuzhi();
COM1=h;
COM1=e;
ET0=1;
TR0=1;
display1(n2);
while(n<50)
{
keyscan();
}
n=0;
ET0=0;
TR0=0;
n2=n2+n3;
if(star==0)
break;
}
n2=high;
while(n2>low)
{
n1=1000000/n2;
c=n1;
chuzhi();
COM1=h;
COM1=e;
ET0=1;
TR0=1;
display1(n2);
while(n<50)
{
keyscan();
}
n=0;
ET0=0;
TR0=0;
n2=n2-n3;
if(star==0)
break;
}
}
if(flag1==1&flag2==2)/*先使用定时器0,再使用定时器1*/
{
a1=0;b1=0;c1=0;
n2=low;
while(n2<5000)
{
n1=50000/n2;
c=n1;
chuzhi();
COM0=h;
COM0=e;
ET0=1;
TR0=1;
display1(n2);
while(n<50)
{
keyscan();
}
n=0;
ET0=0;
TR0=0;
n2=n2+n3;
if(star==0)
break;
}
a1=1;b1=0;c1=0;
while(n2<high)
{
n1=1000000/n2;
c=n1;
chuzhi();
COM1=h;
COM1=e;
ET0=1;
TR0=1;
display1(n2);
while(n<50)
{
keyscan();
}
n=0;
ET0=0;
TR0=0;
n2=n2+n3;
if(star==0)
break;
}
n2=high;
while(n2>low)
{
n1=1000000/n2;
c=n1;
chuzhi();
COM1=h;
COM1=e;
ET0=1;
TR0=1;
display1(n2);
while(n<50)
{keyscan();}
n=0;
ET0=0;
TR0=0;
n2=n2-n3;
if(star==0)
break;
}
a1=0;b1=0;c1=0;
while(n2>low)
{
n1=50000/n2;
c=n1;
chuzhi();
COM0=h;
COM0=e;
ET0=1;
TR0=1;
display1(n2);
while(n<50)
{keyscan();}
n=0;
ET0=0;
TR0=0;
n2=n2-n3;
if(star==0)
break;
}
}
}
void main()
{
COM8253=0x36;/*8253初始化,选择定时器0,工作方式3,二进制*/
COM8253=0x76;/*选择定时器1,工作方式3,二进制*/
init();/*1602初始化*/
display();/*频率显示界面*/
TMOD=0x01;/*定时器0工作方式1*/
TH0=(65536-50000)/256;/*定时器0初值装入*/
TL0=(65536-50000)%256;
EA=1;/*开总中断*/
ET0=0;/*允许定时器0中断*/
TR0=0;/*允许定时器计数*/
a1=0;b1=0;c1=0;
while(1)
{
keyscan();
setlow(set1,set2,set3,set4,set5,set6,set11,set22,set33,set44,set55,set66);
if(star==1)
{
produce();
}
}
}
void T0_time() interrupt 1/*使定时器中断0*/
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
n++;
} |