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, MSP430FR5969, REF3312

芯片:MSP430FR6972

问题描述:

我使用的是ADC+TIM的采样方式,采样间隔约1ms,每次开启采样时,最开始的数据一直不准(大约有80多个不准点,之后就好了),所以请教一下这是什么原因呢?

/* 采样定时器配置 */

void TimerA1_Init(void)
{
TA1CCTL0 = CCIE;
TA1CCR0 = 32; /* 0.9-1ms */
TA1CTL = TASSEL__ACLK | MC__UP; /* ACLK, UP mode */
}

/* ADC配置 */

void MSP_ADC_Config(void)
{
/* 打开相应电源 */
PowerSwitch(VDD_ADC,ENABLE);
PowerSwitch(ADC_BAT,ENABLE);

/* 开启内部参考,Vref=2.5V */
while(REFCTL0 & REFGENBUSY);
REFCTL0 |= REFVSEL_2 | REFON;

/* 开启ADC并设置采样时间 */
ADC12CTL0 = ADC12ON | ADC12SHT0_2 | ADC12MSC;
/* ADC12SC触发采样,序列通道采样, SMCLK/4 */
ADC12CTL1 = ADC12SHP |ADC12SHS_0 | ADC12CONSEQ_1 | ADC12SSEL_3 | ADC12PDIV_1;
/* ADC通道配置: ADC_I->CH0, ADC_BAT->CH13 */
ADC12MCTL0 = ADC12VRSEL_1 | ADC12INCH_0;
ADC12MCTL1 = ADC12VRSEL_1 | ADC12INCH_13 | ADC12EOS;
ADC12IER0 = ADC12IE1;

/* Wait for reference generator to settle */
while(!(REFCTL0 & REFGENRDY));
ADC12CTL0 |= ADC12ENC;
TimerA1_Init();
}

#pragma vector=TIMER1_A0_VECTOR
__interrupt void Timer1_A0_ISR(void)
{
ADC12CTL0 |= ADC12SC;
}

#pragma vector=ADC12_VECTOR
__interrupt void MSP_ADC_ISR(void)
{
if(ADC12IV & ADC12IV_ADC12IFG1)
{
Device_Status.Cur_Sampval[Device_Status.Sample_Num++]=ADC12MEM0;
Device_Status.Status_Info.Bat_Vol_B=ADC12MEM1;
/*
这里预留电池低电压处理程序
*/
if(Device_Status.Sample_Num == 20)
{
Device_Status.Full_Buff_Node=0;
Indicator_Task.Handle_Count += 1;
Indicator_Task.Cur_Handle_Flag=1;
#if USE_LP
LPM3_EXIT;
#endif
}
else if(Device_Status.Sample_Num >= 40)
{
Device_Status.Sample_Num=0;
Device_Status.Full_Buff_Node=1;
Indicator_Task.Handle_Count += 1;
Indicator_Task.Cur_Handle_Flag=1;
#if USE_LP
LPM3_EXIT;
#endif
}
}
ADC12IV=0;
}