2020-02-27 10:05 PM
Hi,
I am using STM32F072VBT6. I need a PWM waveform output that is gated with a PWM output of another timer channel.
I am using TIM3_CH1 as the master that will control the output of another PWM of TIM2_CH1. Please refer the image for clarity. I need waveform (C) as output. So far, I am able to generate waveforms (A) and (B) separately, now I need the gated output. Is it possible by software? Or should I use a AND gate IC externally?
Solved! Go to Solution.
2020-02-27 11:56 PM
In TIM3, set CH1 (OC1REF) as TRGO in TIM3_CR2.MMS.
In TIM2, set TIM3 as TRGI source (in TIM2_SMCR.TS, see "internal trigger connection" at the end of TIM2_SMCR subchapter), and set Gated Mode in TIM2_SMCR.SMS.
JW
2020-02-27 11:56 PM
In TIM3, set CH1 (OC1REF) as TRGO in TIM3_CR2.MMS.
In TIM2, set TIM3 as TRGI source (in TIM2_SMCR.TS, see "internal trigger connection" at the end of TIM2_SMCR subchapter), and set Gated Mode in TIM2_SMCR.SMS.
JW
2020-02-28 12:46 AM
The period of the master should be an exact multiple of the period of the slave, i.e. (TIM3->ARR + 1) % (TIM2->ARR + 1) should be 0, because the master PWM is gating the slave counter, not the output. Otherwise the TIM2_CH1 output would sometimes remain high, if TIM3_CH1 goes low at the wrong time.