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.

Synchronize PWM Generators of differnet PWM Modules

Hello Together,

I need to synchronize the periode of 12 pwm outputs on my tm4c123g for a project of my university. Six of the 12 outputs are generated by deadband generators. The problem is that I have to use two pwm modules and I don't know how I can synchronize all outputs.

Does anybody know whether it's possible and how I should do it?

And is it possible to do this with help of the driverlib?

Thank you very much in advance for your answer

  • Haven't an exact answer for you - but the 2 functions I will list below enable our group to harness 3 PWM Generators (totaling 6 PWM Outputs) to meet our sync specifications:

    PWMSyncTimeBase()
    PWMSyncUpdate()

    Indeed both are official functions w/in StellarisWare V.9453.  (you'll have to cross-check - to see if they continue w/in rebrandware...)

    Now my understanding is that (most) of this vendor's MCUs support up to 4 PWM Generators (totaling 8 outputs) per PWM base module.  Your requirement to sync 12 outputs likely exceeds the capability of one PWM base module - and may limit your "sync" of the "excess" four PWM outputs.  I don't believe either of the functions I've listed support multiple PWM base modules - but you must check.   A possible work-around would be for you to "co-locate" the most critical 8 PWM outputs w/in one base module - and to then call those functions in "back to back" fashion.   (such may prove adequate for most, "Gov't work...")

  • Thank you for answering so fast, but:

    In our current solution we synchronized eight outputs with the two functions you named in your answer and the other four are not synchronized with them.

    The problem is that all of the 12 outputs have the same priority, because we use them to control a three level inverter with space vektor control (12 IGBT). Out of this they all have to be synchronized

    I asked the comunity because I found the Statement "Synchronization in and between the modules" is possible in the paper "Getting Started with the TIVA TM4C123G LaunchPad Workshop". But there hasn't been any further Information.

    Does anybody know whether this is possible? And how?

  • Hello Thomas,

    On the TM4C123, there is no method to synchronize the 2 PWM Modules. However, it is possible to do indirectly if it is a one time event. If you are running at or below 40MHz System Clock then there is no problem, but when running above 40MHz, code placement would needed to be seen. How much applicable it may to be the application or if it causes a glitch is something we need to be careful though

    1. Program the PWM-0 and Synchronize the outputs and then shut the PWM-0 clock by writing HWREG(SYSCTL_RCGCPWM) &= ~(SYSCTL_RCGCPWM_R0);

    2. Program the PWM-1 and Synchronize the outputs and then shut the PWM-1 clock by writing HWREG(SYSCTL_RCGCPWM) &= ~(SYSCTL_RCGCPWM_R1);

    Now enable both the clocks simultaneously

    EDIT STARTS ---

    3. Now enable the clocks to both the PWM's by writing the clock enable register HWREG(SYSCTL_RCGCPWM) = 0x3;

    EDIT ENDS---

    This will ensure that both PWM will start together if the code state takes the same time.

    Also do make sure that IntMasterDisable is called before and IntMasterEnable is called after the above steps to prevent an interrupt from breaking the sequence.

    Regards

    Amit

  • @Amit,

    That's a good, resourceful extension of the "byte limited" PWM modules.

    Perhaps others share my uncertainty with your step 3, "Program the PWM-0 and Synchronize the outputs and then shut the PWM-0 clock..."

    With the PWM_0 clock disabled - can the PWM_0 module continue to function - and generate time appropriate PWM signals?   And - almost appears to be "cut/paste" and/or "sentence float/fragment error" as we've already been instructed to "Program the PWM_0 and Sync Outputs" - thus the repetition here seems w/out full merit... (or - at minimum - deserves some detail/description...)

  • Sounds good, I'll try it.

  • Hello cb1,

    Yes, you are right about that. It was a really a "cut-copy-paste" mistake. Made the amend to the original post so that it does not gets lost in translation.

    Regards

    Amit