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.

EPWM output not displaying on oscilloscope / missing SYNCOUT

Part Number: TMS320F28379D
Other Parts Discussed in Thread: C2000WARE

i am trying to synchronize two boards with one acting as master and other as slave .Below is the code for master and doesnot give any synchronize pulse out of Gpio 6.What is the problem in code

Master:

//***********Main codes in EPWM***********************

EPwm1Regs.TBCTL.bit.SYNCOSEL = TB_CTR_ZERO;  

SyncSocRegs.SYNCSELECT.bit.SYNCOUT = 0;   //EPWM1SYNCOUT

//*****************GPIO****************************

EALLOW;
// Configuring GPIO as EPWM
//PWM 1A e 1B
GpioCtrlRegs.GPAPUD.bit.GPIO6 = 0; // Enable pullup resistor

GpioCtrlRegs.GPAMUX1.bit.GPIO6 = 3; // Set GPIO6 to SYNCOUT

GpioCtrlRegs.GPADIR.bit.GPIO6 = 1; // set as output
EDIS;

  • Hi Jahangeer,

    I do not see any issues with the code you have provided.

    Do you see any output for EPWM1A and EPWM1B?

    Best Regards,

    Marlyn

  • this is epwm onfiguration

    void ConfigEPwm1(void)//q
    {
    EPwm1Regs.TBPRD = 5000; // Set timer period
    EPwm1Regs.CMPA.bit.CMPA = EPwm1Regs.TBPRD >> 1;
    EPwm1Regs.TBPHS.bit.TBPHS = 0; // Phase is 0
    EPwm1Regs.TBCTL.bit.SYNCOSEL = TB_CTR_ZERO;
    SyncSocRegs.SYNCSELECT.bit.SYNCOUT = 0; //EPWM1SYNCOUT
    EPwm1Regs.TBCTR = 0x0000; // Clear counter
    EPwm1Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN; // Count up/down
    EPwm1Regs.TBCTL.bit.PHSEN = TB_DISABLE; // Disable phase loading
    EPwm1Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1; // Clock ratio to SYSCLKOUT
    EPwm1Regs.TBCTL.bit.CLKDIV = TB_DIV1;

    EPwm1Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW; // Load registers every ZERO
    EPwm1Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO_PRD;
    EPwm1Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW; // Load registers every ZERO
    EPwm1Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO_PRD;

    EPwm1Regs.AQCTLA.bit.PRD = AQ_NO_ACTION;
    EPwm1Regs.AQCTLA.bit.ZRO = AQ_NO_ACTION;
    EPwm1Regs.AQCTLA.bit.CAU = AQ_CLEAR; // set actions for EPWM1A
    EPwm1Regs.AQCTLA.bit.CAD = AQ_SET;

    EPwm1Regs.DBCTL.bit.POLSEL = DB_ACTV_HIC; // Active Hi complementary
    EPwm1Regs.DBCTL.bit.OUT_MODE = DB_FULL_ENABLE; // enable Dead-band module
    EPwm1Regs.DBFED.bit.DBFED = 50; // FED = 20 TBCLKs
    EPwm1Regs.DBRED.bit.DBRED = 50; // RED = 20 TBCLKs


    }

  • Jahangeer,

    Have you enabled TBCLKSYNC to start the EPWM modules?

    Best Regards,

    Marlyn

  • Hi Jahangeer,

    I have copied and pasted your code and added a few things. I have gotten the ePWM1A output on my oscilloscope.

    1. In your main.c file, make sure to declare the Device_init(); before any other initialization. 

    I ran into an issue of not being able to view any PWM signals from my board because I did not have this declared.

    2. In your main GPIO configuration I added the following line.

    Device_init(); // 1.

    //***********Main codes in EPWM***********************

    EPwm1Regs.TBCTL.bit.SYNCOSEL = TB_CTR_ZERO;

    SyncSocRegs.SYNCSELECT.bit.SYNCOUT = 0; //EPWM1SYNCOUT

    //*****************GPIO****************************

    EALLOW;
    // Configuring GPIO as EPWM
    //PWM 1A e 1B
    GpioCtrlRegs.GPAPUD.bit.GPIO6 = 0; // Enable pullup resistor

    GpioCtrlRegs.GPAGMUX1.bit.GPIO6 = 0; // 2.

    GpioCtrlRegs.GPAMUX1.bit.GPIO6 = 3; // Set GPIO6 to SYNCOUT

    GpioCtrlRegs.GPADIR.bit.GPIO6 = 1; // set as output
    EDIS;

    Let me know if this solves your EPWM1A output problem first. If you are still unable to see an epwm output, could you please run an example within C2000Ware and see if that works? This will help us narrow down if it is a software issue within your application.

  • after adding the device_init() in the code i am getting this warrning 
    "this declaration has no storage class or type specifier main.c /jahangeer/src line 7 C/C++ Problem"

    epwm is giving pulse when i disable external synchronization ..but when i need to synchronize it doesnot give output

  • example given by texas works fine

  • I got that same error when I called the Device_init() function outside of my main function. Is your Device_init() declared within your main function? Also, are you including the correct headers within the main.c?

    #include "F28x_Project.h"
    #include "driverlib.h"
    #include "device.h"

  •  ;do i need to write InitEPwm1Gpio() for epwm1 just like i write for epwm 2 and epwm3

  • Correct, you can refer to the example located in <C2000Ware_Install_Path>/device_support/<device_name>/examples/cpu1/epwm_up_aq_cpu01. Are you able to view the SYNCOUT signal from the output pin?

  • I was able to replicate your configurations and have attached the code that produces an expected output. 

    Criteria:

    - 50% duty symmetric PWM from a 100 MHz time base clock, with a 10kHz PWM signal

    - Deadband delay of 500 ns

    Here are the screenshots from the oscilloscope.

    //
    // Included Files
    //
    #include "F28x_Project.h"
    #include "driverlib.h"
    #include "device.h"
    
    void init_GPIO(void);
    void ConfigEPwm1(void);
    void init_device(void);
    
    
    
    void ConfigEPwm1(void)//q
    {
        // Time Base config
        EPwm1Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1; // Clock ratio to SYSCLKOUT
        EPwm1Regs.TBCTL.bit.CLKDIV = TB_DIV1; // Scale time base clock relative to ePWM clock (TBCLK), TBCLK = 1/(100MHz) = 10 ns
        EPwm1Regs.TBPRD = 5000; // Set timer period, Freq. of pwm = 10kHz (Configure TBCTR freq or period)
        EPwm1Regs.TBPHS.bit.TBPHS = 0; // Phase is 0
        EPwm1Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN; // Set the mode for time base counter: Count up/down
        EPwm1Regs.TBCTR = 0x0000; // Clear counter
        EPwm1Regs.TBCTL.bit.PHSEN = TB_DISABLE; // Disable phase loading
        EPwm1Regs.TBCTL.bit.SYNCOSEL = TB_CTR_ZERO; // Sync output select
        SyncSocRegs.SYNCSELECT.bit.SYNCOUT = 0; //EPWM1SYNCOUT specify source for sync output of ePWM module (SYNCOUT from figure 15-7 TRM)
    
        // Counter Compare
        EPwm1Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW; // Load registers every ZERO
        EPwm1Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO_PRD;
        EPwm1Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW; // Load registers every ZERO
        EPwm1Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO_PRD;
        EPwm1Regs.CMPA.bit.CMPA = EPwm1Regs.TBPRD >> 1; // 2500
    
        // Action Qualifier sets epwm1a 1b outputs
        EPwm1Regs.AQCTLA.bit.PRD = AQ_NO_ACTION;
        EPwm1Regs.AQCTLA.bit.ZRO = AQ_NO_ACTION;
        EPwm1Regs.AQCTLA.bit.CAU = AQ_CLEAR; // set off on up count
        EPwm1Regs.AQCTLA.bit.CAD = AQ_SET; // set on down count
        // Deadband module
        EPwm1Regs.DBCTL.bit.POLSEL = DB_ACTV_HIC; // Active Hi complementary
        EPwm1Regs.DBCTL.bit.OUT_MODE = DB_FULL_ENABLE; // enable Dead-band module
        EPwm1Regs.DBFED.bit.DBFED = 50; // FED = 20 TBCLKs || 50*10 = 500 ns delay
        EPwm1Regs.DBRED.bit.DBRED = 50; // RED = 20 TBCLKs || 50*10 = 500 ns delay
    
    }
    
    void init_GPIO(void){
        EALLOW;
        // EPWM SYNCOUT signal
        GpioCtrlRegs.GPAPUD.bit.GPIO6 = 0; // pull up enabled
        GpioCtrlRegs.GPAGMUX1.bit.GPIO6 = 0; // configured mux peripheral group
        GpioCtrlRegs.GPAMUX1.bit.GPIO6 = 3; // configured mux peripheral
        GpioCtrlRegs.GPADIR.bit.GPIO6 = 1; // configured output of SYNCOUT
    
        // EPWM1A output from GPIO0
        GpioCtrlRegs.GPAPUD.bit.GPIO0 = 0; // pull up enabled
        GpioCtrlRegs.GPAGMUX1.bit.GPIO0 = 0; // configured mux peripheral group
        GpioCtrlRegs.GPAMUX1.bit.GPIO0 = 1; // configured mux peripheral
        GpioCtrlRegs.GPADIR.bit.GPIO0 = 1; // configured output of EPWM1A
    
        // EPWM1B output from GPIO1
        GpioCtrlRegs.GPAPUD.bit.GPIO1 = 0; // pull up enabled
        GpioCtrlRegs.GPAGMUX1.bit.GPIO1 = 0; // configured mux peripheral group
        GpioCtrlRegs.GPAMUX1.bit.GPIO1 = 1; // configured mux peripheral
        GpioCtrlRegs.GPADIR.bit.GPIO1 = 1; // configured output of EPWM1A
    
        EDIS;
    }
    void main(void)
    {
        Device_init();
    
        init_GPIO();
    
        ConfigEPwm1();
    
        while(1);
    }
    

  • GO OUPUT NOW do i have to simply connect the gpio6 pin to other board in which i use following code

    Slave:

    //***********Main codes in EPWM***********************

    EPwm4Regs.TBSTS.bit.SYNCI = 1;

    EPwm4Regs.TBCTL.bit.SYNCOSEL = TB_SYNC_IN; 

    SyncSocRegs.SYNCSELECT.bit.EPWM4SYNCIN = 5;    // SYNCIN Source: EXTSYNCIN1

    EPwm4Regs.TBCTL.bit.PHSEN = TB_ENABLE;

    EPwm4Regs.TBPHS.bit.TBPHS = 1;

    //*************************GPIO****************************

    InputXbarRegs.INPUT5SELECT = 0x15;  // Connect INPUT5 to GPIO15

    GpioCtrlRegs.GPAPUD.bit.GPIO15 = 0; // Enable pullup resistor

    GpioCtrlRegs.GPAMUX1.bit.GPIO15= 0; // Set GPIO15

    GpioCtrlRegs.GPADIR.bit.GPIO15 = 0; // set as input

    ====================================================

  • Jahangeer,

    I'm glad to hear you got an output. Yes, what you described is correct. Connect GPIO6 to a GPIO on your slave board and use input x-bar to route that GPIO to INPUT5. 

    If you have further questions about this, could you please open a new e2e thread regarding your new question.

    (Below are diagrams from the TRM for the TMS320F2837xD device) 

    Best Regards,

    Ryan Ma