Part Number: TMS320F28379D
I am trying to use the EPWM adc trigger event prescale feature.
I configure EPWM1A for 200kHz, and have it triggering an ADC conversion with SOCA.
For testing, I am toggling GPIO14 every time the ADC ISR runs. If I set prescale to "2", I see a glitch double-toggle. If I use other prescale settings, "10" for example, I see the same glitch, but only once. I have the waveforms captured below.
It seems like configuration for this is fairly simple, and I'm reusing the ADC ISR from another example project from TI. Do I need to do something in the ISR to handle the case where prescale is used?
Setup of the ePWM:
EPWM_setPeriodLoadMode(EPWM1_BASE, EPWM_PERIOD_DIRECT_LOAD);
EPWM_setTimeBasePeriod(EPWM1_BASE, PWM_CLK / 200000);
EPWM_setTimeBaseCounter(EPWM1_BASE, 0U);
EPWM_setTimeBaseCounterMode(EPWM1_BASE, EPWM_COUNTER_MODE_UP);
EPWM_setClockPrescaler(EPWM1_BASE, EPWM_CLOCK_DIVIDER_1,
EPWM_HSCLOCK_DIVIDER_1);
EPWM_setADCTriggerSource(EPWM1_BASE, EPWM_SOC_A, EPWM_SOC_TBCTR_ZERO);
EPWM_setADCTriggerEventPrescale(EPWM1_BASE, EPWM_SOC_A, 2); // <-- I've tried other values, same behavior
EPWM_enableADCTrigger(EPWM1_BASE, EPWM_SOC_A);
EPWM_clearADCTriggerFlag(EPWM1_BASE, EPWM_SOC_A);
Setup of the ADC:
ADC_setupSOC(ADCC_BASE, ADC_SOC_NUMBER1, ADC_TRIGGER_EPWM1_SOCA, ADC_CH_ADCIN4, 15);
ADC_setInterruptSource(ADCC_BASE, ADC_INT_NUMBER1, ADC_SOC_NUMBER1);
// ADC_enableContinuousMode(ADCC_BASE, ADC_INT_NUMBER1); // <-- I've tried with and without, same behavior
ADC_clearInterruptStatus(ADCC_BASE, ADC_INT_NUMBER1);
ADC_enableInterrupt(ADCC_BASE, ADC_INT_NUMBER1);
ADC ISR:
ADC_clearInterruptStatus(ADCC_BASE, ADC_INT_NUMBER1);
GPIO_togglePin(14);
if(true == ADC_getInterruptOverflowStatus(ADCC_BASE, ADC_INT_NUMBER1))
{
ADC_clearInterruptOverflowStatus(ADCC_BASE, ADC_INT_NUMBER1);
ADC_clearInterruptStatus(ADCC_BASE, ADC_INT_NUMBER1);
}
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1);
Note that I also have CPU Timer 0 also generating periodic interrupts. It's ISR also calls Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1);
Waveform capture with prescale=2:

Waveform capture with prescale = 10:

The glitch only happens after every second legitimate toggle, and includes two toggles (so the ISR seems to be called twice)
This is using the LaunchpadXL-28379D


