帮我设计一个具有选频特性的简易两位数字式频率计电路.有思路也行.
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/08 13:47:32
帮我设计一个具有选频特性的简易两位数字式频率计电路.有思路也行.
帮我设计一个具有选频特性的简易两位数字式频率计电路.有思路也行.
帮我设计一个具有选频特性的简易两位数字式频率计电路.有思路也行.
//
#include
unsigned char code display[] = {0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80, 0x90};
unsigned char code bittab[] = {0xfe,0xfd};
unsigned char num[2];
unsigned long play;
unsigned long count;
unsigned char i,c;
sbit s=P1^0;//控制选择I/O
void disp();
void adj();
void t1(void) interrupt 3
{ c++; }
void t0() interrupt 1
{
unsigned char turn;
TH0=0xfe;TL0=0x33;
count++;
if(count==1832)
{
count=0;
switch(turn)
{
case 0:s=0;{if(play>=50000)
{
play=(TL1+TH1*256+c*65536)*128;
TL1=0;TH1=0;c=0;
}
else
{
turn=1;s=1;
TL1=0;TH1=0;c=0;
}}break;
case 1:play=TL1+TH1*256+c*65536;
TL1=0;TH1=0;c=0;s=0;
turn=0;break;
}
adj();
}
i++;
if(i==2)i=0;
disp();
}
void main()
{
TMOD=0x51;
TH0=0xfe;TL0=0x33;
TH1=0;TL1=0;
ET0=1;ET1=1;
EA=1;
TR0=1;TR1=1;
adj();
while(1);
}
void disp()
{
P2=0xff;
P0=display[num[i]];
P2=bittab[i];
}
void adj()
{
num[0]=play%10;
num[1]=play/10%10;
}