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.

CCS/TMS320F28027: PWM issue

Part Number: TMS320F28027
Other Parts Discussed in Thread: CONTROLSUITE

Tool/software: Code Composer Studio

hello,

I am currently working over pwm using adc. I have activated two pwms with same intializations. but I am getting a little phase shift between epwm1a and epwm2a. how to get rid of this, as my requirement is that both epwms should have same waveform.

Please help

  • Hi Madhuri,

    Madhuri Depuru said:
    Please help

    Try this out:

         EALLOW;  
           SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 0;      // DISABLE TBCLK TILL EPWM CONFIGURATION 
         EDIS; 
         
         //ePWM1 Configuration
         //ePWM2 Configuration
     
    
         EALLOW;  
             SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 1;      // ENABLE TBCLK AFTER EPWM CONFIGURATION 
         EDIS; 

    Regards,

    Gautam

  • Hello Gautam,

    I guess I have already incorporated that part in my program, still I am not able to get the result. I am including pwm part of the program. please help.

    void InitEPwm1()
    {

        CLK_disableTbClockSync(myClk);
        CLK_enablePwmClock(myClk, PWM_Number_1);
        GPIO_setPullUp(myGpio, GPIO_Number_0, GPIO_PullUp_Disable);
        GPIO_setPullUp(myGpio, GPIO_Number_1, GPIO_PullUp_Disable);
        GPIO_setMode(myGpio, GPIO_Number_0, GPIO_0_Mode_EPWM1A);
        GPIO_setMode(myGpio, GPIO_Number_1, GPIO_1_Mode_EPWM1B);
        PWM_setSyncMode(myPwm1, PWM_SyncMode_EPWMxSYNC)
        PWM_enableCounterLoad(myPwm1);

        // Set the phase
       /* PWM_setPhase(myPwm1, 100);
        PWM_setPhase(myPwm1, 200);
        PWM_setPhase(myPwm1, 300);*/

        PWM_setPeriod(myPwm1, PWM1_TIMER_TBPRD);
        PWM_setCounterMode(myPwm1, PWM_CounterMode_Up);         // Count up
        PWM_setIntMode(myPwm1, PWM_IntMode_CounterEqualZero);   // Select INT on Zero event
        PWM_enableInt(myPwm1);                                  // Enable INT
        PWM_setIntPeriod(myPwm1, PWM_IntPeriod_FirstEvent);     // Generate INT on 1st event

        PWM_setActionQual_Period_PwmA(myPwm1, PWM_ActionQual_Set);
        PWM_setActionQual_CntUp_CmpA_PwmA(myPwm1, PWM_ActionQual_Clear);


        PWM_setActionQual_Period_PwmB(myPwm1, PWM_ActionQual_Set);
        PWM_setActionQual_CntUp_CmpA_PwmB(myPwm1, PWM_ActionQual_Clear);

       CLK_enableTbClockSync(myClk);
     // EPwm3Regs.DBCTL.bit.OUT_MODE = DB_FULL_ENABLE;
       //EPwm3Regs.DBRED = 50;
      // EPwm3Regs.DBFED = 100;
    }

    void InitEPwm3()
    {

        CLK_disableTbClockSync(myClk);
        CLK_enablePwmClock(myClk, PWM_Number_3);
        GPIO_setPullUp(myGpio, GPIO_Number_4, GPIO_PullUp_Disable);
        GPIO_setPullUp(myGpio, GPIO_Number_5, GPIO_PullUp_Disable);
        GPIO_setMode(myGpio, GPIO_Number_4, GPIO_4_Mode_EPWM3A);
        GPIO_setMode(myGpio, GPIO_Number_5, GPIO_5_Mode_EPWM3B);
         // Setup Sync
        PWM_setSyncMode(myPwm3, PWM_SyncMode_EPWMxSYNC);
      //  PWM_setSyncMode(myPwm2, PWM_SyncMode_EPWMxSYNC);
        PWM_enableCounterLoad(myPwm3);
       

        PWM_setPeriod(myPwm3, PWM3_TIMER_TBPRD);
        PWM_setCounterMode(myPwm3, PWM_CounterMode_Up);         
        PWM_setIntMode(myPwm3, PWM_IntMode_CounterEqualZero);   
        PWM_enableInt(myPwm3);                                  
        PWM_setIntPeriod(myPwm3, PWM_IntPeriod_FirstEvent);   

       PWM_setActionQual_Period_PwmA(myPwm3, PWM_ActionQual_Set);
       PWM_setActionQual_CntUp_CmpA_PwmA(myPwm3, PWM_ActionQual_Clear);


        PWM_setActionQual_Period_PwmB(myPwm3, PWM_ActionQual_Set);
        PWM_setActionQual_CntUp_CmpA_PwmB(myPwm3, PWM_ActionQual_Clear);
        CLK_enableTbClockSync(myClk);

    }

  • Madhuri Depuru said:
    I guess I have already incorporated that part in my program

    Nope you've not incorporated what I suggested!

    CLK_disableTbClockSync(myClk);
    
    InitEPwm1();
    InitEPwm2();
    InitEPwm3();
    
    CLK_enableTbClockSync(myClk);

    Please enable and disable clock sync every-time as you're doing above.

    Regards,

    Guatam

  • I did it. still the same response

  •  the result is as follows

  • OK I'm not sure what's happening on your side, this project works really well : C:\ti\controlSUITE\device_support\f2802x\v230\f2802x_examples_structs\epwm_up_aq
    Just that disable the continuous duty alteration.

    Regards,
    Gautam