我用MSP430G2553的ADC10采集外部电压,ADC10的参考电压为内部的2.5V。外部电压为2.045,ADC10采集到的值为660左右;外部电压为2.097时,ADC10采集到的值为676左右;
我感觉内部参考电压在3.17V左右,并不在2.5V,不知道为什么?
以下是配置的程序,不知道有没有问题;
unsigned int BatADC = 0;
void main( void )
{
// Stop watchdog timer to prevent time out reset
WDTCTL = WDTPW + WDTHOLD;
//P1DIR &= ~BIT5;
ADC10CTL0 &= ~ENC;
ADC10CTL0 = ADC10SHT_3 + ADC10ON + REFON + REF2_5V; //ADC10_ON,REF_ON,REF_2.5V,
ADC10CTL1 = INCH_5 + ADC10SSEL0 + ADC10SSEL1; // // input A5,SMCLK
ADC10AE0 |= BIT5; // PA.5 ADC option select,模拟输入使能;
ADC10CTL0 |= ENC;
for(unsigned int i= 0;i<10000;i++);
while(1)
{
ADC10CTL0 |= ADC10SC; // Sampling and conversion start
while((ADC10CTL0 & ADC10IFG) != ADC10IFG); //如果转换完成
BatADC = ADC10MEM;
ADC10CTL0 &= ~ADC10IFG;
}
}