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 & eCap synchronize problem

Other Parts Discussed in Thread: CONTROLSUITE

Hi, I used F28069.

Because I have read the "http://www.ti.com/lit/ug/spruh18e/spruh18e.pdf" P.255

eCAP1 can synchronize to PWM1.

If this step is success. I think I can see the wavefrom in eCap pin (GPIO05) or PWMSYNCO pin (GPIO33).

Here's my code.

void InitEPwm1Example()
{

EALLOW;
SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 0;
EDIS;

// Setup TBCLK
EPwm1Regs.TBPRD = EPWM1_TIMER_TBPRD; // Set timer period 801 TBCLKs
EPwm1Regs.TBPHS.half.TBPHS = 0x0000; // Phase is 0
EPwm1Regs.TBCTR = 0x0000; // Clear counter

// Set Compare values
EPwm1Regs.CMPA.half.CMPA = EPWM1_MIN_CMPA; // Set compare A value
EPwm1Regs.CMPB = EPWM1_MAX_CMPB; // Set Compare B value

// Setup counter mode
EPwm1Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN; // Count up
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.TBCTL.bit.PHSDIR = 1;
EPwm1Regs.TBCTL.bit.PRDLD = TB_SHADOW;
EPwm1Regs.TBCTL.bit.SYNCOSEL = TB_CTR_ZERO;

// EPwm1Regs.TBSTS.bit.CTRMAX = 0;
EPwm1Regs.TBSTS.bit.SYNCI = 0;

// Setup shadowing
EPwm1Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
EPwm1Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
EPwm1Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO; // Load on Zero
EPwm1Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO;

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

EPwm1Regs.AQCTLB.bit.CBU = AQ_SET; // Set PWM1B on event B, up count
EPwm1Regs.AQCTLB.bit.CBD = AQ_CLEAR; // Clear PWM1B on event B, down count

EALLOW;
SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 1;
EDIS;

}

//////////////////////////////////////////////////////////////////////////

ECap1Regs.ECCTL2.bit.SYNCI_EN = 1;

//////////////////////////////////////////////////////////////////////////

Where I miss?

Can any help me?

Thanks

  • Chi Min Tseng,

    I am looking into your inquiry right now. I will get back to you as soon as I have a chance to run your code. Thanks,

    Kris
  • Chi Min Tseng,

    Setting the SYNCI_EN bit is simply setting the eCAP to load a value from the phase register to the counter register on a SYNC event. You still need to perform additional configurations in the eCAP to put it in APWM mode, set the period and compare values, etc. Please view section 6.3 of the F28069 Technical Reference Manual for more information.

    Thanks,

    Kris
  • Hi, Kirs. Thanks you reply.

    I fallow you comment. It's work.

    Here's the code
    ////////////////////////////////////////////////
    EALLOW;

    ECap1Regs.ECCTL2.bit.CAP_APWM = 1; // Enable APWM mode
    ECap1Regs.ECCTL2.bit.APWMPOL = 0; //Force active high (0 = high, 1 = low)
    ECap1Regs.ECCTL2.bit.SWSYNC = 1;
    ECap1Regs.ECCTL2.bit.SYNCO_SEL = 0;
    ECap1Regs.ECCTL2.bit.SYNCI_EN = 1;
    ECap1Regs.TSCTR = 0;
    ECap1Regs.CAP1 = 45000;
    ECap1Regs.CAP2 = 30000;

    ECap1Regs.ECCTL2.bit.TSCTRSTOP = 1;
    EDIS;
    ////////////////////////////////////////////////
    But it isn't I want.

    I don't know if I have the wrong idea let make you misunderstanding.

    Because my original idea is make the PWM1 action and as a SYNCI signal for eCap1. They are the same two waveforms even PWMSYNCO pin (GPIO33) is.

    Now, I can't see any signal in PWMSYNCO pin (GPIO33).
    Is my idea wrong?

    And another problem, PWMSYNCO pin (GPIO33) is not the same as the PWMSYNCO in "http://www.ti.com/lit/ug/spruh18e/spruh18e.pdf" P.255 ?
  • Hi,

    Based on my understanding of your post, you are looking to synch ePWM1 with eCAP1 (in APWM mode).

    I would recommend first focusing on getting ePWM1's PWMSYNCO pulse show up on GPIO33. Since you are not seeing anything on this pin we can tell that either something is wrong with the ePWM configuration or the GPIO configuration. Based on a quick look at the ePWM code you posted, I do not see anything incorrect.

    I have a few questions:
    1) Can you generate a waveform on ePWM1A @ GPIO00? This would confirm that the PWM itself is behaving correctly.
    2) Have you configured GPIO33 as PWMSYNCO (peripheral selection 2 or GPBMUX1 = 2)


    Thank you,
    Brett

  • Answer the question 1 & 2
    Yes. I can see waveform in PWM1A(GPIO00) but PWMSYNCO(GPIO33) can't see anything.
    Here's the code. (This code is ti provide in C:\ti\controlSUITE\device_support\f2806x\v140\F2806x_common\source\F2806x_EPwm.c)

    void InitEPwm1Gpio(void)
    {
    EALLOW;

    /* Disable internal pull-up for the selected output pins
    for reduced power consumption */
    // Pull-ups can be enabled or disabled by the user.
    // Comment out other unwanted lines.

    GpioCtrlRegs.GPAPUD.bit.GPIO0 = 1; // Disable pull-up on GPIO0 (EPWM1A)
    GpioCtrlRegs.GPAPUD.bit.GPIO1 = 1; // Disable pull-up on GPIO1 (EPWM1B)

    /* Configure EPWM-1 pins using GPIO regs*/
    // This specifies which of the possible GPIO pins will be EPWM1 functional pins.
    // Comment out other unwanted lines.

    GpioCtrlRegs.GPAMUX1.bit.GPIO0 = 1; // Configure GPIO0 as EPWM1A
    GpioCtrlRegs.GPAMUX1.bit.GPIO1 = 1; // Configure GPIO1 as EPWM1B

    EDIS;
    }
    #endif // endif DSP28_EPWM1
    /////////////////////////////////////////////////////////////////////////////////////
    void InitEPwmSyncGpio(void)
    {
    EALLOW;

    /* Configure EPWMSYNCI */

    /* Enable internal pull-up for the selected pins */
    // Pull-ups can be enabled or disabled by the user.
    // This will enable the pullups for the specified pins.
    // Comment out other unwanted lines.

    // GpioCtrlRegs.GPAPUD.bit.GPIO6 = 0; // Enable pull-up on GPIO6 (EPWMSYNCI)
    GpioCtrlRegs.GPBPUD.bit.GPIO32 = 0; // Enable pull-up on GPIO32 (EPWMSYNCI)

    /* Set qualification for selected pins to asynch only */
    // This will select synch to SYSCLKOUT for the selected pins.
    // Comment out other unwanted lines.

    // GpioCtrlRegs.GPAQSEL1.bit.GPIO6 = 0; // Synch to SYSCLKOUT GPIO6 (EPWMSYNCI)
    GpioCtrlRegs.GPBQSEL1.bit.GPIO32 = 0; // Synch to SYSCLKOUT GPIO32 (EPWMSYNCI)

    /* Configure EPwmSync pins using GPIO regs*/
    // This specifies which of the possible GPIO pins will be EPwmSync functional pins.
    // Comment out other unwanted lines.

    // GpioCtrlRegs.GPAMUX1.bit.GPIO6 = 2; // Configures GPIO6 for EPWMSYNCI operation
    GpioCtrlRegs.GPBMUX1.bit.GPIO32 = 2; // Configures GPIO32 for EPWMSYNCI operation.

    /* Configure EPWMSYNC0 */

    /* Disable internal pull-up for the selected output pins
    for reduced power consumption */
    // Pull-ups can be enabled or disabled by the user.
    // Comment out other unwanted lines.

    // GpioCtrlRegs.GPAPUD.bit.GPIO6 = 1; // Disable pull-up on GPIO6 (EPWMSYNCO)
    GpioCtrlRegs.GPBPUD.bit.GPIO33 = 1; // Disable pull-up on GPIO33 (EPWMSYNCO)

    // GpioCtrlRegs.GPAMUX1.bit.GPIO6 = 3; // Configures GPIO6 for EPWMSYNCO
    GpioCtrlRegs.GPBMUX1.bit.GPIO33 = 2; // Configures GPIO33 for EPWMSYNCO

    EDIS;
    }
  • Hi Chi Min Tseng,

    I just tried to do something similar to what you want on my computer. I was able to see the PWMSYNCO output on GPIO33. I will list what I did so that you can duplicate if you wish.

    Using v136 of the F2806x device_support package, I imported the epwm_updown_aq example into CCS.
    \controlSUITE\device_support\f2806x\v136\F2806x_examples_ccsv5\epwm_updown_aq\

    I then made a few changes to the code:
    1) In the Example_2806xEPwmUpDownAQ.c file, I added the InitEPwmSyncGpio(); function to line 139 of main().

    2) In the Example_2806xEPwmUpDownAQ.c file, I added the following line to line 223 in the InitEPwm1Example function:
    EPwm1Regs.TBCTL.bit.SYNCOSEL = TB_CTR_ZERO;

    3) In the F2806x_EPwm.c file, I uncommented the EALLOW; on line 279 and added an EDIS; to the end of the function (line 318).

    After this I was able to see a pulse on GPIO33 which corresponded to the PWMSYNCO signal.


    Thank you,
    Brett