输出频率 Pst 最小值 765.3 最大值 972.6
输出频率 Pd 最小值 702.3 最大值 1248.4
求 M=sqrt(5*(pow((Pd/Pst)+1),0.285)-1)
我写了一半 往下该怎么编写 M的函数程序
unsigned char i;
unsigned char ch=0;
float k1,k2;
float Pst,Pd;
float M;
unsigned PstLCD,PdLCD;
unsigned MLCD;
char Str1[]="ct?";
char Str2[]="dt?";
OSCCON = 0b01110000; OSCTUNE = 0b01000000;
TRISD=0x00;
TRISB=0b00001100;
ADCON1=0b00001101;
ADCON2=0b00111110;
ADCON0=0b00000001;
k1=(float)((972.6-765.3)/225.0);
k2=(float)((1248.4-702.3)/225.0);
for(;;)
{
ch=0;
ADCON0=(ch << 2)+1;
for(i = 0; i < 250; i++);
ADCON0bits.GO=1;
while(ADCON0bits.GO);
Pst=ADRESH;
ch=1;
ADCON1=(ch << 2)+1;
for(i = 0; i < 250; i++);
ADCON0bits.GO=1;
while(ADCON0bits.GO);
Pd=ADRESH;
Pst=(972.6-k1*Pst);
Pd=(1248.4-k2*Pd);
PstLCD=(unsigned)(Pst);
PdLCD=(unsigned)(Pd);
LCD_SetPos(1,1);
LCD_WriteString(Str1);
LCD_DisplayWord(PstLCD);
LCD_SetPos(2,1);
LCD_WriteString(Str2);
LCD_DisplayWord(PdLCD);
M=sqrt(5*(pow((Pd/Pst)+1),0.285)-1);
showM();