Quantcast
Channel: MSP 低功耗微控制器论坛 - 最近的话题
Viewing all articles
Browse latest Browse all 3634

MSP430的ADC采集值偏差太大问题

$
0
0

用的是MSP430FR5972芯片的P9.5口采集一电压信号,万用表测量值3mV,430采集是1000/4096*2.5=0.6v左右;采集1.9V时,430采集是4095/4096*2.5=2.5v左右。不知道什么原因,希望大师们给指点。在此谢过!

电路硬件连接是电阻分压240K/75K得到2.5V以下电压信号,然后放大器跟随,输出直接到430的P9.5。

软件是TI的例子改的,关键语句如下,详细程序在附件。

P9DIR = 0X00;
P9SEL1 |= BIT5 ; // Configure P9.5 for ADC
P9SEL0 |= BIT5 ;

ADC12CTL0 &= ~ADC12ENC; // Disable ADC12
while(REFCTL0 & REFGENBUSY); // If ref generator busy, WAIT
REFCTL0 |= REFVSEL_2 | REFON; // Select internal ref = 2.5V

ADC12CTL0 = ADC12SHT0_8 + ADC12ON; //sample-and-holdtime
ADC12CTL1 = ADC12SHP; // ADCCLK = MODOSC; sampling timer
ADC12CTL2 |= ADC12RES_2; // 12-bit conversion results
ADC12IER0 |= ADC12IE0; // Enable ADC conv complete interrupt
ADC12MCTL0 |= ADC12INCH_13 | ADC12VRSEL_1; // A1 ADC input select; Vref=2.5V
ADC12MCTL0 &=~ADC12DIF;
while(!(REFCTL0 & REFGENRDY)); // Wait for reference generator
// to settle
ADC12CTL0 |= ADC12ENC ;
while(1)

{
__delay_cycles(5000); // Delay between conversions
ADC12CTL0 |= ADC12SC; // Sampling and conversion start

__bis_SR_register(LPM0_bits + GIE); // LPM0, ADC10_ISR will force exit
V_BAT=(float)ADC_BAT*2.5/4096;


__no_operation(); // For debug only
}

中断部分:

switch (__even_in_range(ADC12IV, ADC12IV_ADC12RDYIFG))
{

case ADC12IV_ADC12IFG0: // Vector 12: ADC12MEM0 Interrupt
ADC_BAT=ADC12MEM0;
__bic_SR_register_on_exit(LPM0_bits); // Exit active CPU
break; // Clear CPUOFF bit from 0(SR)

}

中断都能进入。


Viewing all articles
Browse latest Browse all 3634

Trending Articles