本帖最后由 jw_andy 于 2012-9-27 18:25 编辑
unsigned short wADC_Voltage_X,wADC_Voltage_Y; // 采样ADC的电压,存储到wADC_Voltage_X,wADC_Voltage_Y为上一次的采样值
unsigned long dwADCTemp,dwADCTemp1;
第一种计算方法:
dwADCTemp = wADC_Voltage_X*80 + 48*wADC_Voltage_Y; //放大了128倍
第二种计算方法:
dwADCTemp = wADC_Voltage_X;
dwADCTemp <<=6;
dwADCTemp1 =wADC_Voltage_Y;
dwADCTemp1 <<=5;
dwADCTemp += dwADCTemp1;
dwADCTemp1 =wADC_Voltage_X+wADC_Voltage_Y;
dwADCTemp1 <<=4;
dwADCTemp += dwADCTemp1;
请问是直接用乘法快还是移位快? |