Part Number: TMS320F28388D
Other Parts Discussed in Thread: C2000WARE
Hello,
I have a question regarding “high resolution PWM”.
My system requires both of the high-resolution period control and phase control at the same time.
I have examined by the following related code, but the phase shifted epwm2 output has jitter during edging.
when I changed the setting to the following, the jitter disappeared.
EPwm1Regs.TBPRDHR = 0x0;
EPwm2Regs.TBPRDHR = 0x0;
OR
EPwm1Regs.HRPCTL.bit.HRPE = 0U;
EPwm2Regs.HRPCTL.bit.HRPE = 0U;
Is it possible to use high-resolution period control and phase control together?
If possible, is there any problem with my configuration ?
Here is the initialization:
-EPWM clock: 200MHz
-Up –down counter mode
-With TBCTR = 0x0000 event synchronization
-PWM frequency = 995kHz (peak cnt = 100.5)
-Phase shift = 90.5degree (25.5cnt)
A part of the related code:
------------------------------------------------------------------------
do {
status = SFO();
if (status == SFO_ERROR) {
error();
}
} while (status == SFO_INCOMPLETE);
#endif
EALLOW;
/* Timer stop */
CpuSysRegs.PCLKCR0.bit.TBCLKSYNC = 0U;
ClkCfgRegs.PERCLKDIVSEL.bit.EPWMCLKDIV = 0;
CpuSysRegs.PCLKCR2.bit.EPWM1 = 1U;
CpuSysRegs.PCLKCR2.bit.EPWM2 = 1U;
EDIS;
EPwm1Regs.TBCTL.bit.PHSEN = TB_DISABLE;
EPwm2Regs.TBCTL.bit.PHSEN = TB_DISABLE;
EPwm1Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN;
EPwm2Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN;
EPwm1Regs.EPWMSYNCINSEL.bit.SEL = 0U;
EPwm1Regs.EPWMSYNCOUTEN.bit.ZEROEN = 1U; //for f28388
EPwm2Regs.EPWMSYNCINSEL.bit.SEL = 1U;
EPwm2Regs.EPWMSYNCOUTEN.bit.ZEROEN = 0U; //for f28388
EPwm1Regs.HRPCTL.bit.TBPHSHRLOADE = 1U;
EPwm2Regs.HRPCTL.bit.TBPHSHRLOADE = 1U;
EPwm1Regs.TBPRD = 100U; // PWM frequency = 1/(2*TBPRD)
EPwm1Regs.TBPRDHR = 0x7F<<8U;
EPwm2Regs.TBPRD = 100U;
EPwm2Regs.TBPRDHR = 0x7F<<8U;
EALLOW;
EPwm1Regs.HRCNFG.bit.EDGMODE = 3U; /** MEP control of both edges (TBPHSHR or TBPRDHR) **/
EPwm1Regs.HRCNFG.bit.CTLMODE = 0U; /** CMPAHR(8) or TBPRDHR(8) Register controls the edge position **/
EPwm1Regs.HRCNFG.bit.HRLOAD = 2U; /** CMPAHR shadow value Load on either CTR = Zero or CTR = PRD **/
EPwm1Regs.HRCNFG.bit.SELOUTB = 0U; /** ePWMxB output is normal?**/
EPwm1Regs.HRCNFG.bit.AUTOCONV = 1U; /** Automatic HRMSTEP scaling is enabled **/
EPwm1Regs.HRCNFG.bit.EDGMODEB = 3U; /** MEP control of both edges (TBPHSHR or TBPRDHR) **/
EPwm1Regs.HRCNFG.bit.HRLOADB = 2U; /** CMPBHR shadow value Load on either CTR = Zero or CTR = PRD **/
EPwm2Regs.HRCNFG.bit.EDGMODE = 3U; /** MEP control of both edges (TBPHSHR or TBPRDHR) **/
EPwm2Regs.HRCNFG.bit.CTLMODE = 0U; /** CMPAHR(8) or TBPRDHR(8) Register controls the edge position **/
EPwm2Regs.HRCNFG.bit.HRLOAD = 2U; /** CMPAHR shadow value Load on either CTR = Zero or CTR = PRD **/
EPwm2Regs.HRCNFG.bit.SELOUTB = 0U; /** ePWMxB output is normal?**/
EPwm2Regs.HRCNFG.bit.AUTOCONV = 1U; /** Automatic HRMSTEP scaling is enabled **/
EPwm2Regs.HRCNFG.bit.EDGMODEB = 3U; /** MEP control of both edges (TBPHSHR or TBPRDHR) **/
EPwm2Regs.HRCNFG.bit.HRLOADB = 2U; /** CMPBHR shadow value Load on either CTR = Zero or CTR = PRD **/
EPwm1Regs.HRPCTL.bit.HRPE = 1U; // highresolutionperiod control is enabled
EPwm2Regs.HRPCTL.bit.HRPE = 1U; // highresolutionperiod control is enabled
EPwm2Regs.TBPHS.bit.TBPHS = 25U;
EPwm2Regs.TRREM.bit.TRREM = 0x17F;
EPwm2Regs.TBCTL.bit.PHSDIR = 0;
EPwm2Regs.TBCTL.bit.PHSEN = TB_ENABLE;
CpuSysRegs.PCLKCR0.bit.TBCLKSYNC = 1U; /* Time Base Clock enable */
EDIS;


