到底是什么原因 请高人给我分析一下 不悬空可以采样别的电压 就是悬空有1.8V电压
void adinit()
{
P6SEL|=BIT1;
ADC12CTL0|=SHT0_15+ADC12ON+MSC; //设置采样周期不开内部参考电压
ADC12CTL1|=SHP+CONSEQ_3; // 表示采样直接由ADC12SC控制,时钟源默认内部时钟
ADC12MCTL1|=INCH_1; //用输入通道1即A1
ADC12IE|=BIT1;
//ADC12IFG=0xff;
//ADC12采样中断
ADC12CTL0|=ENC;
ADC12CTL0 |= ADC12SC; //开启转换
_EINT(); //开启总中断
}
#pragma vector=ADC12_VECTOR
__interrupt void ADC12ISR (void)
{
//static uchar index = 0;
//average=ADC12MEM1;
// while((ADC12IFG & BIT1)!=0);
results[index++] = ADC12MEM1; // Move results, IFG is cleared
if(index == 31)
{
uchar n;
average = 0;
for(n = 0; n < 32; n++)
{
average += results[n];
}
average >>= 5; //除以32求平均值
average=(average*3300)/4096;
index = 0;
}
ADC12CTL0 &= ~ADC12SC;
}