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: While changing ePWM period and duty on the fly, output is not continuos.

Part Number: TMS320F28379D


Hi dear people!
Progressing in my application, I am in need of a variable output in one ePWM channel,
changing Period and Duty every millisecond.

If I do this inside a loop, the ePWM get periods of time (around 1,3 mS) where the output is zero. The pin goes down for 1,3 mS, and then the normal operation continues.

Those "black-outs" correspond to the end of the setting with the largest Period, it fails to change to the quicker setting.

Sometimes, however, it succeed, ramdonly.

I include some screenshots to show this.
In the screenshots I use a DELAY_US(500); to toggle a pin to make things more clear to you. 
Every time the pin toggles, the settings should change too.

I have changed the settings and changed the time every setting is active, without succes.
The 1,3 mS periods occur at different intervals, but always by the end of the period with the slower setting.
I have used another Launchpad.
Running the Launchpad in stand alone, without my custom circuit, does not help either.
If I run the loop with only one of the settings, everything is fine.
I have stoped the ePWM with
CpuSysRegs.PCLKCR0.bit.TBCLKSYNC = 0;
before making the changes and started it again, no changes.

If I use a slider to modity those setings, everything is fine, but if I run it in a loop not.

Is there a way to do this?

Below I include the two settings and the configuration of the ePWM

Thanks in advance for your opinion!

Greetings from Germany,

Gustavo

EPwm4Regs.TBPRD = 176;
EPwm4Regs.CMPA.bit.CMPA = 107;
EPwm4Regs.CMPB.bit.CMPB = 107;

EPwm4Regs.TBPRD = 57;
EPwm4Regs.CMPA.bit.CMPA = 35;
EPwm4Regs.CMPB.bit.CMPB = 35

void HRPWM4_Config(period)

{
EPwm4Regs.TBCTL.bit.PRDLD = TB_IMMEDIATE;
EPwm4Regs.TBPRD = 176;
EPwm4Regs.CMPA.bit.CMPA = 107;
EPwm4Regs.CMPA.bit.CMPAHR = (0 << 8);

EPwm4Regs.CMPB.bit.CMPB = 107;
EPwm4Regs.CMPB.all |= (0 << 8);


EPwm4Regs.TBPHS.all = 0;
EPwm4Regs.TBCTR = 0;

EPwm4Regs.TBCTL.bit.CTRMODE = TB_COUNT_UP;

EPwm4Regs.TBCTL.bit.PHSEN = TB_DISABLE;
EPwm4Regs.TBCTL.bit.SYNCOSEL = TB_SYNC_DISABLE;

EPwm4Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1;
EPwm4Regs.TBCTL.bit.CLKDIV = TB_DIV1;

EPwm4Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO;
EPwm4Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO;
EPwm4Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
EPwm4Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;

EPwm4Regs.AQCTLA.bit.ZRO = AQ_SET;
EPwm4Regs.AQCTLA.bit.CAU = AQ_CLEAR;
EPwm4Regs.AQCTLB.bit.ZRO = AQ_SET;
EPwm4Regs.AQCTLB.bit.CBU = AQ_CLEAR;

EPwm4Regs.ETSEL.bit.INTEN = 1;

EPwm4Regs.ETPS.bit.INTPSSEL = 0x0;
EPwm4Regs.ETPS.bit.INTPRD = 0x0;
EPwm4Regs.ETSEL.bit.INTSELCMP = 0x0;
EPwm4Regs.ETSEL.bit.INTSEL = 0x6;

EALLOW;
EPwm4Regs.HRCNFG.all = 0x0;
EPwm4Regs.HRCNFG.bit.EDGMODE = HR_FEP;
EPwm4Regs.HRCNFG.bit.CTLMODE = HR_CMP;
EPwm4Regs.HRCNFG.bit.HRLOAD = HR_CTR_ZERO;
EPwm4Regs.HRCNFG.bit.EDGMODEB = HR_FEP;
EPwm4Regs.HRCNFG.bit.CTLMODEB = HR_CMP;
EPwm4Regs.HRCNFG.bit.HRLOADB = HR_CTR_ZERO;
EDIS;
}

  • Gustavo,

    Great to hear back from you. I will work on writing up an answer to your question.

    Nima Eskandari

  • Hi Nima,
    nice that you got my inquiry!
    I hope you have not spent time on it. After tweaking a while I got the solution:

    I got the output constant by clearing the counter before changing the settings
    EPwmxRegs.TBCTR = 0x0000;
    Tell me, please, if I am wrong, or if I should do anything else to make it really stable.

    However, I am confused, since if I use a Slider with the function
    menuitem "ePWM Period"
    slider PeriodSlider(1, 254, 1, 1, periodvalue)
    {
    EPwm4Regs.TBPRD = periodvalue;
    EPwm4Regs.CMPA.bit.CMPA = periodvalue/2;
    }
    things work fine.

    I wish you a nice day!
    Gustavo