#include<reg52.h>
#include<stdio.h>
#include<string.h>
#include<lcd1602.h>
void lcd_re();
void lcd_d(unsigned char sf[],unsigned char ppp);
#define cry 12000000.0000f
sbit Pt = P1^0;
sbit key1=P3^7;
sbit key2=P3^6;
unsigned int Tin,aaa,Asp=214,a=2,numf=0;
unsigned int hh;
unsigned int number;
float Tint;
bit m,n,o;
unsigned char table11[15]={0};
void delay(unsigned char x) //误差 0us
{
unsigned char aa,bb;
for(bb=x;bb>0;bb--)
for(aa=120;aa>0;aa--);
}
void main()
{
TMOD=0x01;
ET0=1;
TR0=1;
EA=1;
lcd_re();
key2=1;
while(1)
{
Tint=(65536.0000-cry/24.000/Asp)*1.0000;
Tin= Tint;
sprintf(table11,"%f",Asp*1.0/1000);
lcd_d(table11,0);
sprintf(table11,"%f",Tint*1.0);
lcd_d(table11,0x08);
sprintf(table11,"%f",TH0*1.0);
lcd_d(table11,0x40);
sprintf(table11,"%f",TL0*1.0);
lcd_d(table11,0x40+0X08);
if(key1==0)
Asp++;
}
}
void ASD()interrupt 1
{
Pt=!Pt;
a=0;
TH0=Tin>>8;
TL0+=Tin;
}
频率(Asp) 实际频率 误差
59 59.98 0.02
60 59.98 0.02
61 59.13 1.87
64 63.98 0.02
65 62.88 2.12
74 73.98 0.02
75 72.2 2.8
1751 1747 4
1801 1798 3
1851 1169 682
1901 961.3 939.7 |