工程师:
你好,我在使用ADC多通道采集时遇到的问题,首先,我使用的ADC 4通道10位采集(A3,A2,A1,A0),采用内部基准电压2.5v,利用DMA取出ADC转换数据。我的问题是,在A3电压为0时,为什么采集的AD转换值 为110.理论上应该是0,才对,不知道问题出在什么地方,请给出帮助。谢谢
//******************************************************************************
#include <msp430.h>
unsigned int ADC_Result[4];
int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // Stop WDT
// Configure ADC10
ADC10CTL0 = ADC10SHT_2 | ADC10MSC | ADC10ON;// 16ADCclks, MSC, ADC ON
ADC10CTL1 = ADC10SHP | ADC10CONSEQ_1; // sampling timer, s/w trig.,single sequence
ADC10CTL2 |= ADC10RES; // 10-bit resolution
ADC10MCTL0 = ADC10SREF_1 |ADC10INCH_3; // A0,A1,A2,A3(EoS), AVCC reference
while(REFCTL0 & REFGENBUSY); // If ref generator busy, WAIT REFCTL0 |= REFVSEL_2|REFON; // Select internal ref = 2.5V // Configure DMA0 (ADC10IFG trigger)
DMACTL0 = DMA0TSEL_24; // ADC10IFG trigger
__data16_write_addr((unsigned short) &DMA0SA,(unsigned long) &ADC10MEM0);
// Source single address __data16_write_addr((unsigned short) &DMA0DA,(unsigned long) &ADC_Result[0]);
// Destination array address DMA0SZ = 0x04; // 4 conversions DMA0CTL = DMADT_4 | DMADSTINCR_3 | DMAEN | DMAIE; // Rpt, inc dest, byte access, // enable int after seq of convs while(1)
{
while (ADC10CTL1 & ADC10BUSY); // Wait if ADC10 core is active
ADC10CTL0 |= ADC10ENC | ADC10SC; // Sampling and conversion start
__bis_SR_register(CPUOFF | GIE); // LPM0, ADC10_ISR will force exit
__delay_cycles(5000); // Delay between sequence convs __no_operation(); // BREAKPOINT; check ADC_Result
}
}
#pragma vector=DMA_VECTOR
__interrupt void DMA0_ISR (void)
{
switch(__even_in_range(DMAIV,16))
{
case 0: break; // No interrupt
case 2: // sequence of conversions complete
__bic_SR_register_on_exit(CPUOFF); // exit LPM
break; // DMA0IFG
case 4: break; // DMA1IFG
case 6: break; // DMA2IFG
case 8: break; // Reserved
case 10: break; // Reserved
case 12: break; // Reserved
case 14: break; // Reserved
case 16: break; // Reserved
default: break; } }
Maka Luo:
ADC10CTL0 = ADC10SHT_2 | ADC10MSC | ADC10ON;// 16ADCclks, MSC, ADC ON
把采样保持时间设置长一点试试,从代码来看没有什么配置错误的问题。
另外你是否只有A3通道采样有问题,其它通道呢?