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.

ADC12单次序列采集,第一次转换的数据不正确

Other Parts Discussed in Thread: MSP430FR6972

芯片型号:MSP430FR6972

问题:我想要的结果是一次转换信号,转换两个通道,然后不通过中断读取这两个值,但是每次完成转换后通道14的值都不准(为0xFFF,但这个值根据我的程序这个时候采的电压不应该是这个值,我量过),后来我加了一个for循环,发现下一次采集到的数据是对的,连试几次也是这样。根本就不是我预想的。是我哪里理解错了吗?

相关代码:

static void For_Real_Sample(void)
{
 ADC_CAP_BAT_Init();
 while(REFCTL0 & REFGENBUSY);                 // If ref generator busy, WAIT
 REFCTL0 |= REFVSEL_2 | REFON;                // Select internal ref = 2.5V
              // Internal Reference ON
 ADC12CTL0 &= ~ADC12ENC;
 
 ADC12CTL0 = ADC12ON | ADC12SHT0_4 | ADC12MSC;       // Turn on ADC12, set sampling time 64 ADC12CLK,采样保持时间尽量长
 ADC12CTL1 = ADC12SHP |ADC12SHS_0 | ADC12CONSEQ_1 | ADC12SSEL_3 | ADC12PDIV_1; // ADC12SC触发采样,序列通道采样 0-1,SMCLK/4
 ADC12CTL3 = ADC12CSTARTADD2;
 
 ADC12MCTL2 = ADC12INCH_12 | ADC12VRSEL_1;     //ADC_CAP
 ADC12MCTL3 = ADC12INCH_14 | ADC12VRSEL_1 | ADC12EOS; //ADC_BAT
 ADC12IER0 = 0;           //关闭中断
 while(!(REFCTL0 & REFGENRDY));                // Wait for reference generator
                  // to settle 
// ADC12CTL0 |= ADC12ENC;        
}

//读取转换的两个通道值

void Read_ADC(void)

{

  if((indicator->WorkStatus == LowPower))
  {
   For_Real_Sample();
   for(i=0; i<5; i++)
   {
   ADC12CTL0 |= ADC12ENC | ADC12SC;
   while(ADC12IFGR0 & ADC12IFG3 == 0);
   temp = ADC12MEM2;
//   temp_s = temp * 5000/4096; //单位mv
//   indicator->Voltage_Cap = temp_s;
   temp = ADC12MEM3;
//   temp_s = temp * 5000/4096; //单位mv
//   indicator->Voltage_Bat = temp_s;
   }
   ADC_CAP_BAT_DeInit();
   Stop_ADC();
  }

}