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.

TMS320F28388D: EPWM sync in tms320

Part Number: TMS320F28388D


Hello,

Kindly help me with the following:

1. How exactly is synchronising two  PWM works. Kindly explain what all ways are there to achieve the same .

2. What all configurations should be taken care from the code side  to implement the same .

I have red the trm , datasheet and failed to get an idea, the exaple code for the same also doesnt work much .This is an emergency situation kindly replay fast .

Thanks and regards,

Stevin 

  • Hello Stevin,

    I'm not certain how much experience you have with the ePWM, so I'll start at a basic level and work up, alright? If this is too long, a succinct version is at the end of the post, after my signature. Additionally, key notes are bolded to easily be noticed.

    If we have 2 different ePWM modules, at the most basic level we just have 2 different counters and quite a bit of logic that reacts to those counters in the form of the CC, AQ, DB, etc. submodules. There is really only 2 things that affect those counters:

    1. Time-Base submodule configuration
    2. Sync-In signals from outside the ePWM

    (This is a bit of an oversimplification, but I believe it works well for explaining the usage of the synch scheme)

    Now, of these 2 options, the TB submodule configuration is done at the beginning of the program and is designed behavior. The TRM section 26.4 goes over all available options for this initial configuration. What's important to us right now is the following excerpts:

    • Figure 26-5, an overview of the Time-Base Submodule from a logic perspective
      • Look through this image to find where the Sync-In or 'EPWMxSYNCI' signal is located. Notice how it's only in one spot?
      • If you follow the wire this is connected to, after the OR gate, you come to a switch controlled by TBCTL[PHSEN], or Time-Base Control[Phase Enable].
        • Effectively, what this means is that the only way for the ePWM Sync-In signal to affect the CTR is if PHSEN=1
      • Next, look at the name of the port on the counter that this wire connects to- "Load." This means that the Sync-In signal controls a "loading" functionality for the TBCTR. Remember this, it's important!

    • Figure 26-10, an example of Time-Base Submodule behavior in count-down mode
      • There are numerous examples of these waveforms, but this one is particularly useful for explaining the behavior of the EPWMxSYNCI signal
      • First, look at the EPWMxSYNCI signal- the sync-in signal is a pulse that affects the system, not a constant signal.

    Now, we finally arrive at the succinct explanation on how does ePWM synchronization work? As you can see from the figures and explanation above,

    When an ePWM receives a Sync-In pulse, it loads the value stored in the TBPHS (phase) register, replacing the current value of the TBCTR.

    For example, if '150' is stored in TBPHS, and the counter is at 250, counting up to a period of 350, we would expect a Sync-In signal to set the counter value to 150, counting up to a period of 350. By default, TBPHS is 0.

    Each ePWM is capable of a receiving a Sync-In signal from numerous places (listed in the TRM section 26.17.2.3 ). If you look at that list, you'll notice that many of the options are EPWMx.SYNCOUT. If you look back at the first figure I posted, you'll see that each ePWM is capable of generating a sync-out pulse in reaction to various events, such as reaching CTR=0. If TBPHS is 0 and SYNCOUT is generated at CTR=0, then the receiving ePWM counter should be identical to the sending ePWM counter!

    I hope this explanation helps,

    Jason Osborn

    Summarized version:

    • Each ePWM can send or receive a synchronization pulse. When an ePWM receives a synchronization pulse, it replaces the current CTR value in the TB submodule with the value stored in TBPHS. This perfectly synchronizes the two signals. If TBPHS =/= 0, the receiving ePWM is offset from the sending ePWM by the amount stored in TBPHS.
  • Hello Jason ,

    Thanks for such a great explanation . I really understood how pwm module get into work or rather handles a pwm sync in signal.But i really want to understand how this signal gets into pwm module
    From what i have red in TRM i have came to know that there are 2 ways we can generate the sync out signal.

    1. Here one PWM module is set as Master PWM which provide sync out signal to all other pwm modules.say i have 3 PWM modules . PWM1 can send SYNC out pulse to PWM2 and PWM3
    so that  PWM2 and PWM3 can be configured to receive  SYNCOUT signal form PWM1.

    2.The second way is something i have no idea about but it is shown in PWM synchronisation example. Here we are using PWM1 to generate Sync out signal which is routed to INPUT XBAR 5
    and INPUT XBAR 6 , and a gpio is also configured. The end point of this signal is fed to epwm modules we use parallely as an EXTSYNC signal . AM not sure if the signal routing and understanding of mine is good.
    Kindly help me with this too .

    See this post in e2e which supports this , but the post doesnt give a clear idea of this methord nor the TRM.:

    e2e.ti.com/.../tms320f28388d-synchronize-epwm-modules-with-external-signal-on-gpioxx

    Can we agree that if method one is sequential method of synchronising pwm , 2 nd method is parallel way to synchronise all pwm together?


    Thanks and regards,

    Stevin Martin

  • Hello Stevin,

    Your first point is correct, yes. The second, though, is just a little bit off. Take a look at the device's TRM, section 26.17.2.3, table 26-26. Specifically, look at options 0x18 and 0x19:

    The X-Bar allows the user to route external signals into the ePWM. Basically, to summarize that post, they are not setting every other ePWM secondary to ePWM1. Instead, they're setting every ePWM- including ePWM1- as secondary to an unspecified signal that's coming from outside of the C2000.

    The epwm_ex3 example is a little confusing in that regard. I didn't realize the XBAR was being enabled- I'm not entirely certain why the XBAR is being used at all here, it's not being used to synchronize the ePWMs, as far as I can tell.

    Anyway.

    To summarize;

    • Each ePWM can be configured to send out a synchronization pulse via EPWMSYNCOUTEN, which also defines what causes the sync event to occur.
    • Each ePWM can be configured to receive a synchronization pulse via EPWMSYNCINSEL, which defines which input is routed to the sync-in port of the TB submodule.
      • Among the options for EPWMSYNCINSEL are; every single ePWM SYNCOUT signal (as well as similar signals from a couple other peripherals), as well as 2 INPUT-XBAR ports.
    • The Input XBAR is, more-or-less, a bus that lets us connect C2000 internal and external signals and ports more freely.
      • For the ePWM, this is relevant because (if you want), you can send a manual synchronization pulse into a chosen GPIO and use the XBAR to route that GPIO as the SYNC-IN signal for your ePWMs, assuming you've correctly configured EPWMSYNCINSEL.

    Does that make sense?

    Regards,

    Jason Osborn