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.

How to design outputs from two PWM Synchronization

 

Here is the code to setup, but I couldn't get synchrnoized output. The outputs between two PWMs has about 1 to 2 us variation for each setup. Once it is setup, the PWM pulse will be kept in same distance. I used Sync_Global settings, update, sync time. Not works.

  // Configure the GEN3 to up-down without synchronization.
  PWMGenConfigure(PWM_BASE, PWM_GEN_3,
                  (PWM_GEN_MODE_UP_DOWN | PWM_GEN_MODE_GEN_SYNC_GLOBAL));

...

Set registers

...


  // Configure the GEN0 to up-down without synchronization.
  PWMGenConfigure(PWM0_BASE, PWM_GEN_0,
                  (PWM_GEN_MODE_UP_DOWN | PWM_GEN_MODE_GEN_SYNC_GLOBAL));

...

Set registers

...

// Enable the M0PWM6 and M0PWM0 output signals.
  PWMOutputState(PWM0_BASE, (PWM_OUT_6_BIT | PWM_OUT_0_BIT), true);

    // Enables PWM generator blocks
    PWMGenEnable(PWM0_BASE, PWM_GEN_3);
    PWMGenEnable(PWM0_BASE, PWM_GEN_0);

 

    // Reset PWM generator blocks
    PWMSyncUpdate(PWM0_BASE, PWM_GEN_3_BIT | PWM_GEN_0_BIT);

    // Reset PWM generator blocks
    PWMSyncTimeBase(PWM0_BASE, PWM_GEN_3_BIT | PWM_GEN_0_BIT);

 

  • Eric Zhang said:
    I couldn't get synchronized PWM outputs

    Several things to consider - but first, (this from our LX4F manual - applies equally - your MCU...)

    "Generally, Count-Down mode is used for generating left- or right-aligned PWM signals, while the Count-Up/Down mode is used for generating center-aligned PWM signals."   Thus - it is possible - what you are reporting is normal.  Diagram further illustrates (same source)

    Issue here is (I believe), "has your observation properly considered this center alignment (and sync) between PWM Generators?"  Note - in the diagram above - the 2 PWM outputs are "sync'ed to center" - not edge! 

    Quick/simple test to evaluate "sync" - switch to "down" mode rather than up/down.  Edge alignment (far easier to detect/measure) results...

    Now - your post reveals Global Sync - which is the most restrictive.  (Detailed below)

    Globally Synchronized. The write value does not affect the logic until two sequential events have occurred: (1) the Update mode for the generator function is programmed for global synchronization in the PWMnCTL register, and (2) the counter reaches zero at the end of the PWM cycle. In this case, the effect of the write is deferred until the end of the PWM cycle following the end of all updates. This mode allows multiple items in multiple PWM generators to be updated simultaneously without odd effects during the update; everything runs from the old values until a point at which they all run from the new values. The Update mode of the load and comparator match values can be individually configured in each PWM generator block. It typically makes sense to use the synchronous update mechanism across PWM generator blocks when the timers in those blocks are synchronized, although this is not required in order for this mechanism to function properly.

    We happen to sync 3 PWM Generators (6 outputs) and find, "Locally Synchronized" better for our purposes.  (you may wish to try, report)

    Do not like the order of your code listing - code shows, " PWMSyncUpdate()" prior to, " PWMSyncTimeBase()."  How can the desired Sync Update occur before you have "sync'ed" the Time Base?  (note: we "helpers" can only work w/data you provide...)

    Your config of PWM parameters appears valid - you have not provided earlier, more basic PWM config listings.  (i.e. GPIOPinType() & GPIOPinConfigure() - we assume that is good)

    We note that your comments (twice!) state w/out Sync - when in fact you apply Global Sync.  Attention to such detail much demanded - any ARM MCU.

    Final point - our 3 PWM Generators (w/ up/down count - as you employ) do sync.  Here's our general, code sequence (to achieve desired sync):

    PWMPulseWidthSet();  //  we first set the PWM width for all channels to be sync'ed

    PWMSyncUpdate();   //  and only then make the call to Sync Update...

    And - you must consider the call (below).  You may wish to experiment - keying upon any change in PWM output and/or position - both prior to & after that call...  (ideally - you'd make notable changes via PulseWidthSet() - and then observe PWM outputs/edges - as the code "rattles thru" ea. of these 3 functions...

    PWMOutputState(PWMx_BASE, Val, true);  //  PWM turned on!

    Long ago - on planet far away - we used Sperry Beckman "plasma" 7 segment & bar-graph displays.  (made NYC TV newz with that...)

  • Hi Eric,

     

    I can't get mine to not be synchronized.  I will continue trying some tests here.

    I did see an error in the code you posted above:

     PWMGenConfigure(PWM_BASE, PWM_GEN_3, (PWM_GEN_MODE_UP_DOWN | PWM_GEN_MODE_GEN_SYNC_GLOBAL));

    Which PWM module are you trying to set up?  I assume it's PWM #3 on PWM module 0?

    John

  • @John,

    Poster has long - gone quiet...  That said - while "deprecated" - don't believe PWM_BASE rises to error... 

    #define PWM_BASE                0x40028000  // PWM
    #define PWM0_BASE              0x40028000  // Pulse Width Modulator (PWM)

    This revealed w/in hw_memmap.h, Rev 9453, StellarisWare.   Don't find his MCU specified w/in his post...

    Continue in my belief that the "center-alignment" - rather than more easily recognized "edge-alignment" - was likely suspect...

    Note further that poster "PWMSync(s)Timebase" only after he "PWMSyncUpdates" - which to me is improper... 

  • I tried up-down mode, down mode only and couldn't make it work. The update related method is just a way to generate PWM pulse under controlled manner during the transition, I think. Of cause I tried different calling sequence and none of them work.

    I don't care the 1st 1 or 2 pulses. I don't think update function make difference.

    I found out one way to make it work. After I applied new settings and enabled PWM, I call SyncTimebase() for 20 times with small delay 10us and close global interrupts; finally it works as expected. I couldn't explain why.

    In design, I believe whatever where the PWM is, once they have same period settings, after SyncTimeBase is called, they should be synchronized.

     

  • Eric,

    This should not be happening.  I believe something else is going on.

    Can you please post your source file (including all of the register setups, how you have the clocks assigned, etc.) to the forum?  I will take a look at it and see if I can spot the issue.  You can just give me the part related to the PWM setup.

    John

  • Eric,

    I've attached a C file that shows how to set up multiple PWMs.  This is a modified version of the Tiva PWM example invert.c.

    This uses PWM 0 and PWM 6 on module 0, and PWM 0 on module 1.

    All 3 of these PWM signals are sync'd on my eval board.

    Hope this helps,

    John

  • Hello John,

    Quickly reviewing this file - can this be correct for SYNC'ED PWM Outputs?

       // Configure the PWM0 to count up/down without synchronization.
        //
        PWMGenConfigure(PWM0_BASE, PWM_GEN_0, PWM_GEN_MODE_UP_DOWN |
                        PWM_GEN_MODE_NO_SYNC);
        PWMGenConfigure(PWM1_BASE, PWM_GEN_0, PWM_GEN_MODE_UP_DOWN |
                            PWM_GEN_MODE_NO_SYNC);
        PWMGenConfigure(PWM0_BASE, PWM_GEN_3, PWM_GEN_MODE_UP_DOWN |
                                PWM_GEN_MODE_NO_SYNC);

    Use of "NO_SYNC" to cause Sync - may break new ground in being counter-intuitive...

    And - file references both PB6 and PD0 (via intro comments) - neither "in play" this file's PWM scheme.  (although they are valid PWM outputs - but not set-up/config'ed - this file...)

    Further - would not some use of, "PWMSyncTimeBase()" be normal/customary - to Sync these outputs.  Yet - none reveals...  If indeed Sync occurs w/out SyncTimeBase() - what is the intent of that function?   Has it been automated (i.e. "swallowed" during the StellarisWare to rebrand exercise?)  Indeed it does work on our early LX4F - and multiple M3's - past...

    Suspect someway/somehow - wrong file was attached...

  • I agreed with you. It seems that a wrong file was attached. The PWMSyncTimeBase() is not called in this file and how these PWMs are synced?

    Per my understanding PWM_GEN_MODE_NO_SYNC shouldn't be an issue since they are in same period. My problem is how to set controlled phase between two PWMs. The phase get 1 to 4 PWM clock variation when the PWMs are enabled; of cause the timing was kept once they are enabled since they all have same period.

     

     

  • Eric,

    That was kind of my point.  On my HW, NO_SYNC still gives me dead on sync'd PWMs.  I don't see any PWM clock difference between the two waveforms.  They are exactly in phase, even down to the 20ns timebase on my scope.

    ???

    What clock are you running the PWMs off of, and what frequency and duty cycle are you setting them to?

    JW

  • Hello again, John,

    In the interest of completeness - and in defense of StellarisWare's creation of, "SYNC vs NO_SYNC" - as regards PWM outputs across different PWM Generators - I have gathered pertinent scope traces which - I believe - support the use of SYNC to insure synchronization across different generators.   Will present here in the next few minutes...

    I offer this as constructive input - my contribution to an area which I sense many will find of importance.  As always - whenever factory personnel can find the time to contribute - such is always most welcome.  Here then - my findings:

    Here - what I believe to be, "Sync'ed PWM Generators" (Gen 0 & Gen 2, PB6, PG4, here).  Note that this was achieved via, "PWM_GEN_MODE_GEN_SYNC_LOCAL" as param. w/in, "PWMGenConfigure()."  In addition - calls were subsequently made both to: "PWMSyncTimeBase()" and "PWMSyncUpdate()."  Kindly observe that both PWM outputs are precisely aligned about the PWM counter's center - expected when using "PWM_GEN_MODE_UP_DOWN" as active parameter. 

    And below - I monitored the same 2 PWM outputs - but after removing the call to, "PWMSyncTimeBase()."  Note that we've lost the "center sync."  Not horrendous - but does not meet, "normal/customary" definition of, "Sync!"

    And - I show here the same signals under wider time-scale.  Bit harder to note here - but the same Sync Loss reveals.

    Thus it appears that my earlier challenge of, "SYNC" not meaning, "NO_SYNC" - of course counter-intuitive - may be in this case, correct.  And for that - I/others am glad!  Words - even MCU functions - do have meaning - and to reject the obvious may not be especially, "STELLAR!"  (disturbed that you ignored my earlier/obvious protest...)

    This work done under StellarisWare 9453 - LX4F231 MCU - custom board - Scope Tek: TDS3054B.  PWM @ 20KHz.

  • There definitely is something about what my code is doing that's different to what you're seeing cb1, because I'm not getting that same result with NO_SYNC.  I don't doubt that you should be required to set these up using the SYNC commands to get them to output synchronized PWMs.  I'm wondering if I have a different clock selected or the frequency is such that it doesn't show up here.  At any rate, the problem for me is that since I can't get it to fail, I can't help Eric solve the original problem, because mine are always sync'd up.  This is why I keep asking for more information about the clocks, frequency, etc.

    Your scope traces are tremendously helpful, thank you for posting these, since I can't get mine to break!

    JW

  • Thank you, John - our group has used ARM MCUs dating to 2004 - and Stellaris since LMI's inception.  And most always employed the PWM Generators - and always these required some SYNC Mode and SyncTimebase - to cause the desired synchronization.  Thus - you may better understand my protest - when that successful mechanism appeared discarded.

    Again - I personally have avoided rebrand devices & rebrandWare.  (I know & appreciate the effort/precision required - and choose not to be, "early adopter.")  Mention again - as my scope traces all stem from StellarisWare - running on an LX4F.  And - using a variety of earlier M3s & other M4s - that SYNC Mode & SyncTimebase were always mandatory!

    While we await poster Eric's return - might you comment on his statement, "PWM_GEN_MODE_NO_SYNC shouldn't be an issue since they are in same period."  Believe this to be flat wrong/misguided.  In fact - the "out of sync" waveforms I supplied are of the exact same period (and frequency) - and are clearly NOT in Sync!  Sharing frequency/period does not assure Sync.  Perhaps he'll more accept that - hearing from you...

    Resolution of this Sync issue likely demands comparison of past StellarisWare vs. rebrand - keying upon:

    PWMGenConfigure()
    PWMSyncTimeBase()
    PWMSyncUpdate()

    Possibly functions have been combined/inter-woven - but such task best left to your group.  Again - hope that you/others find my efforts of some value - always my objective...

    Update: John - first post answering Eric - I asked if he truly understood, "Center Sync" - hope that my scope traces provide good means for comparison.  Note that this same issue impacts, "Edge Sync" - and is more readily noted.

  • @John/interested others,

    In the continuing search, MCU PWM Gen Sync,"truth/justice" - new findings boggle the mind!

    Find now - that indeed I can cause LX4F - under StellarisWare 9453 - to Sync different PWM Generators - when using the param. "PWM_GEN_MODE_NO_SYNC" w/in function, "PWMGenConfigure()" but ONLY after making a call to, "PWMSyncTimeBase()!"  Our group did not expect this - and must state that we shall continue to employ SYNC w/in PWMGenConfigure() as that also works.  (and has for past 7 or so years...)

    Might it be that "SYNC" as used w/in StellarisWare/rebrandWare - deserves/commands some extended definition?

    To confirm - made the effort to change the PWM frequency (seek to eliminate single freq. anomaly).  Now @ 25KHz - scope reveals:

    Capture results from, "NO_SYNC" param. w/in PWMGenConfigure() but only after subsequent call to, PWMSyncTimeBase().   Note that vendor's code example earlier provided (multiple_pwm.c) - made no such call to PWMSyncTimeBase().  My findings - PWMSyncTimeBase() very much required to SYNC!

     Now - without call to, "PWMSyncTimeBase()" (yet still employing "NO_SYNC") - Ch2 shifts right - sync lost!

     

  • cb1,

    I have been able to duplicate Eric's issue as well - I can get it to come up and stay unsynchronized even when it should be sync'd.

    I will seek enlightenment from the product team and report back.  It's very possible that I have a bug in my code.

    JW

  • @John,

    Kindly revisit my post of 14:32 - in which I report that I can "sync" while using param, "NO_SYNC." (our posts crossed)

    However - PWMSyncTimeBase() always is required - our Stellaris & LX4F system.  (under paid, IAR 6.60)

    The code sequence we've past used - and which we continue to employ (we've not yet been able to cause it to fail:)

     w/in PWM_INIT: (this is an extract - not our full code - does convey the essence - this sync issue)

        ROM_PWMGenConfigure(PWM0_BASE, PWM_GEN_0, (PWM_GEN_MODE_UP_DOWN |       
                        PWM_GEN_MODE_GEN_SYNC_LOCAL | PWM_GEN_MODE_FAULT_LATCHED |
                                          PWM_GEN_MODE_DBG_STOP));  

        ROM_PWMGenConfigure(PWM0_BASE, PWM_GEN_2, (PWM_GEN_MODE_UP_DOWN |      
                        PWM_GEN_MODE_GEN_SYNC_LOCAL | PWM_GEN_MODE_FAULT_LATCHED |
                                          PWM_GEN_MODE_DBG_STOP));  

        ROM_PWMSyncTimeBase(PWM0_BASE, PWM_GEN_0_BIT | PWM_GEN_2_BIT | PWM_GEN_3_BIT);

    and w/in PWM_IntHandler:  call below made after our handler has updated pwm duty cycle...

        ROM_PWMSyncUpdate(PWM0_BASE, PWM_GEN_0_BIT | PWM_GEN_2_BIT | PWM_GEN_3_BIT);

    Unless something's changed w/in rebrand SW - suspect this will solve Eric's (and your) Sync issue...

  • cb1_mobile said:
    However - PWMSyncTimeBase() always is required

    As support - here leading edge of both PWM Channels - but w/out call to "PWMSyncTimeBase()."  No chance that these signals are "sync'ed" - even though both have identical freq, period & pulse width. (Note: pwm width was adjusted to be identical here - so that the "edges" of "Sync'ed" PWM Generators could be properly examined.  This was not done in earlier captures - as different pulse widths were employed so that predicted channel overlap would not mask results.)

      

    And - trailing edge of same signals - same conditions as above...  Sync again absent...

    And now - identical set-up - but after call to, "PWMSyncTimeBase()."  And - this is as expected... "SYNC!"

    Facts in evidence seem overwhelming - favor the requirement for, "PWMSyncTimeBase()'s" presence - when synchronization across multiple PWM Generators is desired...  (trailing edges indeed mirror this behavior)   Q.E.D.

  • Cannot possibly be anything further of conceivable value - this too-long subject...  Or not.

    Decided to learn why John could not seem to "break" Sync - and if I could cause multiple PWM Generator sourced outputs to be more obvious when, not Sync'ed.   Believe that mission - now accomplished...

    We note that John likely employed an 80MHz SysClock (work I present - this thread - @ 50MHz) - & his higher SysClock would tend to "mask" the loss of Sync. 

    Dawned that it is "usual" to enable the various PWM Generators in quick succession.  And - that this alone may enable outputs from different PWM Generators to, "masquerade" as Sync'ed - when in fact they are not!  That's the theory - here then - the practice:

         ROM_PWMGenEnable(PWM0_BASE, PWM_GEN_0); 
         ROM_SysCtlDelay(1660);
         ROM_PWMGenEnable(PWM0_BASE, PWM_GEN_2);  
         ROM_PWMGenEnable(PWM0_BASE, PWM_GEN_3);
        
        ROM_PWMSyncTimeBase(PWM0_BASE, PWM_GEN_0_BIT | PWM_GEN_2_BIT | PWM_GEN_3_BIT);

    Note the new delay forced prior to the Enable of PWM_GEN_2.  And - that we may selectively, "comment out" the call to PWMSyncTmBase().

    And the scope reveals: "Eureka" - that 1660 count, forced Delay, caused a targeted 100uS Loss of Sync.  (In fact - a wide range of such signal separations can be created - my choice of 100uS was illustrative.)   And is repeatable - and results from delaying the Enable of that 2nd PWM Generator.  Again - for this run SyncTimeBase is bypassed.

    Now - let's uncomment that, "PWMSyncTmBase()."  And the result is...  (SYNC - but of course...)

    No other changes were made - at all. (I kept that same 1660 delay)  When I dialed the time-base to sub 1uS - perfectly over-lapped rise/fall edges of each PWM channel revealed thus real, "Sync" was realized.

    Note my PWMGenConfig():  (one Gen shown - others similar)

          ROM_PWMGenConfigure(PWM0_BASE, PWM_GEN_0, (PWM_GEN_MODE_UP_DOWN |     
                     PWM_GEN_MODE_GEN_SYNC_LOCAL | PWM_GEN_MODE_FAULT_LATCHED |
                     PWM_GEN_MODE_DBG_STOP)); 

    While, "GEN_SYNC_LOCAL" is useful in our App - "NO_SYNC" may also be used.  The "Sync" w/in this function applies to the, "when & how" any updates to the PWM outputs are applied - and not to the "Sync" between different PWM Generator outputs.  That remains the role of: "PWMSyncTimeBase()!"  (perhaps noted - this reporter - 7,8 posts up (& only later, finally acknowledged))

    Those alert/seeking extra credit may realize that this tunable/selective delay of PWM Generator outputs - prior to the call of, PWMGenEnable() - may allow an unexpected "phasing control" between multiple PWM Generators.  In the short (30 minutes) time I ran/observed - the repetition appeared stable.  Should state that results - this specific post - were achieved w/SystemClock @ 50MHz (= PWMClock) and PWM freq. of 5KHz & under StellarisWare 9453 using LX4F MCU...

  • My case is that PWMSyncTimeBase did syncrhonize two PWMs but the phase has 1 to 4 PWM clock cycles. I set the PWM clock divide by SYSCTL_PWMDIV_16. 320ns per PWM clock. The phase variation is 0 to +/- 1.2us.  I will create a standaonly project to share with you to repeat the issue which I had.

  • In addition - and as always - some mention of MCU in question, Software in use (w/ver number) and - if possible - scope caps similar to those shown.  Does this happen on more than one board - and one MCU?  (my tests - yesterday - ran over 2 different boards - both M3 (may they rest in peace) and M4. 

  • Hi again Eric and cb1 -

    After spending some time looking at my code, I moved the location of the call to PWMSyncTimebase to after the PWMGenEnable function calls, and this, along with using LOCAL instead of GLOBAL, seems to work.  I was able to duplicate cb1's results with no problems.  Source file is attached.  It seems that the order that the functions are called in makes a difference in the sync operation.

    Eric, give this a try and see what you get.  It's virtually the same as yours, except I inserted the delay as cb1 did to force out of sync operation so I could test it.

    JW

  • Hi John,

    Good - glad that you persisted and achieved success.

    Really do believe that the "rapid fire calls" to, "PWMGenEnable()" - combined w/your likely SystemClock @ 80MHz - led you down that early trail. 

    Might your confirmation of my multiple, posted Sync results - along w/imaginative use of delay to first diagnose and then "break" your "Masquerade of Sync effect" - result in a Green Verify tick?  (we independently have confirmed that guidance supplied can both Sync & UnSync multiple, PWM Generator outputs - seems a reasonable & well earned reward...)

     

  • 0121.pwm_test.zip

    Please see attached complete project which is developed under IAR. I think it should be very easy to be changed to other compilers.

    Logic:

    Loop the following:

    Turn on PWM for 5sec

    Turn off PWM for 1 sec

    PWM: period = 100 PWM cycles; c_trigger start at 50PWM cycles; l_trigger starts at 60 PWM cycles; One PWM cycle is 320ns;

    Measurement results:

    I measured the outputs at different PWM on time; we can see the phase between different PWM are shifted.

    PWMSyncTimeBase is called before and after the PWM is enabled.

     

  • @Eric,

    Plot thickens - yours do not much resemble my PWM traces - and do not look like "normal/customary" PWM waveforms to me, either. 

    And - after quick review of your code - believe I know why:

    See no calls whatsoever to: "PWMGenPeriodSet()" nor to:"PWMPulseWidthSet()" - are not both required? (both indeed appear - each/every PWM example provided w/in StellarisWare...)

    Note further that you freely mix use of PB6 & PC4 - both as GPIO Output triggers & later as "suspect" PWM outputs - but that PWM function seems most unlikely without the critical function calls - as I list above.

    Thus - your issue appears not to be one of Sync - instead one of proper set-up & config of each PWM Generator.  And of course this must occur prior to any attempt to, Sync!

    For clarity - I paste here the long-standing PWM example w/in SW-DRL-UG9453: (confirms the need - outlined above...)

    // Configure the PWM generator for count down mode with immediate updates
    // to the parameters.
    //
    PWMGenConfigure(PWM_BASE, PWM_GEN_0,
    PWM_GEN_MODE_DOWN | PWM_GEN_MODE_NO_SYNC);
    //
    // Set the period. For a 50 KHz frequency, the period = 1/50,000, or 20
    // microseconds. For a 20 MHz clock, this translates to 400 clock ticks.
    // Use this value to set the period.
    //
    PWMGenPeriodSet(PWM_BASE, PWM_GEN_0, 400);    // Missing
    //
    // Set the pulse width of PWM0 for a 25% duty cycle.
    //
    PWMPulseWidthSet(PWM_BASE, PWM_OUT_0, 100);   // Missing
    //
    // Set the pulse width of PWM1 for a 75% duty cycle.
    //
    PWMPulseWidthSet(PWM_BASE, PWM_OUT_1, 300);   // Missing
    //
    // Start the timers in generator 0.
    //
    PWMGenEnable(PWM_BASE, PWM_GEN_0);
    //
    // Enable the outputs.
    //
    PWMOutputState(PWM_BASE, (PWM_OUT_0_BIT | PWM_OUT_1_BIT), true);

    Now the above example did not attempt to, "SYNC."  My repeated direction - employ "PWMSyncTimeBase()" post PWM Generator Enabling - achieves that objective - when added...

    This post has moved far from its original, "PWM-SYNC Issue" (which has been exhaustively reviewed - and conclusively solved!)   I leave you now in John's able hands...(and you are welcome...)

  • 4382.pwm_test2.zip

    In order that we talk in the same way, I modified the code with library function only. The period and width are set with PWMGenPeriodSet and PWMPulseWidthSet.

    PWM cycle = 320ns; C_TRIGGER: width = 10 PWM cycles; L_TRIGGER width = 6 PWM cycles. I made the PWM operated at UP_DOWN mode which similiar to your example.

    From calculation, the distance between two rising edge shall be 2 PWM cycles; 640ns. The measurement showed that the distance is at 960ns mostly; occasionaly it is back to 640ns. Whatever the hardware does, it shall be consistant in one way or the other. The PWM width are always correct (C_TRIGGER 10 PWM cycles, L_TRIGGER 6 PWM cycles).

    I suspect TI PWM implementation has hardware bug; or my lib function calling sequence is incorrect.

    For many of your case, you may choose divide by 1, so you will notice 1 PWM clock shift. Our project does care 1 PWM clock.

  • Hi John,

    Have you got chance to run my code and repeated the problem?

    I have modified my code with SYNC_LOCAL parameter and the result is same as NO_SYNC.

  • Hi Eric,

    I tried your code, with the SYNC_LOCAL put in as you did, and I got the same results you did.  I am working with the BU to try to identify a solution.

    Thanks,

    John

  • In up down count mode the pwm will sync at the center. And what cb1 has posted shows same result if I'm not mistaken and are perfectly synchronized.

  • In case anyone is still interested in the answer to this issue (as I was), the problem lies in the use of PWMSyncTimeBase when the PWM Clock Divider is set to something other than 1. This is explained in the errata for the device family, called "Stellaris LM3S Tempest- and Firestorm-Class Microcontrollers Errata". It is currently available at http://www.ti.com/product/LM3S9B96/technicaldocuments. To work around this issue, I replaced my call to PWMSyncTimeBase with the following code (called after PWMGenEnable):

    SysCtlPWMClockSet(SYSCTL_PWMDIV_1);
    SysCtlDelay(800);
    PWMSyncTimeBase(PWM_BASE, PWM_GEN_2_BIT);
    SysCtlPWMClockSet(SYSCTL_PWMDIV_64);
    PWMOutputState(PWM_BASE, PWM_OUT_5_BIT, true);