Hi,
I'm using the LAUNCHXL-F28379D to generate PWM signals where some signals are phase shifted with respect to ePWM1.
I couldn't find a code example for high resolution phase shift, and all my attempts so far failed.
below is the code for ePWM3 that should lead by 7.2 degrees (fC6 parameter):
fC6 = 7.2;
// Start of changing PWM3(phase shift) registers
// Set Duty Cycle
{
static Uint16 oldTBPHS3 = 0;
Uint16 reg, _cmpA;
DefaultType _val;
_val = __fsat(fLIM1, 1 + 0, 0);
_val = ((Uint32)(PWM_TBPRD(3))+1) * ((1 + 0) - _val) * (1.0 / 1);
PWM_CMPA(3) = _cmpA = (int)_val;
PWM_CMPAHR(3) = (int)((_val - _cmpA) * MEP_ScaleFactor + 1.5) << 8;
_val = __fracf32(fC6 * (1.0/360.0));
reg = (int)(((Uint32)(PWM_TBPRD(3))+1) * _val);
if ((_cmpA > oldTBPHS3) && (_cmpA <= reg)) {
_cmpA = reg; // We add this because TBPHS doesn't have shadow register.
// this causes problem sometimes.
}
PWM_TBPHS(3) = oldTBPHS3 = (int)reg;
PWM_TBPHSHR(3) = (int)((reg - (int)reg) * MEP_ScaleFactor + 1.5) << 8;
cck2 = (int)((reg - (int)reg) * MEP_ScaleFactor + 1.5);
PWM_CMPA(3) = _cmpA;
// End of changing PWM3(phase shift) registers
is there a relevant example?
Thanks,
Oren