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.

TMS320F28379D: EPWM ADC Event Trigger Prescale producing "glitch" triggers

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 

  • Mark,

    Can you try C2000 Academy ePWM lab exercise? This does exactly what you are trying to do. Can you please try and let me know if you can still reproduce the issue?

    https://dev.ti.com/tirex/explore/node?node=A__Adlf59dR9TRikXjOlRRRsg__c2000Academy__jEBbtmC__LATEST

    First let's try with original code, so the ePWM is at 2 kHz. Let me know see the issue. Then you can change to the frequency you are trying for your application. I am working remotely this week due to holiday break and do not have F28379D-LAUNCHXL with me.

    Regards, Santosh

  • Thanks.  From a quick test with the lab code, I'm still seeing a few of these glitches.  In the case where the SOCA Trigger Event Count = 1 (where the only modification to the lab project is to add toggling of GPIO14 in the ADC ISR), I see this glitch again.   It seems to be aligned with the ePWM1 switching to high, but it is not every time ePWM1 switches:

    If I change the SOCA Trigger Event Count to 8, 

    Again, the glitch seems to be aligned with EPWM1A going high.  If I look at the rest of the capture, it *only* occurs when GPIO14 toggles low just before EPWM1A switches high.  

  • FYI...I modified ePWM2 so that a waveform is output on the "A" pin.  It goes high on ZERO and low on CMPA.

    You can see in the capture below that the "glitch" is not close to the EPWM2A events.  The glitch is also about 4ns wide.

  • Mark,

    I will look into this today, and try to reproduce the issue with Academy lab code and get back to you. Most of the subject matter experts are out of office due to holiday break. so response may be delayed.

    Regards, Santosh

  • Thanks.  I'm starting to think this may be more of a GPIO issue.  Before, I would only call GPIO_togglePin(14) once near the start of adcA1ISR().  I tried an experiment where I also add a second GPIO_togglePin(14) at the end of adcA1ISR().  So that the output is a pulse while the ISR is executing.  I have only run this a couple of times, but so far I'm not seeing the glitch.

  • Mark,

    Just checking if you made further progress in issue?

    Regards, Santosh

  • Not yet.  I do want to try a different measurement tool.  Perhaps the logic analyzer is reacting to noise.  It may be a day or two before I can try another tool.