void initADC(void)
{
ADC12CTL0 &= ~ENC;//stop a/d
ADC12CTL0 = ADC12ON + MSH;
ADC12CTL0 = SHT0_8;
ADC12CTL1 = SHP + CONSEQ_3;
ADC12MCTL0 = INCH_0;
ADC12MCTL1 = INCH_1;
ADC12MCTL2 = INCH_2 + EOS;
// ADC12IE = 0x0000;
Delay(5); //5ms
ADC12CTL0 |= ENC; // Enable conversions
ADC12CTL0 |= ADC12SC; //start conversion
Delay(5);
}
testBatVal = (ADvalue*3.3/4095)*12; //测量12V电压
以上为初始化程序,想实现的功能如下:ADC一直处于采样状态,外部参考源,3.3v,我在TIMER_A里每隔一段时间去读ADC12MEM1里的值。现在发现根据换算后值电压测得不对,不知道是什么原因,请大家看看上面的初始化程序有没有问题?
芯片我也换过了,还是不对。 |