|
发表于 2012-7-7 17:00:54
|
显示全部楼层
你改成单词转换ADC0MD =0x82 转换结束后等ADC0MUX =0X80才能修改ADC0MUX 然后再次ADC0CMD=0X82启动转换,我这是352 16bit的多通道差分 单端混合采样
while(1)
{
ADC0CN = 0x07; // unique output codes, GAIN=128
ADC0MUX = 0x01; // Input pin selection:
ADC0MD = 0x82; // Start SINGLE conversions
while(!AD0INT); // wait till conversion complete
AD0INT = 0; // clear AD0 interrupt flag
// concatenate ADC0 data bytes to form the16-bit value
ADC_OutputVal = (char)ADC0H;
ADC_OutputVal <<= 8;
ADC_OutputVal += (long)ADC0M;
voltage_temp1=(float)((float)ADC_OutputVal/26);
current1=(voltage_temp1-offset_voltage1)/128*10.14/5+offset_current1;
ADC0CN = 0x00; // Gain = 1, Unipolar mode
ADC0MUX=0X08; //select pin
ADC0MD = 0x82; // Start SINGLE conversions
while(!AD0INT); // wait till conversion complete
AD0INT = 0; // clear AD0 interrupt flag
//ADC0MD=0X80;
ADC_OutputVal=(char)ADC0H ;
ADC_OutputVal<<=8;
ADC_OutputVal+=(long)ADC0M;
AIN0_voltage=(float)((float)ADC_OutputVal/26)/1000*10.14;
power1=current1* AIN0_voltage;
printf ("current1 = %.2fA\t ;AIN0_voltage=%.2fV\t;power=%.4fW,temp_voltage= %.2f\n",current1,AIN0_voltage,power1,voltage_temp1);
} |
|