两个EPWM信号 分别是80KHZ 10KHZ
EPWM2 10KHZ确发 中断1
EPWM3 80KHZ确发 ADC转换中断2
时序大约是这样的先ADC转换64次以后
然后关断EPWM3触法源(即ADC触发源)
进入MAIN函数主循环,结束后,打开EPWM2(10KHZ触发源),
进入10KHZ触发源,打开EPWM3触发源 (即ADC触发源)
关断EPWM2触法源 再进入ADC中断
这样的结果应该是每次EPWM2先触发再启动ADC转换,因EPWM2触发是固定的相位,所以ADC转换的相位应该是固定的,但结果是ADC是在8个采样点中的任一一个做第一个点,结果就是相位相差360/8=45度
目的是即先启动一个标志位,可以让ADC转换的相位和10KHZ的相位相同,但是每次都是取8个点的任意一个点做第一个取样点,这是什么原因,请教大神指点一下
interrupt void adc_isr(void)
{
Voltage2[ConversionCount] = AdcResult.ADCRESULT1;
Voltage1[ConversionCount] = AdcResult.ADCRESULT0;
Voltage3[ConversionCount] = AdcResult.ADCRESULT2;
// real FFT bit reversing
// If 20 conversions have been logged, start over
if(ConversionCount == 63)
{
FFT_Key=1;
AdcRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;
EPwm3Regs.ETSEL.bit.SOCAEN = 0;
ConversionCount = 0;
}
else
{
ConversionCount++;
}
AdcRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //Clear ADCINT1 flag reinitialize for next SOC
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1; // Acknowledge interrupt to PIE
return;
}
interrupt void epwm2_isr(void)
{
// Clear INT flag for this timer
EPwm2Regs.ETSEL.bit.INTEN = 0;
EPwm3Regs.ETSEL.bit.SOCAEN = 1; //ADC使能
AdcRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //Clear ADCINT1 flag reinitialize for next SOC
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
// Acknowledge this interrupt to receive more interrupts from group 3
EPwm2Regs.ETCLR.bit.INT=1;
PieCtrlRegs.PIEACK.all = PIEACK_GROUP3;
}