TI中文支持网
TI专业的中文技术问题搜集分享网站

MSP430I2040: 关于ADC的问题

Part Number:MSP430I2040

ADC在管脚不给电压的情况下依然能采到数据 大概是满量程的一半 使用的是内部参考电压 结果如图

代码如下:

#include "msp430.h"

/* Array to store SD24 conversion results */
volatile int j, index = 0;
volatile unsigned long sum = 0;
unsigned long results[100];                     // Final results from running average

/* Defines */
#define SW_OVER_SAMPLING_FACTOR                 16

/* Main Function */
void main(void) {
    WDTCTL = WDTPW | WDTHOLD;                   // Stop WDT

    SD24CTL = SD24REFS;                         // Internal ref
    SD24INCTL0 = SD24GAIN_1;                    // Set gain on Channel 0
    SD24CCTL0 |=  SD24IE;                        // Enable interrupt, OSR = 256 (default)

    __delay_cycles(3200);                       // Delay ~200us for 1.2V ref to settle

    SD24CCTL0 |= SD24SC;                        // Set bit to start conversion
    __bis_SR_register(GIE);                     // Enable interrupts

    while(1) {                                  // Loop endlessly, SET BREAKPOINT or PAUSE HERE
    }
}

#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=SD24_VECTOR
__interrupt void SD24_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(SD24_VECTOR))) SD24_ISR (void)
#else
#error Compiler not supported!
#endif
{
    long temp = 0;
    switch (__even_in_range(SD24IV,SD24IV_SD24MEM3)) {
        case SD24IV_NONE: break;
        case SD24IV_SD24OVIFG: break;
        case SD24IV_SD24MEM0:

            // Capture ADC data
            SD24CCTL0 &= ~SD24LSBACC;           // Clear LSBACC bit
            temp = SD24MEM0;                    // Read upper 16 bits of SD24MEM0
            SD24CCTL0 |= SD24LSBACC;            // Set LSBACC bit
            temp = temp*256 + (SD24MEM0&0xff);  // Read lower 16 bits of SD24MEM0, combine with upper bits
            // Perform software oversampling
            sum+= temp;                         // Add result to running sum

            j++;
            if(j >= SW_OVER_SAMPLING_FACTOR) {  // Calculate and store average
                results[index++] = sum/SW_OVER_SAMPLING_FACTOR;
                sum = 0;
                j = 0;
            }

            if(index >=100) {
                index=0;
            }
            break;
        case SD24IV_SD24MEM1: break;
        case SD24IV_SD24MEM2: break;
        case SD24IV_SD24MEM3: break;
        default: break;
    }
}

Ben Qin:

你好,应该是由于管脚悬空,所以它的数值是不确定的,所以会有值。

,

SY L:

但是在给管脚电压时 例如0.2V ADC测量得到的结果就是0.8V左右 实际测量值也会比预期值大出一半的量程

,

Ben Qin:

试过TI的例程吗?排除下硬件问题。

赞(0)
未经允许不得转载:TI中文支持网 » MSP430I2040: 关于ADC的问题
分享到: 更多 (0)