我在这个循环中来测量单片机的供电电压,发现第一次运行时的q的值是340多,第二次及就是200多,发现严重不准,基准电压2.5v,内部通道, 采样时64个时钟周期,我用官方的例程也是同样的问题。
测试程序如下:
#include <msp430.h>
int main(void)
{
unsigned int q;
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
for (;;)
{
ADC10CTL0 &= ~ENC; //ADC10 disabled
ADC10CTL0 &= ~ADC10ON; //OFF the ADC10
ADC10CTL0 |= SREF_1 + ADC10SHT_0 + REFON + ADC10ON+REF2_5V;
ADC10CTL1 |= INCH_12 + CONSEQ_0 ;
//ADC10CTL0 &= ~ENC;
while(ADC10CTL1 & ADC10BUSY);
ADC10CTL0 |= ENC;
ADC10CTL0 |= ADC10SC; //start convert
while (ADC10CTL1 & ADC10BUSY);//(!(ADC10IFG & ADC10IFG0))
q = ADC10MEM;
ADC10CTL0 &= ~ENC; //ADC10 disabled
ADC10CTL0 &= ~ADC10ON; //OFF the ADC10
}
}
哪个大神帮我看看什么问题。不胜感激。 |