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.

LAUNCHXL-F28379D: HRPWM phase shift using sysconfig

Part Number: LAUNCHXL-F28379D
Other Parts Discussed in Thread: SYSCONFIG, C2000WARE

Hi,

I'm using SysConfig 1.14.0 and CCS 12.1.0.00007 to define a project for a launchxl-F28379D.

It mostly works well, but I noticed that phase shift between ePWM modules doesn't work where HRPWM is configured.

The regular phase shift settings works well, and after enabling HRPWM I'm getting ~3-4us phase shift regardless of the defined phase shift value.

how can I define it correcly?

thanks,

Oren

  • Hi Oren,

    Could you upload your sysconfig file?

    Best,

    Ryan Ma

  • Hi Oren,

    I was able to use SysConfig and apply a phase shift with HR support enabled.

    EPWM1 is a 1Mhz signal, with AQ events happening at period and CMPA.

    When period CMPA toggles high, and when CMPA event occurs AQ event toggles low.

    EPWM2 is also a 1 Mhz signal, with a phase shift of 180 degrees from EPWM1.

    Both have HRPWM enabled.

    Here are the output signals and the sysconfig file:

    Channel 3 is the EXTSYNCOUT event coming from a gpio using an Output XBAR.

    Channel 1 is EPWM1, Channel 2 is EPWM2.

     https://e2e.ti.com/cfs-file/__key/communityserver-discussions-components-files/171/3426.c2000.syscfg

  • Hi,

    thanks for helping. I can't open the attached "c2000.syscfg" as you used an older version of C2000WARE. There is a prompt when I try to open it:

    I'm using 4.02.00.00. 

    I tried to import the file into an empty project in CCS, but there are build errors.

    can you please make a version for C2000WARE 4.02.00.00, and a phase shift that is not 180 degrees? for example, ~100 degrees.

    Thanks!

  • Hi Oren,

    Could you try to see if you can open this SysCfg file? It should be with C2000WARE 4.02.00.00.

    https://e2e.ti.com/cfs-file/__key/communityserver-discussions-components-files/171/5226.c2000.syscfg

    Best,

    Ryan Ma

  • Hi Ryan,

    I copied your settings into my project and it doesn't work. did you try running this on the same software versions I have?

    all the settings are set well, but for some reason the even the regular phase shift stops to work when I enable HRPWM phase shift.

    any suggestions?

    Thanks!

  • Is it an option to set up a simple example project that demonstrates HRPWM using sysConfig? 

  • Hi Oren, 

    I had configured my PWM without HRPWM support first. Once I had set up your sync scheme and included phase shift within the respective pwm time base module, I enabled HRPWM support. Tested this, and the phase shift was applied.

    Yeah, I made sure to run on same softwre version you have. Could you send me your syscfg file?

  • /**
     * These arguments were used when this file was generated. They will be automatically applied on subsequent loads
     * via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments.
     * @cliArgs --board "/boards/LAUNCHXL_F28379D" --context "CPU1" --product "C2000WARE@4.02.00.00"
     * @versions {"tool":"1.14.0+2667"}
     */
    
    /**
     * Import the modules used in this configuration.
     */
    const epwm  = scripting.addModule("/driverlib/epwm.js");
    const epwm1 = epwm.addInstance();
    const epwm2 = epwm.addInstance();
    
    /**
     * Write custom configuration values to the imported modules.
     */
    epwm.generateInitFunctions = true;
    epwm.enableWarning         = true;
    epwm.enableInfo            = true;
    
    epwm1.$name                                                      = "Reset1";
    epwm1.$hardware                                                  = system.deviceData.board.components.BP_SITE_1.subComponents.PWM_LOC1;
    epwm1.epwmTimebase_emulationMode                                 = "EPWM_EMULATION_FREE_RUN";
    epwm1.epwmTimebase_hsClockDiv                                    = "EPWM_HSCLOCK_DIVIDER_1";
    epwm1.epwmTimebase_period                                        = 1999;
    epwm1.epwmTimebase_counterMode                                   = "EPWM_COUNTER_MODE_DOWN";
    epwm1.epwmTimebase_syncOutPulseMode                              = "EPWM_SYNC_OUT_PULSE_ON_COUNTER_ZERO";
    epwm1.epwmCounterCompare_cmpA                                    = 200;
    epwm1.epwmCounterCompare_shadowLoadModeCMPA                      = "EPWM_COMP_LOAD_ON_CNTR_PERIOD";
    epwm1.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_ZERO      = "EPWM_AQ_OUTPUT_LOW";
    epwm1.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_DOWN_CMPA = "EPWM_AQ_OUTPUT_HIGH";
    epwm1.epwmEventTrigger_enableInterrupt                           = true;
    epwm1.epwmEventTrigger_interruptSource                           = "EPWM_INT_TBCTR_PERIOD";
    epwm1.epwmEventTrigger_EPWM_SOC_B_triggerEnable                  = true;
    epwm1.epwmEventTrigger_EPWM_SOC_B_triggerSource                  = "EPWM_SOC_TBCTR_D_CMPB";
    epwm1.epwmEventTrigger_EPWM_SOC_B_triggerEventPrescalar          = "1";
    epwm1.epwmEventTrigger_EPWM_SOC_B_triggerEventCountInitEnable    = true;
    epwm1.epwmEventTrigger_interruptEventCount                       = "1";
    epwm1.hrpwm_controlModeA                                         = "HRPWM_MEP_PHASE_CTRL";
    epwm1.hrpwm_enable                                               = true;
    epwm1.hrpwm_autoConv                                             = true;
    epwm1.hrpwm_controlModeB                                         = "HRPWM_MEP_PHASE_CTRL";
    
    epwm2.$name                                                      = "Reset2";
    epwm2.$hardware                                                  = system.deviceData.board.components.BP_SITE_1.subComponents.PWM_LOC2;
    epwm2.epwmTimebase_emulationMode                                 = "EPWM_EMULATION_FREE_RUN";
    epwm2.epwmTimebase_hsClockDiv                                    = "EPWM_HSCLOCK_DIVIDER_1";
    epwm2.epwmTimebase_period                                        = 1999;
    epwm2.epwmTimebase_counterMode                                   = "EPWM_COUNTER_MODE_DOWN";
    epwm2.epwmTimebase_syncOutPulseMode                              = "EPWM_SYNC_OUT_PULSE_ON_EPWMxSYNCIN";
    epwm2.epwmCounterCompare_cmpA                                    = 200;
    epwm2.epwmCounterCompare_shadowLoadModeCMPA                      = "EPWM_COMP_LOAD_ON_CNTR_PERIOD";
    epwm2.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_ZERO      = "EPWM_AQ_OUTPUT_LOW";
    epwm2.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_DOWN_CMPA = "EPWM_AQ_OUTPUT_HIGH";
    epwm2.epwmEventTrigger_enableInterrupt                           = true;
    epwm2.epwmEventTrigger_interruptSource                           = "EPWM_INT_TBCTR_PERIOD";
    epwm2.epwmTimebase_phaseEnable                                   = true;
    epwm2.epwmDeadband_deadbandCounterClockRate                      = "EPWM_DB_COUNTER_CLOCK_HALF_CYCLE";
    epwm2.hrpwm_controlModeA                                         = "HRPWM_MEP_PHASE_CTRL";
    epwm2.epwmEventTrigger_EPWM_SOC_B_triggerEnable                  = true;
    epwm2.epwmEventTrigger_EPWM_SOC_B_triggerSource                  = "EPWM_SOC_TBCTR_D_CMPB";
    epwm2.epwmEventTrigger_EPWM_SOC_B_triggerEventPrescalar          = "1";
    epwm2.epwmEventTrigger_interruptEventCount                       = "15";
    epwm2.hrpwm_enable                                               = true;
    epwm2.hrpwm_autoConv                                             = true;
    epwm2.hrpwm_phaseLoadEnable                                      = true;
    epwm2.hrpwm_controlModeB                                         = "HRPWM_MEP_PHASE_CTRL";
    
    /**
     * Pinmux solution for unlocked pins/peripherals. This ensures that minor changes to the automatic solver in a future
     * version of the tool will not impact the pinmux you originally saw.  These lines can be completely deleted in order to
     * re-solve from scratch.
     */
    epwm1.epwm.$suggestSolution          = "EPWM1";
    epwm1.epwm.epwmaPin.$suggestSolution = "boosterpack1.40";
    epwm1.epwm.epwmbPin.$suggestSolution = "boosterpack1.39";
    epwm2.epwm.$suggestSolution          = "EPWM2";
    epwm2.epwm.epwmaPin.$suggestSolution = "boosterpack1.38";
    epwm2.epwm.epwmbPin.$suggestSolution = "boosterpack1.37";
    

    attached. I've changed the file extension from syscfg to txt because the upload doesn't work for syscfg for some reason. 

  • Hey Oren,

    I was able to import your syscfg into a project. Just so we can start from a common ground, I turned off HRPWM and viewed the waveforms on EPWM1A and EPWM2A.

    1. Disabled HRPWM support, I am getting a 50kHz signal, with them being in sync.

    2. Now I enabled HRPWM and view this. They seem to no longer be in sync

    Let me get back to you on why this is.

    Best regards,

    Ryan Ma

  • Hi Oren,

    I believe I have found the cause of this issue. We will take care of this within SysConfig for the upcoming releases once we verify this. But what seems to be happening is when you enable HR support within SysConfig, SysConfig replaces this function 

    EPWM_enablePhaseShiftLoad(Reset2_BASE);
    with 
    HRPWM_enablePhaseShiftLoad(Reset2_BASE);
    However according to our TRM we have to set both TBPHSHRLOADE and PHSEN to be 1. 
    So in order to fix this issue, make sure to call both of these functions to enable synchronization.
    Here is my syscfg file that uses your same settings, just in case you wanted to use it as reference for any checking. However please note that this is for the controlCARD.
    /**
     * These arguments were used when this file was generated. They will be automatically applied on subsequent loads
     * via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments.
     * @cliArgs --board "/boards/TMDSCNCD28379D" --context "CPU1" --product "C2000WARE@4.02.00.00"
     * @versions {"tool":"1.14.0+2667"}
     */
    
    /**
     * Import the modules used in this configuration.
     */
    const epwm  = scripting.addModule("/driverlib/epwm.js");
    const epwm1 = epwm.addInstance();
    const epwm2 = epwm.addInstance();
    
    /**
     * Write custom configuration values to the imported modules.
     */
    epwm.generateInitFunctions = true;
    epwm.enableWarning         = true;
    epwm.enableInfo            = true;
    
    epwm1.$name                                                      = "Reset1";
    epwm1.epwmTimebase_emulationMode                                 = "EPWM_EMULATION_FREE_RUN";
    epwm1.epwmTimebase_hsClockDiv                                    = "EPWM_HSCLOCK_DIVIDER_1";
    epwm1.epwmTimebase_counterMode                                   = "EPWM_COUNTER_MODE_DOWN";
    epwm1.epwmTimebase_syncOutPulseMode                              = "EPWM_SYNC_OUT_PULSE_ON_COUNTER_ZERO";
    epwm1.epwmCounterCompare_cmpA                                    = 200;
    epwm1.epwmCounterCompare_shadowLoadModeCMPA                      = "EPWM_COMP_LOAD_ON_CNTR_PERIOD";
    epwm1.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_ZERO      = "EPWM_AQ_OUTPUT_LOW";
    epwm1.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_DOWN_CMPA = "EPWM_AQ_OUTPUT_HIGH";
    epwm1.epwmEventTrigger_enableInterrupt                           = true;
    epwm1.epwmEventTrigger_interruptSource                           = "EPWM_INT_TBCTR_PERIOD";
    epwm1.epwmEventTrigger_EPWM_SOC_B_triggerEnable                  = true;
    epwm1.epwmEventTrigger_EPWM_SOC_B_triggerSource                  = "EPWM_SOC_TBCTR_D_CMPB";
    epwm1.epwmEventTrigger_EPWM_SOC_B_triggerEventPrescalar          = "1";
    epwm1.epwmEventTrigger_EPWM_SOC_B_triggerEventCountInitEnable    = true;
    epwm1.epwmEventTrigger_interruptEventCount                       = "1";
    epwm1.hrpwm_controlModeA                                         = "HRPWM_MEP_PHASE_CTRL";
    epwm1.hrpwm_controlModeB                                         = "HRPWM_MEP_PHASE_CTRL";
    epwm1.epwmTimebase_period                                        = 1999;
    epwm1.hrpwm_period                                               = 1999;
    epwm1.hrpwm_duty                                                 = 10;
    epwm1.hrpwm_enable                                               = true;
    epwm1.epwm.$assign                                               = "EPWM1";
    
    epwm2.$name                                                      = "Reset2";
    epwm2.epwmTimebase_emulationMode                                 = "EPWM_EMULATION_FREE_RUN";
    epwm2.epwmTimebase_hsClockDiv                                    = "EPWM_HSCLOCK_DIVIDER_1";
    epwm2.epwmTimebase_counterMode                                   = "EPWM_COUNTER_MODE_DOWN";
    epwm2.epwmTimebase_syncOutPulseMode                              = "EPWM_SYNC_OUT_PULSE_ON_EPWMxSYNCIN";
    epwm2.epwmCounterCompare_cmpA                                    = 200;
    epwm2.epwmCounterCompare_shadowLoadModeCMPA                      = "EPWM_COMP_LOAD_ON_CNTR_PERIOD";
    epwm2.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_ZERO      = "EPWM_AQ_OUTPUT_LOW";
    epwm2.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_DOWN_CMPA = "EPWM_AQ_OUTPUT_HIGH";
    epwm2.epwmEventTrigger_enableInterrupt                           = true;
    epwm2.epwmEventTrigger_interruptSource                           = "EPWM_INT_TBCTR_PERIOD";
    epwm2.epwmDeadband_deadbandCounterClockRate                      = "EPWM_DB_COUNTER_CLOCK_HALF_CYCLE";
    epwm2.epwmEventTrigger_EPWM_SOC_B_triggerEnable                  = true;
    epwm2.epwmEventTrigger_EPWM_SOC_B_triggerSource                  = "EPWM_SOC_TBCTR_D_CMPB";
    epwm2.epwmEventTrigger_EPWM_SOC_B_triggerEventPrescalar          = "1";
    epwm2.epwmEventTrigger_interruptEventCount                       = "15";
    epwm2.epwmTimebase_phaseEnable                                   = true;
    epwm2.hrpwm_controlModeA                                         = "HRPWM_MEP_PHASE_CTRL";
    epwm2.hrpwm_controlModeB                                         = "HRPWM_MEP_PHASE_CTRL";
    epwm2.hrpwm_phaseLoadEnable                                      = true;
    epwm2.epwmTimebase_period                                        = 1999;
    epwm2.hrpwm_duty                                                 = 10;
    epwm2.hrpwm_period                                               = 20000;
    epwm2.hrpwm_enable                                               = true;
    
    /**
     * Pinmux solution for unlocked pins/peripherals. This ensures that minor changes to the automatic solver in a future
     * version of the tool will not impact the pinmux you originally saw.  These lines can be completely deleted in order to
     * re-solve from scratch.
     */
    epwm1.epwm.epwmaPin.$suggestSolution = "hsecDigital.49";
    epwm1.epwm.epwmbPin.$suggestSolution = "hsecDigital.51";
    epwm2.epwm.$suggestSolution          = "EPWM2";
    epwm2.epwm.epwmaPin.$suggestSolution = "hsecDigital.53";
    epwm2.epwm.epwmbPin.$suggestSolution = "hsecDigital.55";
    
    Best,
    Ryan Ma
  • Hi Ryan,

    Thanks for debugging the issue.

    In addition to your answer above, please note that the EDGEMODE bits are set to 00. In order to implement HR phase shift these bits should be 11.

    Thanks!

  • No problem! 

    Best,

    Ryan Ma

  • Hi Ryan,

    The solution work in terms of high-resolution phase shift. However, there is a jitter in obtained period.

    can you see it in your device?

    thanks,

    Oren

  • Hi Oren,

    According to our TRM an EPWMxSYNC pulse will introduce +/- 1 - 2 cycle jitter to the PWM (+/- 1 cycle in up-count mode and +/- 2 cycle in up-down count mode). Is this what you are seeing?