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.

[FAQ] HRPWM in Up/Down counter mode will only load user CMP shadow registers on CTR=ZERO

When the HRPWM module is set up using the UP/DOWN counter mode, the CMPx and CMPxHR shadow load mode must be set to load on both CMP=ZERO AND PRD.

    EPwm1Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN;
    EPwm1Regs.TBCTL.bit.PRDLD = TB_SHADOW;

    EPwm1Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO_PRD;
    EPwm1Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;

    EPwm1Regs.HRCNFG.bit.EDGMODE = HR_BEP;
    EPwm1Regs.HRCNFG.bit.CTLMODE = HR_CMP;
    EPwm1Regs.HRCNFG.bit.HRLOAD = HR_CTR_ZERO_PRD;

Even though the shadow load mode is set to both CTR=ZERO AND PRD, the CMPx and CMPxHR shadow registers accessible by the user only get loaded at CTR=ZERO. This is due to the fact that the HRPWM module will center the PWM signal around CTR=PRD. The HRPWM module will internally calculate and load different CMPx and CMPxHR values at CTR=ZERO and then again at CTR=PRD (not accessible through software) to advance and delay the edges of the PWM output.

  • Thanks for posting this Nima!
  • Again, I would like to reiterate:

    Even though the shadow load mode is set to both CTR=ZERO AND PRD, the CMPx and CMPxHR shadow registers accessible by the user only get loaded at CTR=ZERO. This is due to the fact that the HRPWM module will center the PWM signal around CTR=PRD. The HRPWM module will internally calculate and load different CMPx and CMPxHR values at CTR=ZERO and then again at CTR=PRD (not accessible through software) to advance and delay the edges of the PWM output.