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: PWM Duty extending in multi-phase variable frequency operation

Part Number: TMS320F28379D
Other Parts Discussed in Thread: C2000WARE

Tool/software:

Hello I am working on a 3 phase 3 level Flying Capacitor Totem-pole Boost PFC in Inverter mode. We are operating in Triangle Conduction Mode (iTCM) where the switching frequency of each leg and duty cycles also vary. Since we need the PWMs to be correctly updated during each ISR interval, I have used the global load mode to latch the TBPRD, CMPA, CMPB and TBPHS registers. In phase A, I am using EPWM1 (inner switches) and EPWM2 (outer switches). I am facing an issue where if my TBPHS is larger than the CMPA for EPWM2, it keeps EPWM2A ON for a longer duration. I have attached waveforms of the same below. Please help me in resolving this.

  • Hello Pranav,

    So if I'm understanding the issue, you are missing an action qualifier due to the phase shift skipping over the action qualifier event. If this is the case, please see this related thread and let me know if this is applicable/can help resolve your issue: 

    https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1312604/tms320f28379d-tms320f28379d-phase-shift-pwm-missing-pulse 

    Best Regards,

    Allison

  • Hello Allison,

    I am using the global load mode in one-shot configuration because my application is also variable frequency. Is this solution applicable for that?

    Regards,

    Pranav

  • Hi Pranav, 

    The loading scheme wouldn't affect this solution since the solution implements separate action qualifiers (T1/T2) on sync pulses to carry out actions that are missed under certain conditions (e.g. when the TBPHS > CMPA, causing the TBCTR to skip over an action qualifier event upon a sync pulse).

    To clarify, is the extended pulse occurring around when you have a sync pulse? (In case you didn't know or were curious, you can actually scope out the EPWM sync pulse "EXTSYNCOUT" by using the OUTPUT XBAR module which can be quite helpful in debug sometimes). In the thread I linked, you can read my description of the issue and assess if this applies to your situation.

    Best Regards,

    Allison

  • Hello Allison, can you verify if this logic in my code? I think I am missing out on something

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    if(new_phase > new_cmp)
    {
    cmp = new_phase + 1;
    EPwm2Regs.AQTSRCSEL.bit.T1SEL = 7; // EPWMxSYNCI chosen as T1 Event Source
    EPwm2Regs.AQCTLA.bit.CAU = AQ_SET;
    }
    else
    {
    cmp = news_cmp;
    EPwm2Regs.AQTSRCSEL.bit.T1SEL = 0; // Default source selected
    EPwm2Regs.AQCTLA.bit.CAU = AQ_CLEAR;
    }
    EPwm2Regs.CMPA.bit.CMPA = cmp;
    EPwm2Regs.TBPHS.bit.TBPHS = new_phase;
    EPwm1Regs.GLDCTL2.bit.OSHTLD = 1;
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Hi Pranav, 

    Thanks for following up. Please allow me another day to take a look and provide further guidance. 

    Best Regards,

    Allison

  • Hi Pranav, 

    Could you please send me your EPWM initializations so I can see the foundational settings (Time Base, Counter Compare values, Action Qualifiers etc.)? 

    Best Regards,

    Allison

  • Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    // PWM initialization
    EPwm1Regs.TBCTL.bit.CTRMODE = TB_COUNT_UP; // Count up
    EPwm1Regs.TBPRD = PWM_PERIOD; // Set timer period
    EPwm1Regs.TBCTR = PWM_PERIOD/2; // Set time base counter to half period counts
    EPwm1Regs.TBCTL.bit.PHSEN = TB_DISABLE; // Disable phase loading
    EPwm1Regs.TBCTL.bit.SYNCOSEL = 0x1;
    EPwm1Regs.TBPHS.bit.TBPHS = 0x0000; // Phase is 0
    EPwm1Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
    EPwm1Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
    EPwm1Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO;
    EPwm1Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO;
    EPwm1Regs.TBCTL.bit.HSPCLKDIV = 0; // Clock ratio to SYSCLKOUT
    EPwm1Regs.TBCTL.bit.CLKDIV = 0;
    EPwm1Regs.AQCTLA.bit.ZRO = AQ_SET; // Set PWM1A on Zero
    EPwm1Regs.AQCTLA.bit.CAU = AQ_CLEAR; // Clear PWM1A on event A,
    EPwm1Regs.DBCTL.bit.OUT_MODE = 0x3;
    EPwm1Regs.DBCTL.bit.POLSEL = 0x2;
    EPwm1Regs.DBFED.bit.DBFED = DT;
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Thank you! Let me review and try to run a few test cases. I will follow up after.

    Best Regards,

    Allison

  • Hi Pranav,

    I stripped down the EPWM settings to isolate the issue and showcase a simple way you can to use the T1 Event to fulfill the missing action qualifier. The attached .c is taken from our DriverLib synchronization example ({C2000Ware}\driverlib\f2837xd\examples\cpu1\epwm\epwm_ex3_synchronization) and modified to do so. I left comments at the top explaining. Let me know if this is helpful or if you still have trouble implementing it!

    epwm_ex3_synchronization_MODIFIED.c
    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    // ePWM Phase Shift and T1 Workaround.
    //
    // This is the DriverLib epwm_ex3_synchronization example modified.
    //
    // This file configures EPWM1A to GPIO0 and and EPWM2A to GPIO2.
    // EPWM1A:
    // - High on CTR = 0
    // - Sync-Out pulse on CTR = CMPB = 500
    // - Low on CMPA = 1000
    // - PRD = 2000
    //
    // EPWM2A:
    // - High on CTR = 0
    // - Low on CMPA = 1000
    // - PRD = 2000
    // - TBPHS = 1500 (sync-in is EPWM1 sync-out = 500)
    //
    // The example demonstrates a missing EPWM2A action qualifier in the first cycle due to phase shift.
    // The workaround is implemented in main() by using the T1 AQ to carry out the missed action qualifier
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Best Regards,

    Allison

  • Hello Allison,

    This helped me resolve the issue. Thank you so much for the timely help!