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.

TMS320F280049C: ePWM Syncing

Part Number: TMS320F280049C

Hi

I was wondering if it is possible to sync one ePWM module based on the action of another ePWM (NOT based on phase control register or ePWMxSYNC signals). For example, when ePWM1A goes LO, set ePWM2A HI. Reason being - ePWM1 is the master and its configuration changes cyclically, both A and B are used with active high complementary, and gets terminated by a external signal similar to peak current mode control. Then I have ePWM2 that I want to be synched to when ePWM1 is terminated. I can't just use ePWM1 period to generate SYNC signals on ZERO, CMPB, etc, since the termination time is not predefined internally.

I could just replicate the configuration within ePWM2, but I am hoping there is an easier way to do it, since the setup of ePWM1 uses a lot of peripherals, and would create a lot of duplication I am hoping to avoid.

Thanks

EPWMxSYNC

  • Unfortunately from my understanding of your question, we don't have this built into the hardware but as far as software you can easily avoid having duplicate code when using both drivelib and bitfields.

    The places in your code where you need to duplicate the configurations for both EPWM1 and EPWM2, you can write functions that look like this:

    void initEPWM(uint32_t epwm_base)
    {
        //
        // Set-up TBCLK
        //
        EPWM_setTimeBasePeriod(epwm_base, EPWM1_TIMER_TBPRD);
        EPWM_setPhaseShift(epwm_base, 0U);
        EPWM_setTimeBaseCounter(epwm_base, 0U);
    ...
    }

    or for bitfields you can do:

    volatile struct EPWM_REGS *ePWM[PWM_CH] =
    {  &EPwm1Regs, &EPwm1Regs, &EPwm2Regs, &EPwm3Regs, &EPwm4Regs, &EPwm5Regs,
       &EPwm6Regs, &EPwm7Regs, &EPwm8Regs};
    
    void InitEPwm()
    {
       for(j=1; j<PWM_CH; j++)
        {
            (*ePWM[j]).TBCTL.bit.PRDLD = TB_SHADOW;  // set Shadow load
            (*ePWM[j]).TBPRD = period;               // PWM frequency = 1/(2*TBPRD)
            (*ePWM[j]).CMPA.bit.CMPA = period / 2;   // set duty 50% initially
            (*ePWM[j]).CMPA.bit.CMPAHR = (1 << 8);   // initialize HRPWM extension
            (*ePWM[j]).CMPB.bit.CMPB = period / 2;   // set duty 50% initially
            (*ePWM[j]).CMPB.all |= 1;
            (*ePWM[j]).TBPHS.all = 0;
            (*ePWM[j]).TBCTR = 0;
    ...
    ...
    }

  • Interesting idea, thank you.