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.

TMS320F28377S: TMS320F28377SPTPT problem with PWM

Part Number: TMS320F28377S


Hello,

we got problem with PWM in microcontroller TMS320F28377S. Microcontroller control IGBT module in inverter, and for two production series there isn't any problems with this product. But in third series, inverters start to make some strange sounds. After some investigation I recognize that microcontroller generate incorect PWM. PWM looks like comparator which is inside PWM registers ignore conditions for one period, and turn off output in next period.

This problem occurs also with constant duty eg 50%, so it isn't some numerical issue. Duty is set only once, after initialization and befor main loop. Only one thing that affects is switch Counter Compare from CMPA to CMPB.  Below there is initialization.For SWAP Boost =1 were OK but for SWAP Boost =0.

void boostPwmConfig(void)
{
EALLOW;
CpuSysRegs.PCLKCR2.bit.EPWM7 = 0x01;
EPwm7Regs.TBPRD = TBPRD_16kHz;
EPwm7Regs.CMPA.bit.CMPA = 0;
EPwm7Regs.CMPB.bit.CMPB = 0; // Compare B = 500 TBCLK counts
EPwm7Regs.TBPHS.all = 0; // Set Phase register to zero
EPwm7Regs.TBCTR = 0; // clear TB counter
EPwm7Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN; // Symmetric
//EPwm7Regs.TBCTL.bit.PHSEN = TB_DISABLE; // Phase loading disabled
EPwm7Regs.TBCTL.bit.PHSEN = TB_ENABLE; // Phase loading enabled
EPwm7Regs.TBCTL.bit.PHSDIR = TB_UP;
EPwm7Regs.TBCTL.bit.PRDLD = TB_SHADOW;
EPwm7Regs.TBCTL.bit.SYNCOSEL = TB_CTR_ZERO;
EPwm7Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1; // TBCLK = SYSCLKOUT
EPwm7Regs.TBCTL.bit.CLKDIV = TB_DIV1;
ClkCfgRegs.PERCLKDIVSEL.bit.EPWMCLKDIV = 0;//
EPwm7Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
EPwm7Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
EPwm7Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO; // load on CTR = Zero
EPwm7Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO; // load on CTR = Zero
EPwm7Regs.DBCTL.bit.OUT_MODE = DB_DISABLE;
EPwm7Regs.TZFRC.bit.OST = 1;
#ifdef SWAP_BOOST

EPwm7Regs.AQCTLA.bit.CBU = AQ_SET;
EPwm7Regs.AQCTLA.bit.CBD = AQ_CLEAR;
EPwm7Regs.AQCTLB.bit.CAU = AQ_SET;
EPwm7Regs.AQCTLB.bit.CAD = AQ_CLEAR;
EPwm7Regs.DBCTL.bit.OUTSWAP=SWAP;
#else
EPwm7Regs.AQCTLA.bit.CAU = AQ_SET;
EPwm7Regs.AQCTLA.bit.CAD = AQ_CLEAR;
EPwm7Regs.AQCTLB.bit.CBU = AQ_SET;
EPwm7Regs.AQCTLB.bit.CBD = AQ_CLEAR;
EPwm7Regs.DBCTL.bit.OUTSWAP=NO_SWAP;
#endif
GpioCtrlRegs.GPAMUX1.bit.GPIO12 = 1;
GpioCtrlRegs.GPADIR.bit.GPIO12 = 1;
GpioCtrlRegs.GPAMUX1.bit.GPIO13 = 1;
GpioCtrlRegs.GPADIR.bit.GPIO13 = 1;

I checked also all power supplies on board, there were OK.

This phenomena happens only in microcontrollers with productions number: $4C-96AZKNW G4 and $4C-96C2GKW G4. After resolder for another microcontroller from diffrent series this problem didn't occur. The problem is only in one PWM for each microcontroller, but different devices have a problem for different PWM output, e.g. PWM7A and PWM7B on one device and PWM6A and PWM6B on another.

What could be causing this behavior? Defect in this series of microcontrolers? Overheat in solder process? Maybe some initialization are wrong?

Maybe also I can check something more?

  • Just to clarify,

    This works for you:

    EPwm7Regs.AQCTLA.bit.CBU = AQ_SET;
    EPwm7Regs.AQCTLA.bit.CBD = AQ_CLEAR;
    EPwm7Regs.AQCTLB.bit.CAU = AQ_SET;
    EPwm7Regs.AQCTLB.bit.CAD = AQ_CLEAR;
    EPwm7Regs.DBCTL.bit.OUTSWAP=1;

    However, the code below did NOT work:

    EPwm7Regs.AQCTLA.bit.CAU = AQ_SET;
    EPwm7Regs.AQCTLA.bit.CAD = AQ_CLEAR;
    EPwm7Regs.AQCTLB.bit.CBU = AQ_SET;
    EPwm7Regs.AQCTLB.bit.CBD = AQ_CLEAR;
    EPwm7Regs.DBCTL.bit.OUTSWAP=0;

    Nima

  • Thank you for your answer! I gave the guidelines for the programmer, so he'll check this.

    I also upload waveforms below.

    Legend: green-PWM7A, blue-PWM7B, purple-output voltage, yellow-output current

  • Thank you, we will await for your feedback!

    Nima

  • Ok, I got answer from programmer and I also checked all twice.

    Original register declaration looks that:

    EALLOW;
        CpuSysRegs.PCLKCR2.bit.EPWM7 = 0x01;

        EPwm7Regs.TBPRD = TBPRD_16kHz;
        EPwm7Regs.CMPA.bit.CMPA = 0;
        EPwm7Regs.CMPB.bit.CMPB = 0; // Compare B = 500 TBCLK counts
        EPwm7Regs.TBPHS.all = 0; // Set Phase register to zero
        EPwm7Regs.TBCTR = 0; // clear TB counter
        EPwm7Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN; // Symmetric

        //EPwm7Regs.TBCTL.bit.PHSEN = TB_DISABLE; // Phase loading disabled
        EPwm7Regs.TBCTL.bit.PHSEN = TB_ENABLE; // Phase loading enabled
        EPwm7Regs.TBCTL.bit.PHSDIR = TB_UP;

        EPwm7Regs.TBCTL.bit.PRDLD = TB_SHADOW;
        EPwm7Regs.TBCTL.bit.SYNCOSEL = TB_CTR_ZERO;
        EPwm7Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1; // TBCLK = SYSCLKOUT
        EPwm7Regs.TBCTL.bit.CLKDIV = TB_DIV1;
        ClkCfgRegs.PERCLKDIVSEL.bit.EPWMCLKDIV = 0;//
        EPwm7Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
        EPwm7Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
        EPwm7Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO; // load on CTR = Zero
        EPwm7Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO; // load on CTR = Zero
        EPwm7Regs.DBCTL.bit.OUT_MODE = DB_DISABLE;
        EPwm7Regs.AQCTLA.bit.CAU = AQ_SET;
        EPwm7Regs.AQCTLA.bit.CAD = AQ_CLEAR;
        EPwm7Regs.AQCTLB.bit.CBU = AQ_SET;
        EPwm7Regs.AQCTLB.bit.CBD = AQ_CLEAR;

        GpioCtrlRegs.GPAMUX1.bit.GPIO12 = 1;
        GpioCtrlRegs.GPADIR.bit.GPIO12 = 1;

        GpioCtrlRegs.GPAMUX1.bit.GPIO13 = 1;
        GpioCtrlRegs.GPADIR.bit.GPIO13 = 1;

    This settings works perfectly fine for two series our products. In the third series, with same components, same board layout but with different microcontroller production number, the problem described has started. Thats why, after examining, programmer found that with slightly different declarations problem disappeared. Below you got code which help on this specify device which got problem with PWM7, and in this case it helps.

    EPwm7Regs.AQCTLA.bit.CBU = AQ_SET;
    EPwm7Regs.AQCTLA.bit.CBD = AQ_CLEAR;
    EPwm7Regs.AQCTLB.bit.CAU = AQ_SET;
    EPwm7Regs.AQCTLB.bit.CAD = AQ_CLEAR;
    EPwm7Regs.DBCTL.bit.OUTSWAP=SWAP;

    Unfortunately, this does not solve the problem, because on diffrent devices it could be problem with diffrent PWM e.g. PWM7 or PWM8 etc. We do not know why a microcontroller with same program code behaves incorrectly, while previously it was fine.

  • Your configuration looks correct and should not cause any issue. Can you make sure to set the rest of the AQ events as well?

    ZERO -> no action (or the corresponding action)
    PRD -> no action (or the corresponding action)
    CAU/CAD/CBD/CAD for both AQCTLA and AQCTLB -> no action (or the corresponding action)

    I would like all of the AQ events set to their correspong actions explicitly. 

    This is a strange issue which I cannot reproduce, so we have to nail it down on their board.

    Nima

  • I have sent you full initialization. Throughout the code, no PWM7 registers are set anymore, except for duty cycle.
    Perhaps the problem is the default setting of the registers and possible hazard associated with them?

  • I'm not seeing an issue with these settings. Lets do something. Can you send the failing scenario code to be as a zipped CCS project? The COMPLETE code of the project which generates the error. I can try it here on multiple of my boards. If I cannot recreate the issue, then we would need a customer board.

    So can we get an example CCS project zipped so I can test it on my boards first and see if there is anything other than the EPWM settings that could be causing this?

    Nima

  • Maybe the issue is in the GPIO setting, maybe its something unexpected on the board. But nevertheless, the next step is for me to have the full CCS project so I can try it.

    Nima

  • Piotr,

    Where you able to package the full code for me?

    Nima

  • Yes, of course I can send you the full project. Unfortunately, the code is confidential, so I would put the package on a company dropbox. Is it possible here to send a private message?

  • Yes Piotr, please send a friendship request to me on E2E and I can share my email with you. But I was mainly asking for GPIO/EPWM initialization example project that reproduces your issue. Not your confidential code.

    Nima

  • Piotr,

    I have not yet received a friendship request on E2E so I can send you my email.

    Nima