直接看最后几行,msp430.做adc温度传感,一共1处,谢谢 #include <msp430x14x.h> #include "cry1602.h" #include "math.h" #define Num_of_Results 32 typedef unsigned char uchar; typedef unsigned int uint; uchar shuzi[]={"0123456789."}; uchar tishi[]={"temp:"}; static uint results[Num_of_Results]; void Trans_val(uint Hex_Val); /****************主函数******************/ void main(void) { WDTCTL=WDTPW+WDTHOLD; //关闭看门狗 ……………………………… ………… _EINT(); LPM0; } /****************中断服务函数********************* 用途;多次平均计算P60口的模拟电压数值************/ #pragma vector=ADC_VECTOR __interrupt void ADC12ISR(void) { static uint index=0; results[index++]=ADC12MEM0; //移动结果 if(index==Num_of_Results) { uchar i; unsigned long sum=0; index=0; for(i=0;i<Num_of_Results;i++) { sum+=results; } sum>>=5; //除以32 Trans_val(sum); } } /*********************转换数据函数**************** 功能;将16进制转换数据变换成三位10进制真实的模拟电压数据*****/ void Trans_val(uint Hex_val) { unsigned long caltmp; uchar d[4]; float c,i,r; uint curr_volt; //uchar i,r,n,p; caltmp=Hex_val; caltmp=(caltmp<<5)+Hex_val; //caltmp=Hex_val*33 caltmp=(caltmp<<3)+(caltmp<<1); //caltmp=caltmp*10 curr_volt=caltmp>>12; //curr_volt= caltmp/2^n r=(1700/(851-curr_volt))-1.4; c=(1/((1/298.15)-(log(r)/3950)))-273.15; c=c/10;//得到c为4位有效数字 小数点前、后各两位 d[0]=(int)(c); c-=d[0]; c*=10; d[1]=(int)c; c-=d[1]; c*=10; d[2]=(int)(c); c-=d[3]; c*=10; d[3]=(int)(c);
for(i=0;i<=4;i++)*******错误提示Error[Pe031]: expression must have integral type
{ DisplChar((6+i),1,shuzi[d]); } }
|