在调试msp430f5325的ADC12模块,采用的是顺序通道单次采样、ADC12时钟源为SMCLK(10M)3分频,定时器B的OUT1触发采样,采样定时器的采样保持时间设置为ADC12SHT0_4和ADC12SHT1_4,中断方式,发现每次采样的结果波动比较大,请问高手大概是什么原因?
ADC程序如下:
void AdcInit(void)
{
P5SEL |= BIT0+BIT1; // 开启P5.0--Veref+、Veref-功能
P6SEL |= BIT0+BIT1+BIT2+BIT3+BIT4+BIT5+BIT6;
//A0、A1、A2、A3、A4、A5、A6 ADC功能使能
P7SEL |= BIT0+BIT2+BIT3; //A12、A14、A15 ADC功能使能
ADC12CTL0 &= ~ADC12ENC; //ADC12转换禁止,更主要的是为了保证某些位
//的初始化正确,部分位只有在该位为0时,才可初始化
ADC12CTL0 |=ADC12SHT0_4+ADC12SHT1_4+ADC12ON+ADC12MSC;
ADC12CTL1 |= ADC12CSTARTADD_0+ADC12SHS_3+ADC12SHP+ADC12DIV_2;
ADC12CTL1 |= ADC12SSEL_3+ADC12CONSEQ_1;
ADC12CTL1 &= ~ADC12ISSH; //采样保持触发信号同相位
//ADC12CTL2 |= ADC12TCOFF+ADC12RES_2;
ADC12MCTL0 |= ADC12SREF_2+ADC12INCH_0;//选择基准电压为 VeREF+和AVSS、通道0*/
ADC12MCTL1 |= ADC12SREF_2+ADC12INCH_1;//选择基准电压为 VeREF+和AVSS、通道1
ADC12MCTL2 |= ADC12SREF_2+ADC12INCH_2;//选择基准电压为 VeREF+和AVSS、通道2
ADC12MCTL3 |= ADC12SREF_2+ADC12INCH_3;//选择基准电压为 VeREF+和AVSS、通道3
ADC12MCTL4 |= ADC12SREF_2+ADC12INCH_4;//选择基准电压为 VeREF+和AVSS、通道4
ADC12MCTL5 |= ADC12SREF_2+ADC12INCH_5;//选择基准电压为 VeREF+和AVSS、通道5
ADC12MCTL6 |= ADC12SREF_2+ADC12INCH_6;//选择基准电压为 VeREF+和AVSS、通道6
ADC12MCTL7 |= ADC12SREF_2+ADC12INCH_12;//选择基准电压为 VeREF+和AVSS、通道12
ADC12MCTL8 |= ADC12SREF_2+ADC12INCH_14;//选择基准电压为 VeREF+和AVSS、通道14
ADC12MCTL9 |= ADC12SREF_2+ADC12INCH_15+ADC12EOS;
ADC12IE |= ADC12IE9; // Enable ADC12IFG7 interrupt
ADC12CTL0 |=ADC12ENC; // Start sampling/conversion
}
#pragma vector=ADC12_VECTOR
__interrupt void ADC12ISR (void)
{
ADC12_results[0]=ADC12MEM0;
ADC12_results[1]=ADC12MEM1;
ADC12_results[2]=ADC12MEM2;
ADC12_results[3]=ADC12MEM3;
ADC12_results[4]=ADC12MEM4;
ADC12_results[5]=ADC12MEM5;
ADC12_results[6]=ADC12MEM6;
ADC12_results[7]=ADC12MEM7;
ADC12_results[8]=ADC12MEM8;
ADC12_results[9]=ADC12MEM9;
ADC12CTL0 |= ADC12SC; // Start sampling/conversion
}
每次采样的结果波动比较大,有多大。把一串连续的采样结果发出来, 用示波器采集同一时段的波形。比较一下。
建议先确定是不是电压不稳,先以一个固定电压采样,看看波动大不大,确定唯一变量对结果的影响