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.
Hello,
I'm trying to synchronize PWM channels 3, 6 and 7 in a Piccolo 28069 with the TBCLKSYNC bit. They have periods that are multiple of each other.
If I set all counters (TBCTR) to 0, it works fine. All the PWMs are synchronized and the counters all start at the same time.
But if I want to preset one of the counters to a different value, the phase shift does not make any sense. Seems to be a random value, but consistent every time I run it.
Does anybody know if the TBCLKSYNC feature has any bug?
Thanks,
Max
Max,
There is nothing wrong with the TBCLKSYNC feature as far as I know. I've attached to this post a F28335 CCSv5.3.0 example that has ePWM1, 2, 3, and 4 synchronized using the approach you described. That is, initializing the TBCTRs to different values and then starting all ePWM clocks together using TBCLKSYNC. F28335 code is what I happened to have and could dust off. The same thing will apply to F28069. Just look in the ePWM.c file to see what I did, and you can copy for F28069. I tested this code today, and it works. The four ePWMs are offset by 0%, 25%, 50%, and 75% of the period.
The other approach to synchronizing the ePWMs is to use the synchronizing/phasing hardware in the ePWM modules. That is, TBCTL.SYNCOSEL bit, and TBPHS register. This allows you to change the phasing on-the-fly, whereas with the TBCLKSYNC method the phasing is statically configured at init time. You asked about the TBCLKSYNC method, so that is what I provided in my example.
Good luck and regards,
David
David,
Thanks for the answer.
We implemented the real-time synchronization method (TBPHS) and works fine.
We usually use the real-time method but in this application we wanted to have synchronized non-consecutive PWM channels, that's why we wanted to use the static method.
We are going to keep the code you sent in case we need to use TBCLKSYNC in the future. We may have had a mistake in our code.
Regards,
Max