2019-04-30 12:31 PM
Is it possible to do this? I need to shift PWM2 by 180 degrees from PWM1. On a test board I am doing this with two timers, with the second timer picking up the count from the first and adding period/2. The current board will not allow this.
I hope it is possible with a single timer and PWM1/PWM2...any suggestions on how this could be accomplished?
Thanks for your help.
2019-04-30 12:37 PM
ST's TIM design has a single counting (phase) element
PWM2 should be anti-phase with PWM1. You can expand the low portion of PWM2 by pushing out the CCR value
2019-04-30 01:55 PM
hi, thanks for the reply. An objective is to generate a specific number of pulses. In the TIM2 interrupt, I can count the pulses and then disable the timer. However, PWM2 remains high after that. How can it be reset at that point?
Also - ccan you explain what "expanding the low portion of the CCR value" (register) would do? And would this be achieved by directly writing it?
2019-04-30 02:00 PM
LL_TIM_CC_DisableChannel kills the output, so that is now OK. Could you still clarify what you meant by expanding the low portion of the CCR value. Thanks!
2019-04-30 02:24 PM
You didn't care to tell us which STM32 are you using.
Newer STM32 like the 'L4 or 'F7 come with timers which (some of them) have so called assymetric and combined pwm modes. These are designed to allow you to generate phase shifted waveform, at the cost of using 2 channels for one output.
JW
2019-04-30 02:37 PM
PWM1 -------\__________________
PWM2 _______/------------------
^CCRx == CNT
In PWM1 the CCRx value determines the length of the HIGH signal, in PWM2 it is the length of the LOW signal
2019-04-30 02:46 PM
it's the STM32L476. So far using LL drivers I think this seems to be working out. Using TIM3, I can generate PWM1/PWM2, with PWM2 phase shifted ever so slightly by the differential of the duty cycle. And I can generate the exact number of cycles as well. Thanks!
2019-04-30 02:50 PM
Ah, thanks. That should be enough to work with.