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.

28035之AD采样问题



interrupt void adc_isr(void)
{
unsigned int tmp = 0;
g_DCVotageSample[ConversionCount] = AdcResult.ADCRESULT1;
g_MotorCurrentSample[ConversionCount] = AdcResult.ADCRESULT0;
if(ConversionCount == 9)
{ //存10个数据
ConversionCount = 0; //在这里设置断点,查看变量的值
g_MotorCurrent.ValueNew = VavrCalculate(g_MotorCurrentSample,10);
DataFilter(&g_MotorCurrent);

g_DCVotage.ValueNew = VavrCalculate(g_DCVotageSample,10);
tmp = g_DCVotage.ValueNew*10;
g_DCVotage.ValueNew = tmp/41;
DataFilter(&g_DCVotage);
if(g_DCVotage.ValueNew>370)
{
//过压则开通制动电阻
RCONEnable;
}
else
{
RCONDisable;
}
}
else
{
ConversionCount++;
}
AdcRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //清除中断标志
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
}

ConversionCount = 0;
//配置AD通道和采样时钟
EALLOW;
AdcRegs.ADCCTL1.bit.INTPULSEPOS = 1;
AdcRegs.INTSEL1N2.bit.INT1E = 1; //使能ADCINT1
AdcRegs.INTSEL1N2.bit.INT1CONT = 0; //禁止连续转换模式
AdcRegs.INTSEL1N2.bit.INT1SEL = 1;
AdcRegs.ADCSOC0CTL.bit.CHSEL = 9; //SOC0使用 ADCINB1
AdcRegs.ADCSOC1CTL.bit.CHSEL = 8; //SOC1使用 ADCINB0
AdcRegs.ADCSOC0CTL.bit.TRIGSEL = 5; //设置SOC0触发->EPWM1A
AdcRegs.ADCSOC1CTL.bit.TRIGSEL = 5; //设置SOC1触发->EPWM1A
AdcRegs.ADCSOC0CTL.bit.ACQPS = 9; //设置采样时间为10个ADC时钟
AdcRegs.ADCSOC1CTL.bit.ACQPS = 9; //设置采样时间为10个ADC时钟
EDIS;

上面是我的部分程序和AD配置,我想把g_DCVotageSample[ConversionCount] ;g_MotorCurrentSample[ConversionCount] ;改为16个数据的数组,即if(ConversionCount == 15)
{ //存16个数据
ConversionCount = 0; //在这里设置断点,查看变量的值……………

是不是还要更改AD配置:AdcRegs.ADCSOC0CTL.bit.ACQPS = 15; //设置采样时间为16个ADC时钟
AdcRegs.ADCSOC1CTL.bit.ACQPS = 15; //设置采样时间为16个ADC时钟

但是,看数据手册发现,10h,11h,12h,13h,14h,1Dh,1Eh,1Fh……等是无效配置数据,我想问:我上面的想法(还要更改AD配置)对吗?这个15应该是有效配置数据吧?