|
本帖最后由 fxk1220 于 2012-10-31 09:50 编辑
ADC12转换结果跳动大,而且经常出现511这个数值。用内部参考电压2.5V 时,特别不稳定,AD转换结果很不理想,当用VCC做参考电压时,跳动范围大,但总体来说稍微好一点,输出结果相对线性些。哪位用过ADC遇到过类似的问题吗,求解,谢谢
初始化程序如下:
static void ADC_init(void)
{
UINT16 i;
P6DIR &=~(BIT3 +BIT4+BIT5); //P6.3--P6.5 dir set input status;
P6SEL |= BIT3 +BIT4 +BIT5; // ADC enable;
REFCTL0&= ~REFMSTR;
ADC12CTL0 = 0;
ADC12CTL0 = ADC12ON + ADC12MSC + ADC12SHT0_12 + ADC12REFON + ADC12REF2_5V;//AD采样保持周期为1024个时钟
ADC12CTL1 = ADC12SHP + ADC12CONSEQ_3 +ADC12SSEL_3; // 选择转换模式 SMCLK
ADC12CTL2 = ADC12RES_1 +ADC12TCOFF +ADC12REFOUT; //10 bit ,and shut down Temperature Sensor
// REF module enable; Vref output 2.5V
//REFCTL0 = REFMSTR + REFVSEL_2 + REFTCOFF + REFON + REFOUT;
ADC12MCTL0 |= ADC12SREF_1 + ADC12INCH_3; //通道 4
ADC12MCTL1 |= ADC12SREF_1 + ADC12INCH_4; //通道 5
ADC12MCTL2 |= ADC12SREF_1 + ADC12INCH_5 +ADC12EOS; //通道 6
for (i=0; i<0xFFFF; i++); // 等待基准电压建立
UCSCTL8 |= SMCLKREQEN;
ADC12CTL0 |= ADC12ENC; // Enable conversions
}
后面取值部分:
for(sample = 0; sample < Temp_CT; sample++)
{
ADC12CTL0 |= ADC12SC; // Start conversion
delay_us(150);
while (!(ADC12IFG & BIT2));
delay_us(30);
measure_value.tmp[1][sample] = ADC12MEM0;
measure_value.tmp[0][sample] = ADC12MEM1;
measure_value.tmp[2][sample] = ADC12MEM2;
delay_us(100);
ADC12CTL0 &= ~ADC12SC; // Stop conversion
delay_us(100);
}
|
阿莫论坛20周年了!感谢大家的支持与爱护!!
该献的血还是要献的。你不献他不献。难道让我去献? --- 出自坛友:lovejp1981
|