Skip to main content
SPhil.3
Associate II
June 23, 2021
Question

Timer in combined PWM mode question - how to set the polarity of the reference PWMs?

  • June 23, 2021
  • 7 replies
  • 2539 views

Can the combined PWM signal be the AND of two reference PWMs in which one is negated?

This is what I would like to do.

Combined PWM signal = OC1Ref AND NOT(OC2Ref)

If I could set the polarity of the two reference PWMs differently, I think that would work. I just don't now how to configure it that way. Are there any code examples for using the PWM in combined mode?

Thanks -

This topic has been closed for replies.

7 replies

TDK
June 23, 2021

Include your chip part number.

"If you feel a post has answered your question, please click ""Accept as Solution""."
SPhil.3
SPhil.3Author
Associate II
June 23, 2021

Sorry, I forgot to add that to my original post.

STM32L475

waclawek.jan
Super User
June 23, 2021

Polarity is applied *after* the combiner:

0693W00000Bbq8yQAB.pngJW

SPhil.3
SPhil.3Author
Associate II
June 23, 2021

Thanks for the reply. So it looks like I cannot implement the following logic using the combined PWM mode feature.

0693W00000BbqIPQAZ.jpg 

waclawek.jan
Super User
June 23, 2021

What is your desired output waveform?

As PWM1 and PWM2 modes are effectively mutually inverted, you might be able to achieve the same effect using more channels.

JW

SPhil.3
SPhil.3Author
Associate II
June 24, 2021

Here is an example waveform. Effectively, the channel outputs only drive high when there is a difference between the two reference PWM outputs.

CH1 goes high when OC1 is high and OC2 is low. CH2 goes high when OC1 is low and OC2 is high. If OC1 and OC2 are both high or both low, CH1 and CH2 stay low.

0693W00000BbqzTQAR.jpg

waclawek.jan
Super User
June 24, 2021

As I've said, use PWM1 mode in one channel and PWM2 in the other, to generate one of the waveforms. Then use channels 3 and 4, withc CCRx having copied from CH1/CH2, with PWM1/PWM2 set exactly to opposite as in CH1/CH2 and use that to generate the other waveform. As the matter of fact, when Combined AND mode is used, the channel where the AND is performed works as PWM2 anyway.

JW