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.

TMS320F280040-Q1: What does initial Counter Value does?

Part Number: TMS320F280040-Q1
Other Parts Discussed in Thread: SYSCONFIG

Hello,

I try to create a 90 degree phase shift between PWM2 and PWM3.

I accidentally set the Initial Counter Value of 31 for PWM2, instead of Phase Shift value. And set the Phase Shift Value of 62 for PWM3. Then I got two signals with 90 degree phase shift.

Later I realize the the Phase Shift Value for PWM2 should be set 31, not the Initial Counter Value. Then I set the Phase Shift Value as 31 and set the Initial Counter Value back 0. Then there is no phase shift between the two signals. 

Why it is like this? Isn't it supposed to set values for Phase Shift Value for both PWM2 and PWM3?

Thanks!

Crane

  

  • Hello Crane,

    If I'm not mistaken, the important thing to remember here is going to be that the phase-shift operates based on a trigger, the sync-in pulse. In this case, when ePWM3 receives a sync-in pulse, the value is reset to the value stored in TBPHS, 62. However, as far as I can tell, you do not currently have this operation configured, meaning no phase shift will ever be applied. If you're trying to utilize this function to create an offset between two ePWMs and nothing else, then you need to add a software-forced sync pulse to your initialization. Take a look at Figure 18-8 from the device's TRM for a visual of this functionality:

    (Additionally, this requires PHSEN = 1 to function.)

    Meanwhile, the functionality to set the initial value of the counter simply assigns a value to the counter. If all you're trying to do is create an offset between two ePWMs with identical periods, setting the initial value is one way to do it. I prefer to utilize the counter-compare submodule to create offsets in my ePWM waveforms when I'm able to, but this works just as well!

    Regards,

    Jason Osborn

  • Also I dont see in your SysConfig view that you have enabled the PHASE SHIFT SYNCHRONIZATION CHAIN. Did you do this? 

  • Thanks Jason! 

    Ok, as you said, after unchecking Enable the Phase Shift Load for both PWMs and leaving the initial value, there is still phase shift between two PWMs.

    Also you mentioned two things. One is to set Sync-in pulse and use Phase Shift Value to create the phase shift between two PWMs. Another one is to use Counter Compare module to create the phase shift. Are they two ways to create the Phase Shift or the two things for one way?

    I tried these settings and it works. Is this the way you mentioned? I didn't see PHSEN you mentioned.

    Regards,

    Crane

  • Thanks Nima.

    I didn't see where to enable PHASE SHIFT SYNCHRONIZATION CHAIN. Where module is it in?

    Regards,

    Crane

  • Crane,

    PHSEN is the register name for the 'enable phase shift' functionality- PHSEN, PH(A)S(E) EN(ABLE). 

    The time-base submodule phase shift is a true phase shift, adjusting the actual counter value, affecting the entire ePWM accordingly. Adjusting values in the counter-compare submodule, meanwhile, doesn't touch the counter, only affecting the duty cycle of the ePWMA/B outputs. Each has its own use cases.

    (I only recommended looking at the counter-compare submodule because you mentioned looking at the signal outputs, and adjustment of the CMPA/B values allows you to directly control the signal output behavior without necessarily affecting the behavior of the rest of the ePWM, such as SOC or interrupt generation.)

    Hope that makes sense,

    Jason Osborn

  • Ok got it.

    The reason I mentioned adjusting the Initial Counter Value was because I accidentally found that works. Now based on what you said, I found how how to set Phase Shift Value to create phase shift between two PWMs.

    Next I need to create a signal which is relevant to both PWMs (PWM2 and PWM3 with 90 degree phase shift). Which module do I need to use to achieve that? Any advice? 

    Thanks!

    Crane

  • Crane,

    When you say 'relevant to', what exactly do you mean? A signal that both ePWMs depend on, a signal that depends on both ePWMs, or a third ePWM reliant on both of them?

    Regards,

    Jason Osborn

  • Hi Jason,

    Yes, the third PWM's rising and falling depends on the other two's rising.

    The way I do it right now is to calculate the counter value of the rising edges of the first two PWMs and use those numbers to generate the third one. It works. But when the frequency of the first two PWMs are changed (the first two has the same frequency), the same calculation seems not working any more.

    Regards,

    Crane

  • Hello Crane,

    The ideal answer would be to assign this behavior to the ePWMB channel of one of the two existing ePWM modules, assuming they're not currently being used. If they are being used, I would refer you to the suggestions of this thread to utilize the device's CLB.

    Regards,

    Jason Osborn

    (Alternatively, I believe you could utilize PWM linking to copy the CMPx values of the primary ePWM modules into the third one, but without knowing more about your calculation scheme I cannot guarantee this would work. The CLB is more likely to be the superior option if it's anything more complicated than just copying the values of the other ePWMs.)

  • Ok I will take a look at how to use CLB. 

    But probably it is ok to use PWM linking as I just calculate the counter value of the rising edge of the first two PWMs and take them as the values to compare to CMPA and CMPB for the third PWM.

    Regards,

    Crane