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.

tricky PWM 100% duty cycle problem in 28335

Hi,

I have configured my PWM timer initilization for inverter which are complementary and PWM outputs are gated (Init_Timer function below). I am using EPWM1 interrupt to process ADC data only.

InitPWMs-1/2/3()
{
// Allow synchronization            
TBCTL.bit.SYNCOSEL  = 0; 
TBCTL.bit.PHSEN     = 0; 
TBCTL.bit.CLKDIV    = 0; 
TBCTL.bit.HSPCLKDIV = 0; 
TBPHS.half.TBPHS    = 0; 
TBCTL.bit.FREE_SOFT = 2;  
                                    
TBPRD              = 5000;
CMPA.half.CMPA     = 2500;
                                    
TBCTL.bit.CTRMODE  = 2;  
TBCTR              = 0;   
                                    
CMPCTL.bit.SHDWAMODE = 0;
CMPCTL.bit.SHDWBMODE = 0;
                                    
// Next PWM is set zero when CTR      reaches zero and moved from Shadow to Active.                       
CMPCTL.bit.LOADAMODE = 0;
CMPCTL.bit.LOADBMODE = 0;
                                    
// Set actions: ACTIVE LOW-HIGH     
AQCTLA.bit.CAU = 0x1;    
AQCTLA.bit.CAD = 0x2;    
                                    
// Setup the deadband - Active high  complementary PWMs               
DBCTL.bit.OUT_MODE = 0x3;
DBCTL.bit.POLSEL   = 2;  
DBCTL.bit.IN_MODE  = 0x0;
DBRED              = 10; 
DBFED              = 10; 

}

With an interface I was able to change the duty cycle varying from 10% to 100% duty cycle and with fixed frequency and could able to see different PWM outputs. I was trying to configure a shorted PWM case which means

EPWM1A-> 12.5V or 100%  EPWM1B -> 0V or 0%
EPWM2A-> 12.5V or 100%. EPWM2B -> 0V or 0%
EPWM3A-> 12.5V or 100%. EPWM3B -> 0V or 0%

or vice versa.

Inorder to acheive this,as per the document. I have set my PWM registers as below. In this case, my PWM just stops and never starts. Only option is to reset the processor and run the PWM. Short()
{
  EPwm1Regs.TBPRD = PWM_PERIOD;
  EPwm2Regs.TBPRD = PWM_PERIOD;
  EPwm3Regs.TBPRD = PWM_PERIOD;

  EPwm1Regs.half.bit.CMPA = 0x0000
  EPwm2Regs.half.bit.CMPA = 0x0000
  EPwm3Regs.half.bit.CMPA = 0x0000
}

Can I acheive this with this configuration or Am I missing some thing or IS THERE ANY MAGIC?  I have referred EPWM document as well as SPRAA1 doc also. Replies greatly appreciated.

Thanks alot,

Regards,

Kuldeep

 

 


 

  • Hi Kuldeep,

    I assume you are running your PWMs in up-down count mode.  If you set the PWM TBPRD and CMPA registers as you described in the Short() function, it should result in either a 0% or 100% duty PWM signal.

    Can you explain what you mean by "my PWM just stops and never starts" in your post? 

    When do you activate those settings? 

    What is the relationship between PWM_PERIOD and 5000?

     

  • Hi Chang,

    Yes! you are right. I am running in Up-Down Mode.

    When do you activate those settings? 

    I call the interface RunPWM() and update the TBPRD and CMPA registers settings.

    What is the relationship between PWM_PERIOD and 5000?

    PWM_PERIOD  = 5000 ( My bad, they are the same).

    Can you explain what you mean by "my PWM just stops and never starts" in your post? 

    I mean, PWM stays at 0% . Even though if I call the RunPWM () with 50% duty cycle. I could not see the PWM outputs and always stays at 0%.

     

     

     

  • Kuldeep,

    In your first post, you said you were able to run PWM modules and observe changing Duty cycle waveforms.  What are you doing differently from that setup?

  • Daniel,

    Thanks for the reply. Yes ! you are right as stated from previous post and now also I am able to run PWM's.  Let me clarify, I have 3 function calls in my PWM interface.

    1. RUNPWM    (I can change my duty cycles and frequency in debugger and just update the registers and PWM runs fine).
    2. STOPPWM   (Set my TBPRD = 0. so, stops the PWM and runs fine.)
    3. SHORTEDPWM ( High and low side switches shall be commanded OFF & ON or vice versa). PROBLEM.

    As per EPWM guide for 28335 document. If I set to TBPRD = MAX_PERIOD (5000) & CMPA = 0 (I should expect either 0% or 100% duty). I did the same way.

    Case-1 : Tried setting the registers to

     TBPRD = MAX_PERIOD (5000) (EPWM-1/2/3)
     CMPA  = 0 (EPWM-1/2/3)

     DOES NOT DO anything. PWM OUTPUT STAYS AT 0%.

    case-2: tried setting the registers to see 100%

     TBPRD = MAX_PERIOD (5000) (EPWM-1/2/3)
     CMPA  = MAX_PERIOD (5000) (EPWM-1/2/3)   DOES NOT DO anything. PWM OUTPUT RUNS WITH DEFAULT SETTINGS (50% duty cycle).

    I hope this helps. Please advice.

    Regards,
    KK

     

  • KK,

    Is this the exact code you are using in your program?

      EPwm1Regs.half.bit.CMPA = 0x0000
      EPwm2Regs.half.bit.CMPA = 0x0000
      EPwm3Regs.half.bit.CMPA = 0x0000

    If that is the code you are using, that is incorrect.  You need to access the registers this way:

    EPwm1Regs.CMPA.half.CMPA = 0x0;
    EPwm2Regs.CMPA.half.CMPA = 0x0;
    EPwm3Regs.CMPA.half.CMPA = 0x0;

  • Daniel,

    I tried setting the registers as per your note.

    EPwm1Regs.CMPA.half.CMPA = 0x0;
    EPwm2Regs.CMPA.half.CMPA = 0x0;
    EPwm3Regs.CMPA.half.CMPA = 0x0;

    But I see the same problem (PWM stops).

    If I run with settings below it runs.

    EPwm1Regs.TBPRD = 0x2710;
    EPwm2Regs.TBPRD = 0x2710;
    EPwm3Regs.TBPRD = 0x2710;

    EPwm1Regs.CMPA.half.CMPA = 0x1388;
    EPwm2Regs.CMPA.half.CMPA = 0x1388;
    EPwm3Regs.CMPA.half.CMPA = 0x1388;

    Regards,

    KK

    Any suggestion

  • KK,

    When do you try to run at CMPA = 0x0?  Is it after you call the "STOPPWM" function?

     

  • Daniel,

    No! I tried running CMPA = 0x0 after RUNPWM() function call.

    KK

  • Have you verified in the debug watch window that the PWM timers are still running?

    After you set CMPA = 0x0, if you change it, does the PWM waveform return?

  • With CMPA = 0x0 setting, I observed that PWM timers are running that is TBCTR keeps changing for all the timers (EPWM-1/2/3) but NO PWM WAVEFORM. When I change the value from CMPA =0x0 to CMPA = 0x1388 with TBPRD = 0x2710, I see the PWM wave form.

    Thanks,

    KK

  • Daniel,

    Is trip zone or deadband setting  would be help ful for me in my SHORTPWM () function?

    KK

  • KK,

    What you are describing sounds like normal operation to me. 

    Your Action Qualifier settings has-
        Clear on CMPA-Up
        Set on CMPA-Down

    With CMPA=0, both events occur simultaneously.  According to the event priority in the ePWM user guide, CMPA-Up takes priority.  With your configuration, this results in 0% duty.  Why don't you try CMPA = Period instead to see if that is what you want?

    Depending on your goal, you could also try using a continuous SW force, using the  AQCSFRC register.

    You can refer to SPRUGE9

     

  • Daniel,

    Thanks for the update. I tried to set the CMPA= MAX_PERIOD (10000 or 0x2710). Either with CMPA = 0x0 or CMPA = 0x2710. I still have the same problem. No PWM WAVE FORM with my register settings.  I will try to see by using AQCSFRC register.

    Regards,

    KK

     

  • Hi,

    I am using 28335 for PWM setup. PWM are running fine. I have set up to trigger ADC when TBCTR = TBPRD and  I am using Shadow registers. In this case, sometimes I am seeing PWM is not triggering ADC on the scope. Is there any way to know if the next pulse is updated as expected or if I am missing a PWM pulse setup in debugger or some test examples?

     

    Thanks,

    KUldeep