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.

MSP430G2553 ADC10多通道序列采样,结果不准,请指教~

Other Parts Discussed in Thread: MSP430G2553

我想要用MSP430G2553 的ADC10做双通道采样,使用的端口为P1.1,P1.4以下是我的代码:

 

unsigned int a[2];

void ADC10_Init_DoubleChannel(void)
{
  P1DIR &= ~(BIT1 + BIT4);
  ADC10CTL0 = ADC10SHT_2 + ADC10ON + ADC10IE + MSC; // 开启AD,并使能AD中断,采样保持时间为16个ADC时钟
  ADC10CTL1 = CONSEQ_1 + INCH_5; 
  ADC10DTC1=0X02;
  ADC10AE0 = BIT1 + BIT4 ;
}
void ADC10Converting()
{
    ADC10CTL0 &= ~ENC;
    while (ADC10CTL1 & BUSY);               // Wait if ADC10 core is active
    ADC10SA = (unsigned int)a;
    ADC10CTL0 |= ENC + ADC10SC;             // Sampling and conversion ready
    __no_operation();
}
// ADC10 interrupt service routine
#pragma vector=ADC10_VECTOR
__interrupt void ADC10_ISR (void)
{
  ADC_disp();
}

void ADC_disp(void)
{
    Current_disp = (unsigned int)( a[0] / 3.223 * REF_Curr_Disp);
    voltage_disp = (unsigned int)( a[1] / 16.1133 * REF_Voltage);
    
    if(voltage_disp >= 18000)
    {
      LCD_Display(0,0,OverVoltage);
      _NOP();
      LCD_Display(1,0,blank);
    }
    
    else
    {
      Disp_num1[12] = Current_disp%10+ '0';
      Disp_num1[11] = Current_disp/10%10+ '0';
      Disp_num1[10] = Current_disp/100%10+ '0';
      Disp_num1[9] = Current_disp/1000%10+ '0';
      
      
      Disp_num2[12] = voltage_disp%10 + '0';
      Disp_num2[11] = voltage_disp/10%10+ '0';
      Disp_num2[10] = voltage_disp/100%10+ '0';
      Disp_num2[9] = voltage_disp/1000%10+ '0';   
      _NOP();
      
      LCD_Display(0,0,Disp_num1);
      _NOP();
      LCD_Display(1,0,Disp_num2);
    }
}


结果测得的不准,a[0]和a[1]几乎都维持在一个固定值,大概是440和0左右。不知道有什么问题。。谢谢解答~

使用的是TI的launchpad板子,测试方法为飞线到VCC和GND,结果也不准,测试断点设置在AD中断中。

开发环境:IAR 5.50