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.

How to synchronize epwm1 by an outside signal

Hi everybody!

I read from the manual that all EPWM2 3 4 can be synchronized from EPWM1. And EPWM1 can be synchronized by an outside signal.

 My question is if I want to synchronize epwm1 from an outside signal how can I do that? (like configure the GPIO pin for input pulse).

Is there an project example for that from the TI control suite? Because in the example I see from the Ti control suite  it all set the phase of epwm1 to 0 and not from an outside source.

Thanks a lot for helping me.

  • Jianyang,

    You don't say which device you are using, but the information you're looking for is in the ePWM chapter of the TRM (Technical Reference Manual) for the device.  You first configure the TBCTL.bit.PHSEN=1 so that the phase load on a EPWMxSYNCI signal is enabled.  You will also need to configure the GPIO mux register to make the appropriate pin have the EPWMxSYNCI function.

    Regards,

    David

  • Hi David,

    I am using the C2000 experiment kit,f28335.

    Do i also need to write  EPwm1Regs.TBCTL.bit.SYNCOSEL = TB_SYNC_IN;

    Thanks a lot and I am looking forward to hearing from you.

    Regards,

    Jianyang

  • Hi David,

    And can you also give me the link of the ePWM chapter of TRM, thanks a lot for your help.

    Regards,

    Jianyang Liu

  • Jianyang,

    Jianyang Liu said:

    Do i also need to write  EPwm1Regs.TBCTL.bit.SYNCOSEL = TB_SYNC_IN;

     
    Yes, if you want the sync signal to ripple through to downstream modules (per Figure 2-6 in the ePWM TRM sprug04a) , you should set SYNCOSEL = TB_SYNC_IN  (00b).
     

    Jianyang Liu said:

    And can you also give me the link of the ePWM chapter of TRM, thanks a lot for your help.

     
    For the F28335, there are individual TRMs for each peripheral.  You will find them in the product folder at http://www.ti.com/product/TMS320F28335.  The direct link to the ePWM TRM is http://www.ti.com/lit/pdf/sprug04.
     
    Regards,
    David
  • Hi David,

    Thank you so much for your information. And I had go through all the ePWM of TRM. 

    But now my problem is in the ePWM of TRM it never tells you how you can configure the GPIO so you could get a synchronous pulse from outside in order to synchronize epwm1.

    Do you know how can I configure the GPIO and connect it into the epwm model, so when I generate an input *** from the GPIO pin I set, I can use it to synchronize the epwm1 model. 

     Thanks again for your help and look forward to hearing from you.

    Regards,

    Jianyang

  • Hi David:

    In other words, how can I configure the GPIO mux register to make the appropriate pin have the EPWMxSYNCI function since I have not see how can I do that in the manual.

    With Best Regards,

    Jianyang Liu

  • Hi Jianyang,

    I am assuming you are using the F28335. The configuration of the port mux register to behave as an external sync input can be found in a different TRM

    TMS320F2833x System Control and Interrupts : http://www.ti.com/lit/ug/sprufb0d/sprufb0d.pdf 

    In this on page 83/84, it talks about how to configure GPIO32 to behave as an external EPWM synch input

    Thanks and Regards

  • Hi Nishant,

    This is really helpful, thanks a lot.

    Best Regards,

    Jianyang

  • Hi Nishant,

    I have set

    GpioCtrlRegs.GPBPUD.bit.GPIO32 = 0;
    GpioCtrlRegs.GPBMUX1.bit.GPIO32 = 2; 

    So now I could give GPIO32 an input pulse, will it be served for the synchronize signal for epwm1? I see the result but the duty cycle of the pwm has not change. And here is my epwm configuration code.

    EPwm1Regs.TBCTL.bit.CTRMODE = TB_COUNT_UP; // Count up
    EPwm1Regs.TBPRD = EPWM1_TIMER_TBPRD; // Set timer period
    EPwm1Regs.TBCTL.bit.PHSEN = TB_ENABLE; // enable phase loading
    EPwm1Regs.TBCTL.bit.SYNCOSEL = TB_SYNC_IN;
    EPwm1Regs.TBPHS.half.TBPHS = 9760; // Phase is 0
    EPwm1Regs.TBCTR = 0x0000; // Clear counter
    EPwm1Regs.TBCTL.bit.HSPCLKDIV = TB_DIV2; // Clock ratio to SYSCLKOUT
    EPwm1Regs.TBCTL.bit.CLKDIV = TB_DIV2;

    // Setup shadow register load on ZERO
    EPwm1Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
    EPwm1Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
    EPwm1Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO;
    EPwm1Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO;

    // Set Compare values
    EPwm1Regs.CMPA.half.CMPA = 9760; // Set compare A value

    // Set actions
    EPwm1Regs.AQCTLA.bit.ZRO = AQ_SET; // Set PWM1A on Zero
    EPwm1Regs.AQCTLA.bit.CAU = AQ_CLEAR; // Clear PWM1A on event A, up count

     

  • Did you check the GPBPUD and GPBMUX1 registers to see that your settings were written?  If not, you likely forgot the EALLOW before you set them.

    - David

     

  • Hi David,

    This is what I have written and I think I wrote the eallow.

    void InitsynGpio(void)
    {
    EALLOW;

    GpioCtrlRegs.GPBPUD.bit.GPIO32 = 0; 
    GpioCtrlRegs.GPBMUX1.bit.GPIO32 = 2; 


    EDIS;
    }

    Regards,

    Jianyang Liu

  • Hi David,

    Problem Solved.

    Thanks a lot,

    With Best Regards,

    Jianyang Liu

  • Jianyang,

    Jianyang Liu said:

    Problem Solved.

    What was the mistake?

    - David

  • Hi David,

    I write the GPIO enable code outside the main loop, so when I check the register of GPIOMUX32 as you told, I only found a zero value. After I put it inside the main loop the value become 2 and the program works.

    Thanks again for your help.

    Regards,

    Jianyang Liu