标题: 等精度频率计设计 [打印本页]

作者: dianzisheji    时间: 2017-5-3 11:32
标题: 等精度频率计设计
#include <reg52.h>
void delay1ms(void)
{
  unsigned char i,j;
  for(i=20;i>0;i--)
     for(j=248;j>0;j--);
     }
unsigned char codedispbitcode[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
unsigned char code LEDcode[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x00,0x40};
unsigned char T0count;
unsigned char T1count;
unsigned char timecount;
bit flag;
unsigned long x;
void Display()
{
P2=0xff;
P2=0xdf;
P0=LEDcode[x%1000000/100000];
delay1ms();
P2=0xef;
P0=LEDcode[x%100000/10000];
delay1ms();
P2=0xf7;
P0=LEDcode[x%10000/1000];
delay1ms();
P2=0xfb;
P0=LEDcode[x%1000/100];
delay1ms();
P2=0xfd;
P0=LEDcode[x%100/10];
delay1ms();
P2=0xfe;
P0=LEDcode[x%10];
delay1ms();
}
void main(void)
{
   TMOD=0x55;
   C_T=0;
   CP_RL2=0;
   TH0=0;
   TL0=0;
   TH1=0;
   TL1=0;
   TH2=(65536-49972)/256;
   TL2=(65536-49972)%256;
   TR1=1;
   TR0=1;
   ET0=1;
   ET1=1;
   ET2=1;
   EA=1;
  while (1)
   {
     if(flag==1)
     {
          flag=0;
          x=(T0count*65536+TH0*256+TL0)/(T1count*65536+TH1*256+TL1)*10000;
          }
          Display();
     }
   }
  void t0(void) interrupt 1 using 0
   {
     T0count++;
     }
     void t1(void) interrupt 3 using 0
   {
     T1count++;
     }
     void t2(void) interrupt 5 using 0
     {
          TH2=(65536-49972)/256;
          TL2=(65536-49972)%256;
          timecount++;
          if(timecount==20)
          {TR0=0;
             TR1=0;
             TR2=0;
             timecount=0;
             flag=1;
          }
     }
帮忙看一下该程序和该电路哪里出错了。

1.png (348.88 KB, 下载次数: 62)

1.png

作者: 暗双魂    时间: 2018-6-20 19:52
应该是晶振时基电路不起振,我仿真过,那个晶振很难起振
作者: YJGG    时间: 2019-2-15 22:21
没有具体故障现象,谁能看出哪里出错了
作者: shuisheng60    时间: 2019-2-16 18:55
这儿有一个同你相同的,你拿出参考一下http://www.51hei.com/bbs/dpj-147691-1.html
作者: shuisheng60    时间: 2019-2-16 19:01
这边还有一个AVR的,代码差不http://www.51hei.com/bbs/dpj-146532-1.html
作者: springcsp    时间: 2019-7-15 16:10
等精度频率计!
作者: 91hei电子    时间: 2020-4-3 16:39
可能是不起振,也可能是频率过高导致闪烁过快,仿真软件不能显示。




欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1