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.

TMS320F28335: EPWM compares ignoring AQCTLA and B

Part Number: TMS320F28335

Hi all,

While working on a design that has EPWMA and B that are to be used independently, I'm encountering a problem with the way the action qualifier registers are working. I'm writing the EPWM CMPA, CMPB, and TBPRD registers immediately (no shadow mode) with updated data every ~500µs. If I have the CBU bit (Compare B, counting up) for AQCTLA and AQCTLB both set to 0 (Do Nothing), both PWM outputs will occasionally turn off when hitting CMPB, despite AQCTL saying to do nothing. I'm kind of at a loss at what would cause such behavior, as both AQCTLA registers have the same value being written to them once, on startup, which is 0 (Do Nothing).

My register initialization values are below, if helpful, though keep in mind that the CMPA, CMPB, and TBPRD registers are updated every 500µs.

SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 1; // Enable TBCLK within the ePWM
EPwm1Regs.TBPRD=65535;
EPwm1Regs.CMPCTL.bit.SHDWAMODE=1;
EPwm1Regs.CMPCTL.bit.SHDWBMODE=1;
EPwm1Regs.TBCTL.bit.CLKDIV=7;
EPwm1Regs.TBCTL.bit.HSPCLKDIV=0;
EPwm1Regs.TBCTL.bit.SWFSYNC=0;
EPwm1Regs.TBCTL.bit.SYNCOSEL=0;
EPwm1Regs.TBCTL.bit.PRDLD=1;
EPwm1Regs.TBCTL.bit.PHSEN=0;
EPwm1Regs.TBCTL.bit.CTRMODE=0;
EPwm1Regs.AQCTLA.bit.CBD=0;
EPwm1Regs.AQCTLA.bit.CBU=0;
EPwm1Regs.AQCTLA.bit.CAD=0;
EPwm1Regs.AQCTLA.bit.CAU=2;
EPwm1Regs.AQCTLA.bit.PRD=1;
EPwm1Regs.AQCTLA.bit.ZRO=0;
EPwm1Regs.AQCTLB.bit.CBD=0;
EPwm1Regs.AQCTLB.bit.CBU=0;
EPwm1Regs.AQCTLB.bit.CAD=0;
EPwm1Regs.AQCTLB.bit.CAU=2;
EPwm1Regs.AQCTLB.bit.PRD=1;
EPwm1Regs.AQCTLB.bit.ZRO=0;

  • Anyone have ideas as to what could be causing this behavior?

  • What counter mode are you using?

    Can you confirm that the counter direction is not changing? Furthermore what are the CBD actions?

    Are you sure that the action qualifier settings for CBU aren't changing? 

    CMPB feeds into the AQ and the ET module. Lets confirm that you don't have any interrupt effecting this.

    Do you modify the GPx mux anywhere in your code? It is possible to disable the PWM at the GPIO mux which could affect the output of the PWM.

    Regards,
    Cody 

  • I'm using count up mode, and the counter direction is not changing. The CBD action is set to Do Nothing.

    I've turned off any PWM interrupts, trip zones, deadband control, or PWM control, so nothing else should be affecting it. I do have ECAP interrupts, though. Could those be interfering?

    After a bit more testing, the problem disappears if I turn off writes to the PRD register. I need to update the PRD register regularly, however, as it must change with motor speed. And if it were a shadowed update, it could be pretty far off when operating at low speed.

  • Ah, is there any chance that TBPRD ever gets set to a smaller value than CBU? This would cause the event to be missed. If the CBU writes are shadowed they will likely happen after TBPRD is updated.

    Regards,
    Cody 

  • So I determined that the problem is that the period register was being written from 2 different sources, and was therefore flipping between 2 different periods while CMPA and B stayed the same, making it appear like AQCTLA and B were not performing correctly. Removing the extraneous period register write fixed the problem.