cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L476RE: Can I have two timers (TIM2 and TIM3 for example) using the same external clock source?

philipweiss
Associate II
Posted on October 27, 2017 at 00:54

I need to create two synchronized signals.  I'd like to use a PWM output for one, and to have the software create the second signal based on an interrupt from the same clock used to create the PWM output.

I'd like to use STM32CubeMX, but I couldn't find a way synchronize TIM2 and TIM3, or make them use the same external clock source.

8 REPLIES 8
Posted on October 27, 2017 at 02:01

I don't understand. Draw a diagram.

JW

Posted on October 27, 2017 at 02:31

Thank you for your prompt reply.

I hope that this helps:

0690X00000608SrQAI.png
Uwe Bonnes
Principal II
Posted on October 27, 2017 at 11:13

Easiest way is to connect the input signal to the TIXx_ETR or TIMx_TI1 pins of both timers.

Posted on October 27, 2017 at 10:18

You could use CH1 or both timer connected together to have a common clock source (pin)

You might also use a single timer with long period and use 2 output channels, the one with slowest period as output compare and the other one using DMA to make burst of pulses during the same period.

Posted on October 27, 2017 at 10:56

I may be exceptionally dumb but I still don't understant. Do you want TIM2 to output a PWM based on external clock, and then feed that PWM generated by TIM2 as an input to TIM3 and measure its duty cycle or frequency? But duty cycle is under your control as it's generated by TIM2, so why would you want to do that? 

And what is 'Software Controlled Digital Output' to be output from TIM3, a 1:1 waveform with varying frequency?

JW

Posted on October 27, 2017 at 17:45

The 'Software Controlled Digital Output' signal is a waveform with varying frequency.  I was planning on bit-banging out a manchester-encoded data stream.

Posted on October 27, 2017 at 17:47

I will look at output compare on two channels.  That seems like the simple answer I missed when I was looking at the hardware manual.

Posted on October 27, 2017 at 17:49

Thank you.  I will verify that I have both pins available.