我用28335的内置A/D采样5路信号,采样顺序采样的方式,连续采样模式,相关配置程序如下所示,但是在线调试的时候从变量观测器里发现大部分时候A/D转换值波动范围都很小,但是偶尔会出现偏差较大的野值点,请问我该如何解决这个问题?
void ConfigADC(void)
{
InitAdc();
EALLOW;
SysCtrlRegs.HISPCP.all = ADC_MODCLK;//25MHz
EDIS;
AdcRegs.ADCTRL1.bit.ACQ_PS = 0x0;//pulse width: ACQ_PS+1 ADCLK cycle
AdcRegs.ADCTRL1.bit.CPS = 0; //0:bufenpin, 1:erfenpin
AdcRegs.ADCTRL3.bit.ADCCLKPS = 0x0;//frequency dividing coefficients:2*ADCCLKPS,0:No frequency division
AdcRegs.ADCTRL3.bit.SMODE_SEL = 0;//sequential sampling
AdcRegs.ADCMAXCONV.bit.MAX_CONV1 = 4;//number of conversion channel: 4+1
AdcRegs.ADCTRL1.bit.SEQ_CASC = 1;//cascade mode
AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0x0;
AdcRegs.ADCCHSELSEQ1.bit.CONV01 = 0x1;
AdcRegs.ADCCHSELSEQ1.bit.CONV02 = 0x2;
AdcRegs.ADCCHSELSEQ1.bit.CONV03 = 0x3;
AdcRegs.ADCCHSELSEQ2.bit.CONV04 = 0x4;
AdcRegs.ADCTRL1.bit.CONT_RUN = 1;//continuous operation mode
}
void ReadADC_Results(void)
{
while(AdcRegs.ADCST.bit.INT_SEQ1 == 0); //Wait for the end of conversion
AdcRegs.ADCST.bit.INT_SEQ1_CLR = 1; //clear interrupt flag
Vpv = AdcRegs.ADCRESULT0>>4;
Vc1 = AdcRegs.ADCRESULT1>>4;
Vc2 = AdcRegs.ADCRESULT2>>4;
Ig = AdcRegs.ADCRESULT3>>4;
Vg = AdcRegs.ADCRESULT4>>4;
}
Green Deng:建议先用例程测试一下,排除软件方面的因素。例程位置:
C:\ti\controlSUITE\device_support\f2833x\v142\DSP2833x_examples_ccsv5\adc_soc
我用28335的内置A/D采样5路信号,采样顺序采样的方式,连续采样模式,相关配置程序如下所示,但是在线调试的时候从变量观测器里发现大部分时候A/D转换值波动范围都很小,但是偶尔会出现偏差较大的野值点,请问我该如何解决这个问题?
void ConfigADC(void)
{
InitAdc();
EALLOW;
SysCtrlRegs.HISPCP.all = ADC_MODCLK;//25MHz
EDIS;
AdcRegs.ADCTRL1.bit.ACQ_PS = 0x0;//pulse width: ACQ_PS+1 ADCLK cycle
AdcRegs.ADCTRL1.bit.CPS = 0; //0:bufenpin, 1:erfenpin
AdcRegs.ADCTRL3.bit.ADCCLKPS = 0x0;//frequency dividing coefficients:2*ADCCLKPS,0:No frequency division
AdcRegs.ADCTRL3.bit.SMODE_SEL = 0;//sequential sampling
AdcRegs.ADCMAXCONV.bit.MAX_CONV1 = 4;//number of conversion channel: 4+1
AdcRegs.ADCTRL1.bit.SEQ_CASC = 1;//cascade mode
AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0x0;
AdcRegs.ADCCHSELSEQ1.bit.CONV01 = 0x1;
AdcRegs.ADCCHSELSEQ1.bit.CONV02 = 0x2;
AdcRegs.ADCCHSELSEQ1.bit.CONV03 = 0x3;
AdcRegs.ADCCHSELSEQ2.bit.CONV04 = 0x4;
AdcRegs.ADCTRL1.bit.CONT_RUN = 1;//continuous operation mode
}
void ReadADC_Results(void)
{
while(AdcRegs.ADCST.bit.INT_SEQ1 == 0); //Wait for the end of conversion
AdcRegs.ADCST.bit.INT_SEQ1_CLR = 1; //clear interrupt flag
Vpv = AdcRegs.ADCRESULT0>>4;
Vc1 = AdcRegs.ADCRESULT1>>4;
Vc2 = AdcRegs.ADCRESULT2>>4;
Ig = AdcRegs.ADCRESULT3>>4;
Vg = AdcRegs.ADCRESULT4>>4;
}
user5994389:
回复 Green Deng:
我设置的采样率是DSP所允许的最高的采样率,请问降低采样率是否可以缓解这个问题?
我用28335的内置A/D采样5路信号,采样顺序采样的方式,连续采样模式,相关配置程序如下所示,但是在线调试的时候从变量观测器里发现大部分时候A/D转换值波动范围都很小,但是偶尔会出现偏差较大的野值点,请问我该如何解决这个问题?
void ConfigADC(void)
{
InitAdc();
EALLOW;
SysCtrlRegs.HISPCP.all = ADC_MODCLK;//25MHz
EDIS;
AdcRegs.ADCTRL1.bit.ACQ_PS = 0x0;//pulse width: ACQ_PS+1 ADCLK cycle
AdcRegs.ADCTRL1.bit.CPS = 0; //0:bufenpin, 1:erfenpin
AdcRegs.ADCTRL3.bit.ADCCLKPS = 0x0;//frequency dividing coefficients:2*ADCCLKPS,0:No frequency division
AdcRegs.ADCTRL3.bit.SMODE_SEL = 0;//sequential sampling
AdcRegs.ADCMAXCONV.bit.MAX_CONV1 = 4;//number of conversion channel: 4+1
AdcRegs.ADCTRL1.bit.SEQ_CASC = 1;//cascade mode
AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0x0;
AdcRegs.ADCCHSELSEQ1.bit.CONV01 = 0x1;
AdcRegs.ADCCHSELSEQ1.bit.CONV02 = 0x2;
AdcRegs.ADCCHSELSEQ1.bit.CONV03 = 0x3;
AdcRegs.ADCCHSELSEQ2.bit.CONV04 = 0x4;
AdcRegs.ADCTRL1.bit.CONT_RUN = 1;//continuous operation mode
}
void ReadADC_Results(void)
{
while(AdcRegs.ADCST.bit.INT_SEQ1 == 0); //Wait for the end of conversion
AdcRegs.ADCST.bit.INT_SEQ1_CLR = 1; //clear interrupt flag
Vpv = AdcRegs.ADCRESULT0>>4;
Vc1 = AdcRegs.ADCRESULT1>>4;
Vc2 = AdcRegs.ADCRESULT2>>4;
Ig = AdcRegs.ADCRESULT3>>4;
Vg = AdcRegs.ADCRESULT4>>4;
}
Green Deng:
回复 user5994389:
按照你目前的描述我没办法判断具体问题出在哪里。这类采样问题,软硬件都有可能有关,所以先建议你用例程测试一下,方便排除问题。你也可以直接将你的操作执行一下看看效果如何,这样最直观。