cancel
Showing results for 
Search instead for 
Did you mean: 

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

SPhil.3
Associate II

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 -

7 REPLIES 7
TDK
Guru

Include your chip part number.

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

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

STM32L475

Polarity is applied *after* the combiner:

0693W00000Bbq8yQAB.pngJW

SPhil.3
Associate II

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

0693W00000BbqIPQAZ.jpg 

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
Associate II

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

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