Hi,
I am facing issue setting the phase offset value for decimal values in HRPWM in up-down count mode. I have updated the example epwm_up_aq_cpu01 to perform the following settings.
1) Generate ePWM1 syncout to ePWM2
2) update phase value to TBPHS and TBPHSHR register for every sync event.
3) Use auto conversion to update mep_scale factor.
4) Use count up as the direction after phase update.
Code shown below.
for(;;)
{
EPwm2Regs.TBPHS.bit.TBPHS = (Uint16)phaseVal;
/*-- Update TBPHSHR --*/
float TBPHSf = phaseVal;
TBPHSf -= EPwm2Regs.TBPHS.bit.TBPHS;
TBPHSf *= 65536;
EPwm2Regs.TBPHS.bit.TBPHSHR = (Uint16)TBPHSf;
update_MepScaleFactor();
}
I have configured both ePWMs for 500KHz frequency and 50% duty cycle. I have attached the oscilloscope screenshots for 3 cases of phase values
Case 1: Phase offset - 7 clock cycles, expected value of phase delay - 50 ns, Actual phase delay - 50 ns (red), ePWM2(green) lags in phase compared to ePWM1(yellow)
Case 2: Phase offset - 8 clock cycles, expected value of phase delay - 60 ns, Actual phase delay - 60 ns, ePWM2 lags in phase compared to ePWM1
Case 3: Phase offset - 7.6 clock cycles, expected value of phase delay - 56 ns, Actual phase delay - 44 ns, ePWM2 lags in phase compared to ePWM1
I can see similar behavior for up count mode as well. Can you let us know if anything is missing here.
Attaching the source code
Thanks,
Aditya
