This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

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

Other Parts Discussed in Thread: MSP430FR5972

用的是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)

}

中断都能进入。

  • 另外问个复用IO配置问题:

    我想配置MSP430FR5系列P9.5为AD口,用
    P9SEL1 |= BIT5 ; // Configure P9.5 for ADC
    P9SEL0 |= BIT5 ;
    这两条语句是否就够了?
    在数据手册中 第六章11节【6.11.22.11 Port P9 (P9.4 to P9.7) Input/Output With Schmitt Trigger 】,关于P9口的用法 有个表 6-30. Port P9 (P9.4 to P9.7) Pin Functions,
    即使P9SEL1和P9SEL0配置成11了,还有C13功能呢,不冲突吗?
    表下面的(2)、(3)说明更有的懵逼了,Setting P9SEL1.x and P9SEL0.x  去禁止数字口,Setting the CEPD.x  也禁止数字口。不知道如何操作了。
  • 1,建议不用低功耗模式。调试模式下,转换完成中断直接看寄存器的值;

    2,可以调整下SAMPLE AND HOLD的时间 

    关于你说的,C13和A13是如何内部区分, 用户手册里面确实不清楚。我确认下回复。