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 using EXTSYNCOUT to generate sync from higher-numbered channel to lower-numbered channel

Part Number: TMS320F28379D

Hello,


I have an existing hardware design.  Lower-numbered EPWM channels are used and cannot be changed.  I would like to use a higher-numbered EPWM channel to generate a sync event.

My first idea is to

  • Configure EXTSYNCOUT to use EPWM7SYNCOUT
  • Configure Output XBAR to route EXTSYNCOUT to an unused GPIO
  • Connect the unused GPIO to a second unused GPIO
  • Configure Input XBAR to set the second unused GPIO to XBAR INPUT5
  • Use XBAR INPUT5 for EXTSYNCIN1 to EPWM1,2,3,4,5,6

Does this seem reasonable?

Is there a better method to do this?

I see that EXTSYNCOUT can be set as an input to the ePWM XBAR Mux 14.  

It seems like it may be possible to route EXTSYNCOUT to the ePWM DC to trigger a sync by using TBCTL[SWFSYNC], per TRM section 15.11.4.1, but I haven't worked out how to do this yet.   Are there any example projects available to that do this?

Thanks!

  • I am trying the second approach, using EXTSYNCOUT.

    What I am doing so far:

    All EPWMs configured for 10kHz, 50% duty.

    // Configure EPWM4 for sync out

    EPWM_setSyncOutPulseMode(EPWM4_BASE, EPWM_SYNC_OUT_PULSE_ON_COUNTER_ZERO);

    SysCtl_setSyncOutputConfig(SYSCTL_SYNC_OUT_SRC_EPWM4SYNCOUT);

    XBAR_setEPWMMuxConfig(XBAR_TRIP12, XBAR_EPWM_MUX14_EXTSYNCOUT);
    XBAR_enableEPWMMux(XBAR_TRIP12, XBAR_MUX14);

    // Configure EPWM1 DC submodule (I've also tried EPWM2 and EPWM3)

    EPWM_setCountModeAfterSync(EPWM1_BASE, EPWM_COUNT_MODE_UP_AFTER_SYNC);

    EPWM_enablePhaseShiftLoad(EPWM1_BASE);

    EPWM_selectDigitalCompareTripInput(EPWM1_BASE, EPWM_DC_TRIP_TRIPIN12, EPWM_DC_TYPE_DCAH);       // DCAHTRIPSEL

    EPWM_setDigitalCompareEventSource(EPWM1_BASE, EPWM_DC_MODULE_A, EPWM_DC_EVENT_1, EPWM_DC_EVENT_SOURCE_ORIG_SIGNAL);    // DCACTL.EVT1SRCSEL = 0

    EPWM_setDigitalCompareEventSyncMode(EPWM1_BASE, EPWM_DC_MODULE_A, EPWM_DC_EVENT_1, EPWM_DC_EVENT_INPUT_NOT_SYNCED); // DCACTL.EVTSYNCE = 1
    EPWM_enableDigitalCompareSyncEvent(EPWM1_BASE, EPWM_DC_MODULE_A);

    The key part of the TRM that leads me to believe this should work is:

    This configuration is not working / there is no sync between EPWM4 and EPWM1.  I would expect that there would be a constant offset between the two outputs, but there is large variation.

    Any suggestions on what else I need to do to get sync to work using EXTSYNCOUT from EPWM4 to trigger sync on EPWM1?

    Thanks!

  • Update:

    Adding

        EPWM_setTripZoneDigitalCompareEventCondition( EPWM1_BASE, EPWM_TZ_DC_OUTPUT_A1, EPWM_TZ_EVENT_DCXH_HIGH);


    Produces a more consistent offset between EPWM1 and EPWM4, so it seems sync is working.  However, with this config, I'm getting only every other pulse on EPWM1:

  • Hi Mark,
    Thanks for the detailed explanation

    Let me read through this thread and get back to you.

    Thanks

  • Thanks, Prarthan,

    I guess the basic question is: how do I connect EXTSYNCOUT to TRIP12 (for example), and then configure EPWM DC submodule to generate the software sync (SWFSYNC)?

    I am also now out-putting EXTSYNCOUT to XBAROUT3 so that I can see the sync signal in relation to the PWM waveforms.

    You can see in the capture below, I'm seeing EXTSYNCOUT  on XBAROUTPUT3 as expected, but EPWM1 is not working as expected. 

    TBPRD and CMPA are the same fore both EPWM1 and EPWM4.  TBPRD = 100*100 (100us), and CMPA = 100*50 (50us)

    I have EPWM4 configured as up-down count, and that it should only generate the pulse on TBCTR=ZERO

    EPWM_setTimeBaseCounterMode(EPWM4_BASE, EPWM_COUNTER_MODE_UP_DOWN);

    EPWM_setActionQualifierAction(EPWM4_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_HIGH, EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPA);
    EPWM_setActionQualifierAction(EPWM4_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_LOW, EPWM_AQ_OUTPUT_ON_TIMEBASE_DOWN_CMPA);

    EPWM_setSyncOutPulseMode(EPWM4_BASE, EPWM_SYNC_OUT_PULSE_ON_COUNTER_ZERO);

    The pulse in the middle of the Low part of the EPWM4 seems to be correct, and is where I would expect TBCTR=ZERO.   EPWM1 seems to be missing every second sync pulse.

    As mentioned in the original post, EXTSYNCOUT is configured as:

    SysCtl_setSyncOutputConfig(SYSCTL_SYNC_OUT_SRC_EPWM4SYNCOUT);

    XBAR_setEPWMMuxConfig(XBAR_TRIP12, XBAR_EPWM_MUX14_EXTSYNCOUT);
    XBAR_enableEPWMMux(XBAR_TRIP12, XBAR_MUX14);

    and then EPWM1 is configured as:

    EPWM_selectDigitalCompareTripInput(EPWM1_BASE, EPWM_DC_TRIP_TRIPIN12, EPWM_DC_TYPE_DCAH); // DCAHTRIPSEL
    EPWM_setTripZoneDigitalCompareEventCondition( EPWM1_BASE, EPWM_TZ_DC_OUTPUT_A1, EPWM_TZ_EVENT_DCXH_HIGH);
    EPWM_setDigitalCompareEventSource(EPWM1_BASE, EPWM_DC_MODULE_A, EPWM_DC_EVENT_1, EPWM_DC_EVENT_SOURCE_ORIG_SIGNAL); // DCACTL.EVT1SRCSEL = 0
    EPWM_setDigitalCompareEventSyncMode(EPWM1_BASE, EPWM_DC_MODULE_A, EPWM_DC_EVENT_1, EPWM_DC_EVENT_INPUT_NOT_SYNCED); // DCACTL.EVTSYNCE = 1
    EPWM_enableDigitalCompareSyncEvent(EPWM1_BASE, EPWM_DC_MODULE_A);

    EPWM_setTimeBaseCounterMode(EPWM1_BASE, EPWM_COUNTER_MODE_UP_DOWN);
    EPWM_setCountModeAfterSync(EPWM1_BASE, EPWM_COUNT_MODE_UP_AFTER_SYNC);
    EPWM_enablePhaseShiftLoad(EPWM1_BASE);
    EPWM_setPhaseShift(EPWM1_BASE, 2);

    EPWM_setActionQualifierAction(EPWM1_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_HIGH, EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPA);
    EPWM_setActionQualifierAction(EPWM1_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_LOW, EPWM_AQ_OUTPUT_ON_TIMEBASE_DOWN_CMPA);

  • Hi Mark,

    Sorry I forgot to get back to you before

    I am also now out-putting EXTSYNCOUT to XBAROUT3 so that I can see the sync signal in relation to the PWM waveforms.

    You can see in the capture below, I'm seeing EXTSYNCOUT  on XBAROUTPUT3 as expected, but EPWM1 is not working as expected

    >> I thought you wanted to generate sync to epwm1 from epwm4.
    What is EXTSYNCOUT in this context ?
    Is this same as epwm4 syncout ?

    Also based on the action qualifiers it looks like even when the EPWM1 goes high it doesn't come down on down counter match with cmpa.

    Can you add gpio toggle/syncout on counter 0 for epwm1 ? Not able to understand why only one action happens in one cycle. (Either high or either low)

    EPWM_setActionQualifierAction(EPWM1_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_HIGH, EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPA);
    EPWM_setActionQualifierAction(EPWM1_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_LOW, EPWM_AQ_OUTPUT_ON_TIMEBASE_DOWN_CMPA);

    Is the image above what you expect ?

    EPWM_selectDigitalCompareTripInput(EPWM1_BASE, EPWM_DC_TRIP_TRIPIN12, EPWM_DC_TYPE_DCAH); // DCAHTRIPSEL
    EPWM_setTripZoneDigitalCompareEventCondition( EPWM1_BASE, EPWM_TZ_DC_OUTPUT_A1, EPWM_TZ_EVENT_DCXH_HIGH);
    EPWM_setDigitalCompareEventSource(EPWM1_BASE, EPWM_DC_MODULE_A, EPWM_DC_EVENT_1, EPWM_DC_EVENT_SOURCE_ORIG_SIGNAL); // DCACTL.EVT1SRCSEL = 0
    EPWM_setDigitalCompareEventSyncMode(EPWM1_BASE, EPWM_DC_MODULE_A, EPWM_DC_EVENT_1, EPWM_DC_EVENT_INPUT_NOT_SYNCED); // DCACTL.EVTSYNCE = 1
    EPWM_enableDigitalCompareSyncEvent(EPWM1_BASE, EPWM_DC_MODULE_A);

    >> This looks correct : Selected TripIn12 for DCAHTRIPSEL --> DCAH high is selected as event condition --> enable sync on DCAEVT1.

  • Hi Prarthan,

    >> I thought you wanted to generate sync to epwm1 from epwm4.
    What is EXTSYNCOUT in this context ?
    Is this same as epwm4 syncout ?

    This is still the goal.  I am configuring EPWM4 SYNCOUT as source for EXTSYNCOUT.   I am using EXTSYNCOUT via EPWMXBAR as source for TRIPIN12.  And then using TRIPIN12 with EPWM1 DC submodule to trigger a sync event.

    Further observations today:

    If I run EPWM1 "standalone" without attempting synchronization, it has the correct waveform.  Up/Down count, 50% duty.  At TBCTR=10000, this is 50us low, 100us high, 50us low.

    As soon as I attempt to enable synchronization, the EPWM1 waveform changes to 50us low, 150us high, 50us low.  So the high-time of the pulse is stretched.  I enable sync by adding these lines:

    EPWM_setCountModeAfterSync(EPWM1_BASE, EPWM_COUNT_MODE_UP_AFTER_SYNC);
    EPWM_enablePhaseShiftLoad(EPWM1_BASE);
    EPWM_setPhaseShift(EPWM1_BASE, 2);

     

    If I leave sync enabled on EPWM1, but disable generation (so no EXTSYNCOUT pulse is generated), I still see the wrong waveform 50us low, 150us high, 50us low.

    I disable the EXTSYNCOUT in this case by commenting out the line

        XBAR_enableOutputMux(XBAR_OUTPUT3,XBAR_MUX14);

    I changed the frequency on EPWM1, and can illustrate the behavior in a bit of a different way.

    Here is the waveform with my attempt to enable sync from EPWM4 to EPWM1:

    EPWM1 is still configured for 50% duty.  Note that even between sync events, the high-time of EPWM1 is stretched.

    If I comment out the lines enabling sync for EPWM1 (EPWM_setCountModeAfterSync, EPWM_enablePhaseShiftLoad, EPWM_setPhaseShift), I get the correct  50% duty waveform:

  • Mark,

     Taking a step back.

    You can route syncout of epwm4 to gpio and gpio to INPUTXBAR5 and send it to epwm sync in for epwm1.

    Is this what you are doing currently ?

    If not this is the method you can try.

    This method avoids all the DC Submodule initialization hassle.

    Thanks!

  • In my end design / existing hardware, XBARINPUT1 through XBARINPUT6 are already used.  I need to try to get the DC submodule option working (unless there is another way to do this sync)

  • Understood Mark,

    Let me take a look again and get back 

  • Hi Prathan,   Have you had a chance to look at the DC submodule option for this?  Thanks!

  • Hi Mark,

    If I comment out the lines enabling sync for EPWM1 (EPWM_setCountModeAfterSync, EPWM_enablePhaseShiftLoad, EPWM_setPhaseShift), I get the correct  50% duty waveform:

    If you just disable phase shift load on epwm1 does it give proper/expected output ?

    Havent had time to create the test case to try this yet, if you can send me a simplified test case where this is reproduceable I can help solve the issue on my end here.

    Thanks!