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.

CCS/TMS320F280049C: HRPWM phase shift, unable to get microsteps

Part Number: TMS320F280049C
Other Parts Discussed in Thread: C2000WARE

Tool/software: Code Composer Studio

Hello,

I am trying to implement the HR PWM phase shift for my application. With normal EPWM is working, but I would need higher resolution. Here is the code that I am using:

void PSFB_HAL_setupHRPWM(uint32_t PWMbase)

{

    MEP_ScaleFactor = 55;

    //Number of MEP steps per coarse step at 180 ps (10 n/180 ps ), MEP_ScaleFactor
    HRPWM_setMEPStep(PWMbase, MEP_ScaleFactor);

    //
    // HRCAL uses the EPWM1 clock
    //
    SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_EPWM1);

    HRPWM_enableAutoConversion(PWMbase);

    //Setting MEP
    HRPWM_setMEPEdgeSelect(PWMbase, HRPWM_CHANNEL_A, HRPWM_MEP_CTRL_RISING_AND_FALLING_EDGE);
    HRPWM_setMEPControlMode(PWMbase, HRPWM_CHANNEL_A, HRPWM_MEP_PHASE_CTRL);//HRPWM_MEP_DUTY_PERIOD_CTRL);

    //HRPWM_setSyncPulseSource(PWMbase, HRPWM_PWMSYNC_SOURCE_ZERO);

    //HRPWM_enablePeriodControl(PWMbase);
    //HRPWM_setTimeBasePeriod(PWMbase, PSFB_EPWM_TBPRD);
    //HRPWM_setHiResTimeBasePeriodOnly(PWMbase, frac(PSFB_EPWM_TBPRD) << 8);

    //
    // Align HRPWM CMPA value and shadow mode with EPWM
    //
    HRPWM_setCounterCompareShadowLoadEvent(PWMbase, HRPWM_CHANNEL_A, HRPWM_LOAD_ON_CNTR_ZERO);

    HRPWM_setCounterCompareValue(PWMbase, HRPWM_COUNTER_COMPARE_A, 0);
    HRPWM_setHiResCounterCompareValueOnly(PWMbase, HRPWM_COUNTER_COMPARE_A, 0);

    HRPWM_setChannelBOutputPath(PWMbase, HRPWM_OUTPUT_ON_B_NORMAL);

    HRPWM_setPhaseShift(PWMbase, 0);
    HRPWM_setHiResPhaseShiftOnly(PWMbase, 0);

}

In main:

    HRPWM_enablePhaseShiftLoad(PSFB2_DRV_EPWM_BASE);
    HRPWM_enablePhaseShiftLoad(PSFBR_DRV_EPWM_BASE);

    EPWM_enablePhaseShiftLoad(PSFB2_DRV_EPWM_BASE);
    EPWM_enablePhaseShiftLoad(PSFBR_DRV_EPWM_BASE);

for(;;)

{

Phase_shift = PSFB_shift / 360; //Where PSFB_shift varies from 0 to 360.

         HRPWM_setPhaseShift(PSFB2_DRV_EPWM_BASE, (uint32_t)((Phase_shift * PSFB_EPWM_TBPRD) * ((uint16_t)0x1 << 8)));

}

PSFB_shift is updated every 10Hz:

    if(PSFB_shift <=45)
        PSFB_shift= 300;

    PSFB_shift = PSFB_shift - 0.01f;

What I get on the output is that the signal is shifting to the left by microsteps, very small steps, and then, suddenly jumping to the right with 4ns step. So doing the shift to the other direction and recovering what it has done to the left plus additional "jump"... I try to add a video of the oscilloscope.

Thank you very much.

Luis

  • Hi,

    Could you please refer to the example 
    C:\ti\c2000\C2000Ware_3_01_00_00\device_support\f2837xd\examples\cpu1\hrpwm_deadband_sfo_v8

    This has high resolution phase shift implementation. Note that continuously synchronizing PWMs in Phase shift mode could result in jitter.
    Hence, you can apply synchronization when there is a change in the phase shift value once and disable on further instances.
    This example has details of phase shift implementation.