cancel
Showing results for 
Search instead for 
Did you mean: 

Connect two timers in Gated Mode

smrtkai
Senior
Posted on November 10, 2015 at 09:42

Hi,

unfortunately I haven't understood how to connect two timers. I want to achieve a 3,2kHz PWM switch signal that turns on and off a 1 MHz signal.

I try to setup TIM3 as a master timer; in STM32CubeMX I have selected ''Master/Slave Mode: Enable (sync between this TIM (Master) and its Slaves (through TRGO))'' and ''Trigger Event Selection: Output Compare (OC2REF)''.

For TIM4 as slave timer I selected ''Slave Mode: Gated Mode'' and ''Trigger Source: ITR0''

And that's where my understanding ends. As trigger source for TIM4 I would have expected something like TIM3-TRGO. Or some assignment for ITR0 to TIM3-TRGO.

Can someone please explain how TIM3 can be connected to TIM4? That would be great.

Thanks in advance for your help.
4 REPLIES 4
Posted on November 10, 2015 at 10:02

> And that's where my understanding ends. As trigger source for TIM4 I would have expected something like TIM3-TRGO. Or some assignment for ITR0 to TIM3-TRGO.

Read the fine manual, '' TIMx internal trigger connection'' sub-chapter of the relevant TIM chapter.

JW

smrtkai
Senior
Posted on November 10, 2015 at 12:00

Thanks.

For anybody who is curious what the fine manual is, here is the link:

http://www.st.com/web/en/resource/technical/document/reference_manual/DM00031020.pdf

ftiti
Associate II
Posted on November 10, 2015 at 18:17

Try to read and run the ''TIM_Synchronization'' FW example of the STM32Cube_FW_F4.

It talks about the synchronization between TIM1 as master and TIM3/TIM4 as slave which is configured in gated mode to output a PWM switched by the updated event comming from TIM1 with a configured rate (TIM1 Frequency/ repetition counter).

Explanation (Readme.txt):

The TIM1 counter clock is 180 MHz.

  The Master Timer TIM1 is running at:

  TIM1 frequency = TIM1 counter clock / (TIM1_Period + 1) = 703 KHz

  The TIM3 is running at:

  (TIM1 frequency)/ ((TIM3 period +1)* (TIM1_Repetition_Counter+1)) = 46.866 KHz and Good luck.

smrtkai
Senior
Posted on November 11, 2015 at 13:53

Thanks.

Should have had a look into that Reference Manual before. Haven't found it before. The answer is pretty simple. It's just a lookup for the slave's internal trigger ITRx to the master's trigger output TIMx_TRGO.