• Join
  • Sign In with my.TI Login
Texas Instruments
  • Products
  • Applications
  • Tools & Software
  • Support & Community
  • Sample & Buy
  • About TI
Sample & Purchase Cart Sample & Purchase Cart
  • Search
  • Advanced
TI E2E™ Community
  • Support Forums
  • Blogs
  • Groups
  • Videos
  • 简体中文
  • More ...
TI Home » TI E2E Community » Support Forums » Microcontrollers » C2000™ Microcontrollers » C2000 32-bit Microcontrollers Forum » tricky PWM 100% duty cycle problem in 28335
Share
C2000™ Microcontrollers
  • Forums
  • Announcements
  • E2E Wiki
Options
  • Subscribe via RSS
C2000 Resources
  • Product Folder
  • C2000 Training Portal
  • C2000 Technical Training Catalog
  • C2000 Datasheets, App Notes, User Guides
  • C2000 Hardware Design Kits
  • controlSUITE for C2000 Software Library


  • InstaSPIN Resources
  • What is InstaSPIN?
  • Videos and Support


  • InstaSPIN-FOC and InstaSPIN-MOTION Resources
  • What is InstaSPIN-FOC?
  • What is InstaSPIN-MOTION?
  • Product Folder: F28069F, F28068F, F28062F, F28068M, F28069M
  • User’s Guide
  • Technical User’s Manual
  • Tools
  • tricky PWM 100% duty cycle problem in 28335

    tricky PWM 100% duty cycle problem in 28335

    This question is answered
    Kuldeep Kumar Mynampati
    Posted by Kuldeep Kumar Mynampati
    on Jan 13 2012 11:25 AM
    Intellectual320 points

    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

     

     


     

    28335 issue Complementary PWM Set up 100% dutycycle PWM issue
    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    All Replies
    • Daniel Chang
      Posted by Daniel Chang
      on Jan 13 2012 14:04 PM
      Expert4120 points

      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?

       

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Kuldeep Kumar Mynampati
      Posted by Kuldeep Kumar Mynampati
      on Jan 13 2012 15:57 PM
      Intellectual320 points

      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%.

       

       

       

      28335 100% duty cycle. PWM issue
      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Daniel Chang
      Posted by Daniel Chang
      on Jan 13 2012 17:04 PM
      Expert4120 points

      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?

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Kuldeep Kumar Mynampati
      Posted by Kuldeep Kumar Mynampati
      on Jan 16 2012 15:57 PM
      Intellectual320 points

      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

       

      28335 Ecan 100% PWM problem
      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Daniel Chang
      Posted by Daniel Chang
      on Jan 16 2012 16:17 PM
      Expert4120 points

      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;

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Kuldeep Kumar Mynampati
      Posted by Kuldeep Kumar Mynampati
      on Jan 18 2012 11:08 AM
      Intellectual320 points

      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

      28335 100% PWM duty_cycle
      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Daniel Chang
      Posted by Daniel Chang
      on Jan 18 2012 11:42 AM
      Expert4120 points

      KK,

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

       

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Kuldeep Kumar Mynampati
      Posted by Kuldeep Kumar Mynampati
      on Jan 18 2012 11:47 AM
      Intellectual320 points

      Daniel,

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

      KK

      28335 pwm 1005 duty Cycle
      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Daniel Chang
      Posted by Daniel Chang
      on Jan 18 2012 12:26 PM
      Expert4120 points

      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?

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Kuldeep Kumar Mynampati
      Posted by Kuldeep Kumar Mynampati
      on Jan 18 2012 13:25 PM
      Intellectual320 points

      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

      28335 PWM 100% duty cycle
      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Kuldeep Kumar Mynampati
      Posted by Kuldeep Kumar Mynampati
      on Jan 18 2012 13:30 PM
      Intellectual320 points

      Daniel,

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

      KK

      28335 pwm
      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Daniel Chang
      Posted by Daniel Chang
      on Jan 18 2012 14:10 PM
      Verified Answer
      Verified by Kuldeep Kumar Mynampati
      Expert4120 points

      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

       

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Kuldeep Kumar Mynampati
      Posted by Kuldeep Kumar Mynampati
      on Jan 18 2012 15:25 PM
      Verified Answer
      Verified by Kuldeep Kumar Mynampati
      Intellectual320 points

      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

       

      pwm 28335 Ecan 100% duty cycle
      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Kuldeep Kumar Mynampati
      Posted by Kuldeep Kumar Mynampati
      on Apr 12 2012 15:47 PM
      Intellectual320 points

      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

       

      ADC 28335 pwm
      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    TI E2E™ Community
    • Support Forums
    • Blogs
    • Videos
    • Groups
    • Site Support & Feedback
    • Settings
    TI E2E™ Community Groups
    • TI University Program
    • Make the Switch
    • Microcontroller Projects
    • Motor Drive & Control
    Other Communities
    • Deyisupport
    • Designsomething.org
    • beagleboard.org
    • TI on Element 14
    • TI on TechXchangeSM
    Other Technical & Support Resources
    • WEBENCH® Design Center
    • Product Information Centers
    • Technical Documents
    • TI Design Network
    • TI Technical Articles
    • TI Training

    All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with respect to these materials. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.

    Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms of Use of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms of Use of this site. TI, its suppliers and providers of content reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

    Follow Us Texas Instruments on Facebook Texas Instruments on Twitter Texas Instruments on LinkedIn Texas Instruments on Google+
    TI Worldwide | Contact Us | my.TI Login | Site Map | Corporate Citizenship | mobile m.ti.com (Mobile Version)

    TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs and
    embedded processors, along with software, tools and the industry’s largest sales/support staff.

    © Copyright 1995-2013 Texas Instruments Incorporated. All rights reserved.
    Trademarks | Privacy Policy | Terms of Use