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.

TMS320F28384S: Help Setting Up PWM Channels

Part Number: TMS320F28384S
Other Parts Discussed in Thread: C2000WARE

Hi TI Team,

I am in the process of migrating an application from a TI 28374S to a 28384S.

In the 28374S, we have all 24 EPWM1 to EPWM12 setup and working fine.

On the new 28384S with 32 PMW channels, after a few minor adjustments from the previous setup sequence, I have the first 24 channels firing fine (EPWM1A-B to EPWM12A-B) no issues with the first 24 signals.

However, I am setting up EPWM13A-B to EPWM16A-B the exact same way as the 24 that are working, but I cannot get these ones firing away.

In particular EPWM16A we are using straight out of the processor, so on my first test point with my scope I should be seen this nice and simple square wave 10kHz which I am then commanding to different duty cycles.

Questions:

Are channels EPWM13 to 16 any different that EPWM1-12? Do these need to be configured differently?

Can you provide sample code to simply configure each PWM channel to fire independently to a given duty cycle?

  • Hi Rafael,

    Are channels EPWM13 to 16 any different that EPWM1-12? Do these need to be configured differently?

    There should be no differences in these channels versus the 1-12 EPWM modules.

    Can you provide sample code to simply configure each PWM channel to fire independently to a given duty cycle?

    We do have some examples within C2000Ware that I suggest you try, just to ensure you can get an output on EPWM13 to 16. Simply change the EPWM base of any of the examples to be either EPWM 13, 14, 15, or 16. Please let me know if this still does not work and I will test it on hardware myself.

    C:\ti\c2000\C2000Ware_version\driverlib\f2838x\examples\c28x\epwm 

    Best Regards,

    Marlyn

  • Hi Marlyn,

    Thank you for the answers to my questions and pointing out to the sample code.  Unfortunately I still need help to understand what am I doing wrong.

    I modified my code to use TIs example code on my board.  This is the code I am using to initialize the EPWM devices, basically lifted from the epwm_ex11_configure_signal.c file.

    volatile uint16_dtc debugPeriodReadback[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
    
    
    EPWM_SignalParams pwmSignal =
                {20000, 0.5f, 0.5f, true, DEVICE_SYSCLK_FREQ, SYSCTL_EPWMCLK_DIV_1,
                EPWM_COUNTER_MODE_UP_DOWN, EPWM_CLOCK_DIVIDER_1,
                EPWM_HSCLOCK_DIVIDER_1};
    
    void myEpwmInitFunction()
    {
        // setup all EMPWM pins
        EALLOW;
        GPIO_setPinConfig(GPIO_0_EPWM1A);
        GPIO_setPinConfig(GPIO_1_EPWM1B);
        GPIO_setPinConfig(GPIO_2_EPWM2A);
        GPIO_setPinConfig(GPIO_3_EPWM2B);
        GPIO_setPinConfig(GPIO_4_EPWM3A);
        GPIO_setPinConfig(GPIO_5_EPWM3B);
        GPIO_setPinConfig(GPIO_151_EPWM4A);
        GPIO_setPinConfig(GPIO_152_EPWM4B);
        GPIO_setPinConfig(GPIO_153_EPWM5A);
        GPIO_setPinConfig(GPIO_154_EPWM5B);
        GPIO_setPinConfig(GPIO_155_EPWM6A);
        GPIO_setPinConfig(GPIO_156_EPWM6B);
        GPIO_setPinConfig(GPIO_157_EPWM7A);
        GPIO_setPinConfig(GPIO_158_EPWM7B);
        GPIO_setPinConfig(GPIO_159_EPWM8A);
        GPIO_setPinConfig(GPIO_160_EPWM8B);
        GPIO_setPinConfig(GPIO_161_EPWM9A);
        GPIO_setPinConfig(GPIO_162_EPWM9B);
        GPIO_setPinConfig(GPIO_18_EPWM10A);
        GPIO_setPinConfig(GPIO_19_EPWM10B);
        GPIO_setPinConfig(GPIO_20_EPWM11A);
        GPIO_setPinConfig(GPIO_21_EPWM11B);
        GPIO_setPinConfig(GPIO_167_EPWM12A);
        GPIO_setPinConfig(GPIO_168_EPWM12B);
        GPIO_setPinConfig(GPIO_137_EPWM13A);
        GPIO_setPinConfig(GPIO_138_EPWM13B);
        GPIO_setPinConfig(GPIO_139_EPWM14A);
        GPIO_setPinConfig(GPIO_140_EPWM14B);
        GPIO_setPinConfig(GPIO_141_EPWM15A);
        GPIO_setPinConfig(GPIO_142_EPWM15B);
        GPIO_setPinConfig(GPIO_143_EPWM16A);
        GPIO_setPinConfig(GPIO_144_EPWM16B);
        EDIS;
    
        // Disable sync(Freeze clock to PWM as well)
        SysCtl_disablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
     
        EPWM_configureSignal(EPWM1_BASE, &pwmSignal);
        EPWM_disablePhaseShiftLoad(EPWM1_BASE);
        EPWM_setPhaseShift(EPWM1_BASE, 0U);
        EPWM_enableSyncOutPulseSource(EPWM1_BASE, EPWM_SYNC_OUT_PULSE_ON_CNTR_ZERO);
        debugPeriodReadback[0] = EPWM_getTimeBasePeriod(EPWM1_BASE);  // For my debug
    
        EPWM_configureSignal(EPWM2_BASE, &pwmSignal);
        EPWM_disablePhaseShiftLoad(EPWM2_BASE);
        EPWM_setPhaseShift(EPWM2_BASE, 0U);
        EPWM_setSyncInPulseSource(EPWM2_BASE, EPWM_SYNC_IN_PULSE_SRC_SYNCOUT_EPWM1);
        debugPeriodReadback[1] = EPWM_getTimeBasePeriod(EPWM2_BASE);    // For my debug
    
        // ... here I repeat the same set of lines for EPWM3 to 16
        
        //Re-enable Peripheral Clock
        SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
    }
    
    

    I have a 1Hz loop taking a global duty cycle value that I set from the debugger window to values from 0 to 100% commanding the desired DC on every channel.

    However, using TI sample code I get the exact same behavior as with my original code.  EPWM 1A-B to 12A-B, fire without issues (duty cycle and frequency are fine) but no activity whatsoever on EMPW 13-16.

    Here is a scope image where I capture EPWM 1A (same for 2 to 12 A-B sides) output (blue line) at 50% DC and 20kHz frequency, while EPWM16A (Same for EPWM 13 to 16) is connected to the red line below flat at 0%.

    As much as I would like to blame the issue on our new board and ask our EE guys to go chase it down, I see something odd as I debug the application.

    When I go through the configuration block for each channel I read back the period setting into my debugPeriodReadback variable.  The period reads back fine for EPMW 1-12 but for 13-16 is all 0s.  Inspecting the register memory space also confirms that 1-12 have some registers with values other than 0s, while EPWM 13-16 show nothing but 0s.

    EPWM_configureSignal(EPWM12_BASE, &pwmSignal);
    EPWM_disablePhaseShiftLoad(EPWM12_BASE);
    EPWM_setPhaseShift(EPWM12_BASE, 0U);
    EPWM_setSyncInPulseSource(EPWM12_BASE, EPWM_SYNC_IN_PULSE_SRC_SYNCOUT_EPWM1);
    debugPeriodReadback[11] = EPWM_getTimeBasePeriod(EPWM12_BASE);   // this one reads fine

    EPWM_configureSignal(EPWM13_BASE, &pwmSignal);
    EPWM_disablePhaseShiftLoad(EPWM13_BASE);
    EPWM_setPhaseShift(EPWM13_BASE, 0U);
    EPWM_setSyncInPulseSource(EPWM13_BASE, EPWM_SYNC_IN_PULSE_SRC_SYNCOUT_EPWM1);
    debugPeriodReadback[12] = EPWM_getTimeBasePeriod(EPWM13_BASE); // this all the way down to EPWM16A reads 0s.

    Inspecting the EPWM control registers memory I see EPMW1-12 have a handful of registers that are not 0s, while configuration registers associated with 13-16 are all 0s.

      

    Please let me know if you have any questions, or if there is additional information you may need to help me resolve this issue.

    Thank you.

    Rafael

  • Hi Rafael,

    Thank you so much for your detailed check. Let me check on my side now, I'll run the same code on my device and see if I run into the same issues. I will provide a response tomorrow. 

    Best Regards,

    Marlyn

  • Hi Rafael,

    I was not able to acquire the correct hardware today to test this, but will try to find the right one tomorrow. I will keep you posted.

    Best Regards,

    Marlyn

  • Hi Marlyn,

    Thanks for keeping me updated on the progress on this.  It is a hot subject at the office, as we find ourselves in the middle of a design transition from one board revision using 28374S to the next using 28384S.  We only have a few of the old boards available, and finalizing the validation of this one is holding the ordering of new ones.

    I am very interested in knowing if you get the same issue after calling the configuration on EPWM 13 - 16 where the configuration/control registers are all 0.

    Next I will try to create a new empty project for this new processor and only add the minimum code to configure and set the PWMs. I do not know if I have a mixture of old and new processor libraries or files that is causing the issue.

    Thank you.

    Rafael

  • Hi Marlyn,

    This has been resolved.

    The issue was in the basics, I forgot to add the calls to enable the new peripherals. (DUH!)

    SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_EPWM13);
    SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_EPWM14);
    SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_EPWM15);
    SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_EPWM16);

    Added those lines to my initialization function and EPWM13-16 are working fine now.

    Thanks for the help so far.