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.

MSP430F2132的模拟量采集



各位大侠,请帮着看看这个程序段,怎么模拟量采集就出了问题呢?

要求对AD7通道进行数据采集,采用2.5V基准电压

----------------------------------------

管脚初始化部分

----------------------------------------

    P1SEL=0;
    P1DIR&=~0x0C;
    P2DIR|=BIT3;    // P2.3输出模式
    P3SEL |=0X80;  //P3功能选择寄存器,0为通用GPIO,1为外围模块功能,P3.7为AD输入
    P3DIR |=0x01b;//P3方向寄存器=0输入;=1输出
    P3OUT &=0X0F; //将SPI接口外的管脚均置为0

------------------------------------------------------------------

模拟初始化和采集程序部分

void adc_init(void)
{
  ADC10CTL0 =SREF_2+ ADC10SHT_2 + REFON+ ADC10ON + ADC10IE+REF2_5V; //ADC10ON,   中断使能,  2.5V基准电压
  ADC10CTL1 =INCH_7;//选择采样通道为AD.7  P3.7
  //SREF_2  模拟量ADC10采样参考电平选择
  //ADC10SHT_2          (2*0x800u)   /* 16 x ADC10CLKs */
  //REFON                                 打开内部参考电压发生器
  //ADC10ON             (0x010)      /*.4  ADC10 内核使能 =0,关闭内核,=1打开内核          ADC10 On/Enable */
  //ADC10IE             (0x008)      /*.3  ADC10 中断使能=0,中断禁止;=1允许        ADC10 Interrupt Enalbe */
  //REF2_5V             (0x040)      /*.6  ADC10 基准电压值选择位:=0为1.5V,=1为2.5V    ADC10 Ref 0:1.5V / 1:2.5V */
  ADC10AE0 |= 0x01;                          // 模拟输入使能,=0,禁止,=1使能
}

//---------------------------------
INT16U adc10_jiance(void)
{
  union WB_DATA   ADC116;
  unsigned int i;
  ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start
  __bis_SR_register(CPUOFF + GIE);     // LPM0, ADC10_ISR will force exit
  ADC116.ADATA=ADC10MEM;

  return ADC116.ADATA;//
}

--------------------------------------------------------------------------

ADC中断处理部分

//---------------------------------
// ADC10 interrupt service routine
#pragma vector=ADC10_VECTOR
__interrupt void ADC10_ISR(void)
{
 __bic_SR_register_on_exit(CPUOFF);
}

----------------------------------------------------------------------