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 Start / stop question

Other Parts Discussed in Thread: TMS320F28035

Hi all,

I am using the EPwm1 in TMS320F28035 micro-controller in a  power supply project. I have connected a push button at one of the GPIO port for starting and stoping the PWM pulses.

I am facing following problems in this

Question 1

 When I start the PWM a wide pulse comes first on EPWM1A channel and then starts the normal PWM pulses. The width of this pulse varies each time I starts.

 My question is, is there any standard way to start and stop pwm pulses. What I am doing wrong. Please refer my code given below

 

 // To STOP the PWM
     
      EPwm1Regs.AQSFRC.bit.RLDCSF = 3;
    EPwm1Regs.AQSFRC.bit.ACTSFA = 1;
    EPwm1Regs.AQSFRC.bit.ACTSFB = 1;
    EPwm1Regs.AQSFRC.bit.OTSFA = 1;
    EPwm1Regs.AQSFRC.bit.OTSFB = 1;
    EPwm1Regs.AQCSFRC.bit.CSFA = 1;
    EPwm1Regs.AQCSFRC.bit.CSFB = 1;
    EPwm1Regs.DBCTL.bit.OUT_MODE = 0;
   
   
   
    // To START the PWM   
      EPwm1Regs.AQSFRC.bit.RLDCSF = 0;
    EPwm1Regs.AQSFRC.bit.ACTSFA = 0;
    EPwm1Regs.AQSFRC.bit.ACTSFB = 0;
    EPwm1Regs.AQSFRC.bit.OTSFA = 0;
    EPwm1Regs.AQSFRC.bit.OTSFB = 0;
    EPwm1Regs.AQCSFRC.bit.CSFA = 0;
    EPwm1Regs.AQCSFRC.bit.CSFB = 1;
    EPwm1Regs.DBCTL.bit.OUT_MODE = 3;

Question 2

 I have configured the trip zone for over current protection. The over current tripping is working OK. But once it is tripped we are not able to start the pulse again by pressing the start button.

To restart  the PWM pulse I have to do  power ON/OFF of the development kit.

Please refer my Initialization Code given below and start code shown above. Please give your suggestions.

Thanks and regards

Ittoop

//------------------------------------------------------Start--------------------------------------------------------------------------

// EPM configuration

  EPwm1Regs.TBCTL.bit.CTRMODE = TB_FREEZE;  // disable counter
  EPwm1Regs.TBCTR = 0x0000;                                     // Clear timer counter
  EPwm1Regs.TBPRD = FREQ_MAX_COUNT;            // Period = Start from max frequency
  EPwm1Regs.CMPA.half.CMPA = FREQ_MAX_COUNT/2;
  EPwm1Regs.AQCTLA.bit.ZRO = AQ_TOGGLE;          //AQ_TOGGLE;            

// Dead band configuration

    EPwm1Regs.DBCTL.bit.IN_MODE = DBA_ALL;         // EPWMxA is the source for both delays
    EPwm1Regs.DBCTL.bit.OUT_MODE =DB_FULL_ENABLE;  //DB_DISABLE;// Enable Deadband module
    EPwm1Regs.DBCTL.bit.POLSEL = DB_ACTV_HIC;     // Active High Complementary (AHC)
    EPwm1Regs.DBRED = 150;                        //2.5uS dead time
    EPwm1Regs.DBFED = 150;
   
// Trip zone configuration    
   
    EPwm1Regs.TZCLR.all=0;                     // clear previous trips
    EPwm1Regs.TZCLR.bit.OST=1; 
    EPwm1Regs.TZSEL.bit.OSHT1 = 1;                           // one-shot source
    EPwm1Regs.TZCTL.bit.TZA = TZ_FORCE_LO;       // set EPWM1A to low at fault
    EPwm1Regs.TZCTL.bit.TZB = TZ_FORCE_LO;      // set EPWM1B to low at fault
   
   
    EPwm1Regs.AQSFRC.bit.RLDCSF = 0;
  EPwm1Regs.AQSFRC.bit.ACTSFA = 0;
  EPwm1Regs.AQSFRC.bit.ACTSFB = 0;
  EPwm1Regs.AQSFRC.bit.OTSFA = 0;
  EPwm1Regs.AQSFRC.bit.OTSFB = 0;
  EPwm1Regs.AQCSFRC.bit.CSFA = 0;
  EPwm1Regs.AQCSFRC.bit.CSFB = 1;
  EPwm1Regs.DBCTL.bit.OUT_MODE = 3;
  EPwm1Regs.TBCTL.bit.CTRMODE = TB_COUNT_UP;

//--------------------------------------------------------End--------------------------------------------------------------------------

  • Question1:  Your button might do bouncing, means it is not a clean switch from "0" to "1" and this might cause you these problems. You will have to filter the bouncing with hardware or with qualification parameters in software or neglecting the pin change for a short time after change has occured. Check if there is bouncing with the oscilloscope.

     

    Question2: You are using one shot. To get PWM started again you will have to clear the one shot flag by writing: EPwm1Regs.TZCLR.OST = 1;

     

    JHi

  • For Question1:

    Try this trick. 

    1. Make sure you have shadow registers enabled.
    2. Before mux'ing GPIO to PWM, set your pulse width to zero.
    3. Wait at least one PWM period (this is to make sure shadow register got copied to active register)
    4. Now set GPIO mux to PWM.
    5. Now write to the compare register the correct vaue for the pulse width.

    I hope this works/helps.

  • Hi JHi and  quark,

    Thanks for reply and time.  Your suggetions worked very well.

    Regards

    toop