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.

TMS320F28377S: synchronised ePWM should extend to HRPWM

Part Number: TMS320F28377S
Other Parts Discussed in Thread: C2000WARE

Hi,

I have already working 3x ePWM driver for PMSM, as described here:

https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/815681/tms320f28377s-up-down-pwm-with-phase-control---result-is-oposite-to-expetations

I use driverlib functions for configuration and Control of 3 synchronised ePWM.

With 200MHz clock and 40kHz PWM the resulting resolution of PWM is about 10bit. It is insufficient for precision driving in low duty cycle.

How can I easily extend existing code with HRPWM. C2000Ware 3.04 example "hrpwm_duty_sfo_v8" seems to be not enough to explain it.

How often should I call SFO() function? Does it dusrupt ongoing PWM? Which Registers are updated from SFO()?

Kind regards

  • You can call the SFO function in your LOWEST priority background task. It is not necessary to call it frequently unless you have drastic fast changes in temperature.

    It does not interrupt on going PWM.

    The SFO updates HRMSTEP. And some other internal registers that you should never use in application code and most likely are not using if coding in driverlib.

    Nima

  • My SFO() seems to work partially only.

    Printed out return SFO() value  (0x40 for example) matches HRMSTEP from EPWM1Regs (Debugger) but the others EPWM2 and EPWM3 registry are not written. Their HRMSTEP stay 0.

    My *.cpp Code:

    #include "SFO_V8.h"

    //SFO:

    extern "C" {

    extern uint32_t MEP_ScaleFactor = 0; // Global variable used by the SFO library

    #define myEPWM1_BASE EPWM1_BASE

    #define myEPWM2_BASE EPWM2_BASE

    #define myEPWM3_BASE EPWM3_BASE

    //#define myEPWM4_BASE EPWM4_BASE

    extern volatile uint32_t ePWM[16+1] = { 0, myEPWM1_BASE, myEPWM2_BASE, myEPWM3_BASE };

    } //extern "C"

     

    … and later call:

    SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_EPWM1);

    SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_EPWM2);

    SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_EPWM3);

    SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_HRPWM); //sourced from ePWM1 clock source

    uint16_t status = SFO_INCOMPLETE;

    while (status== SFO_INCOMPLETE) // Call until complete

    {

    status = SFO();

    if (status == SFO_ERROR)

    {

    ESTOP0; // SFO function returns 2 if an error occurs & # of MEP steps/coarse step

    } // exceeds maximum of 255.

    }

     debugprintf("MEP_ScaleFactor %lu\r\n", MEP_ScaleFactor);

     

    ----

    Moreover,

    HRMSTEP from EPWM1 can be overwritten from Debugger but HRMSTEP from higher EPWMs can not.

  • What you are observing is correct. SFO only writes to EPWM1. The value for calibration is ONLY in EPWM1 regs. ALL OTHER EPWMs use EPWM1.

    You should be good to move forward.

    Nima