#include<stdio.h>
#include<math.h>
#define uchar unsigned char
#define R1 10000 // the value of standard resistor is 10000
#define c 0.0001// theroy current
#define Vref 2.5//refrence voltage
#define PGA 2//gain
char *Hex="0123456789ABCDEF";
void PrintHex(long a);
//恒流源波动0.1uA时的测试情况
int main(void)
{
double DM1 = 0x33404e;
double DM2 = 0x52007d;
double DT2 = (DM2/DM1) * R1 * c * PGA * (pow(2,23)-1)/(2 * Vref);
long DT2_int = (long)DT2;//舍弃小数位
printf("Decimal form:\n");
printf("%f\n",DT2);
printf("Hex form:\n");
PrintHex(DT2_int);
printf("\n");
return 0;
}
//函数的嵌套
void PrintHex(long a)//Convert Decimal to Hex and print laster
{
if(!a)
return;
PrintHex(a/16);
char x = Hex[a%16];
printf("%c",Hex[a%16]);
}
测温补偿测试程序
时间: 2024-10-11 20:41:05