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: Configure EPWMs to load CMPA on SYNCIN

Part Number: TMS320F28379D
Other Parts Discussed in Thread: C2000WARE

Tool/software:

I am unable to configure the EPWMs to load CMPA on a SYNCIN event.

Here is my setup:

I'm using EPWM Modules 1 through 11. I need to load the shadowed CMPA and CMPB value for EPWMs 9 through 11 simultaneously for my design. Right now, I am attempting to do the following

- EPWM 1 configured to generate SYNCOUT pulse when TBCTR=0
- EPWM 2 through 11 configured to use SYNCOUT = SYNCIN
- EPWM 1 through 8 configured to be active high (not complementary)
- EPWM 9 through 11 configured to be active high complementary
- EPWM 9 through 11 configured to load CMPA and CMPB on SYNCIN


This last part is the the one that doesn't seem to work for me. 

I have attached a working test project that demonstrates the issue.

The relevant code is in lines 561-577

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
EPwm9Regs.CMPCTL.bit.LOADAMODE = 0;
EPwm9Regs.CMPCTL.bit.LOADASYNC = 2;
EPwm9Regs.CMPCTL.bit.LOADBMODE = 0;
EPwm9Regs.CMPCTL.bit.LOADBSYNC = 2;
EPwm10Regs.CMPCTL.bit.LOADAMODE = 0;
EPwm10Regs.CMPCTL.bit.LOADASYNC = 2;
EPwm10Regs.CMPCTL.bit.LOADBMODE = 0;
EPwm10Regs.CMPCTL.bit.LOADBSYNC = 2;
EPwm11Regs.CMPCTL.bit.LOADAMODE = 0;
EPwm11Regs.CMPCTL.bit.LOADASYNC = 2;
EPwm11Regs.CMPCTL.bit.LOADBMODE = 0;
EPwm11Regs.CMPCTL.bit.LOADBSYNC = 2;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX



When I run this program and test whether the PWM duty ratios are updating properly, I see that the duty ratio is never actually loaded, despite the fact that I can confirm the EPWM Sync signal is present.

Here is an image showing the PWM signals, sync signal output on a GPIO pin, and a flag that I'm using for triggering the measurement. The duty ratios should be different before and after the trigger point, but never change.



--------

For comparison, here is the behavior when I set EPwmxRegs.CMPCTL.bit.LOADASYNC = 0 for all three EPWMs. You can see that the duty ratios get updated at the CTR=0 point as they should.



It seems I am missing some setting to get the EPWMs to load on sync, but I am unable to determine what is incorrect here. According to section 15.5 in the Technical Reference Manual I am setting all the CMPCTL registers properly.

Looking forward to hearing from you. I have attached a working project as a .zip file (please be sure to set the value of C2000WARE_ROOT properly in Project Properties > Linked Resources to ensure the library dependencies link properly) (EDIT Nov 22, 2024: project updated in comments)

Regards,
Rahul

  • Hi Rahul,

    Can you please double check that your Sync-IN source for those PWMs is set up correctly?

    Please send a snippet of the Sync select registers to verify that the sync source is set up correctly - if this is true, then the loading scheme should work if you have set up shadow load on sync.

    Best Regards,

    Allison

  • Hi Allison,

    I verified that the SYNCO TO SYNCI chain is functioning as I expect by connecting SYNCOs via the EXTSYNCOUT and OutputXBAR to a GPIO pin and probing with an oscilloscope.

    However, despite the SYNCI configuration, the CMPA/B load is not being triggered.

    Here are the settings copied from the configure_EPWM function in the project that I attached. 


    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    EALLOW;
    CpuSysRegs.PCLKCR0.bit.TBCLKSYNC = 0; // stop TBCTR incrementing
    EDIS;
    // EPWM 1
    EPwm1Regs.TBCTL.bit.CLKDIV = TB_DIV1; // CLKDIV=1 TBCLK=EPWMCLK/(HSPCLKDIV*CLKDIV)
    EPwm1Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1; // HSPCLKDIV=1
    EPwm1Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN; // Up-down mode
    EPwm1Regs.TBPRD = EPWM_TBPRD; // Counter period
    EPwm1Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW; // Shadow mode active for CMPA
    EPwm1Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW; // Shadow mode active for CMPB
    EPwm1Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO; // Load on TBCTR=TBPRD
    EPwm1Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO; // Load on TBCTR=TBPRD
    EPwm1Regs.CMPA.bit.CMPA = EPWM_TBPRD; // Initial value of CMPA
    EPwm1Regs.AQCTLA.bit.CAU = AQ_CLEAR; // Set EPWMA low on TBCTR=CMPA during up count
    EPwm1Regs.AQCTLA.bit.CAD = AQ_SET; // Set EPWMA high on TBCTR=CMPA during down count
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Hi Rahul,

    Thanks for the information. Please give me another few days to take a look.

    Best Regards,

    Allison

  • Hi Allison,

    Thanks. Looking forward to hearing back from you and/or anyone else on the C2000 team.

    Regards,
    Rahul

  • Hi Rahul,

    No update yet- I will follow up tomorrow. Appreciate the patience!

    Best Regards,

    Allison

  • Hi ,

    After extensive trial and error, I have determined that the way to get CMPA to load on SYNCI is to set

    EPwmxRegs.TBCTL.bit.PHSEN = 1 

    In other words, the PHSEN bit does more than just loading TBCTR with the value of TBPHS on sync, it also appears to gate whether CMPA gets loaded on sync.

    There's no mention of this anywhere in the Technical Reference Manual. I'd like to understand whether this is indeed the way PHSEN is designed to operate within the EPWM module or if it only works in this project by some coincidence.

    I have attached a new zip file that can be A/B tested to verify this behavior.

    3187.test_epwm_sync.zip

    Here, lines 645 to 655 are commented out and because PHSEN is set to 1 for all modules, the CMPA load on SYNCI behavior is as expected.

    If you uncomment these lines (set PHSEN = 0 for all modules) the loading no longer works.

    Best,
    Rahul

  • Hi Rahul,

    Appreciate the perseverance- glad you were able to get the desired output.

    The PHSEN bit will determine whether the sync pulse is able to be used as a SYNC-IN source for the PWM, so this behavior aligns with the TRM when it mentions "Clearing the TBCTL[PHSEN] bit configures the ePWM to ignore the synchronization input pulse." The SYNC-IN pulse is what is used for the loading strobe.

    However, it may not be clear in regard the SYNC signal being used for other register loading (beyond TBPHS). I will make a note for this to be clarified in this section in the future Slight smile

    Best Regards,

    Allison

  • Hi Allison,

    Appreciate the note to clarify this in the future. I interpreted the statement you're referring to about TBCTL as only applying to the TB submodule, not CC also. It appears from the explanation that TBCTL[PHSEN] configures all submodules within the EPWM module to ignore the SYNCIN pulse. 

    Best,
    Rahul