RT,我最近在用MSP430FR5959这个芯片做一个多通道的单次转换测试,设定了四个采样通道A0~A3,经过实际测试的时候发现,通道A0、A1、A2、A3的采样结果均比较稳定,与实际电压值之间存在几个毫伏的抖动(后来发现抖动来源于地线端的漂移电压),但是通道A1的采样结果却与实际值之间存在数十个毫伏的偏差,最大的时候这个偏差达到了70mV,目前检查代码已有一周,一直未能发现问题,所以到论坛里面求助各位。底下是我的部分代码:
WDTCTL = WDTPW | WDTHOLD;
PM5CTL0 &= ~LOCKLPM5;
P1SEL0 |=BIT0+BIT1+BIT2+BIT3;
P1SEL1 |=BIT0+BIT1+BIT2+BIT3;
ADC12CTL0 |=ADC12SHT0_2 | ADC12ON | ADC12MSC;
ADC12CTL1 |=ADC12SHP |ADC12CONSEQ_1;
ADC12CTL2 |=ADC12RES_2;
ADC12MCTL0 |=ADC12INCH_0 | ADC12VRSEL_1;
ADC12MCTL1 |=ADC12INCH_1 | ADC12VRSEL_1;
ADC12MCTL2 |=ADC12INCH_2 | ADC12VRSEL_1;
ADC12MCTL3 |=ADC12INCH_3 | ADC12VRSEL_1 | ADC12EOS;
while(REFCTL0 & REFGENBUSY);
REFCTL0 |= REFVSEL_2 | REFON;
while(!(REFCTL0 & REFGENRDY));
ADC12IER0 |=ADC12IE0;
UART_Init();
while (1)
{
int i,j;
__delay_cycles(5000);
ADC12CTL0 |=ADC12ENC|ADC12SC;
__bis_SR_register(LPM0_bits | GIE);
UART_SendString(buf3);
delay_ms(120);
}
}
#pragma vector=ADC12_VECTOR
__interrupt void ADC_ISR(void)
{
temp[0]=ADC12MEM0;
temp[1]=ADC12MEM1;
temp[2]=ADC12MEM2;
temp[3]=ADC12MEM3;
ADC12CTL0 &=~ADC12ENC;
__bic_SR_register_on_exit(LPM0_bits);
}