cancel
Showing results for 
Search instead for 
Did you mean: 

Starting two timers synchronous

shadowrunner92
Associate II
Posted on January 12, 2012 at 21:59

Hello everybody!

In my program I have to start two timers exactly at the same time. In my current code I start them behind one another (just one line of code each) but unfortunately the error with this method is too large.

I'm not really into the possibilties a STM32 �C provides, maybe you can give me some tips or even an example code where this problem is solved.

Some facts about the timer-settings:

Timer1 is in PWM-Mode, triggering the ADC.

Timer4 is in OnePulse-Mode.

Hope this problem isn't very hard to solve ;)

Thank you in advance!

#start-two-timers-synchronously
3 REPLIES 3
Posted on January 13, 2012 at 00:50

Could you use different channels on the same timer?

Draw a diagram illustrating the desired relationship the two signals. Or some more specifics.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
shadowrunner92
Associate II
Posted on January 13, 2012 at 13:58

I'll give you a short explanation so that you get an overview of what I want to do :)

I want to measure the saturation current of an inductor, so I have to short-circuit the coil for a certain time and sample the voltage over a shunt to get the current-value.

Timer4's work is to generate the pulse with its certain length.

Timer1's work is to trigger the ADC to get samples every exact interval during the on-pulse.

Everything works, except the first sample which is wrong because of the delay resulting of starting the two timers seperately.

In the reference manual there's a chapter called ''Starting 2 timers synchronously in response to an external trigger''. I think that's exactly what I want to do.

What do you think about that? :)

Greetz

Christoph

firatparlak
Associate II
Posted on June 27, 2013 at 11:02

Hello Clive,

I searched my issue in the forum and found this topic, so I don't open a new topic about my issue.

I want to start two timers synchronously. Both of the timers will be used as PWM output mode. One of the timer is 2MHz clock output.(PWM) and another is 8KHz clock output.(also PWM)

There are two option for me. 

First: I can use TIM3_CH1 and TIM3_CH2. But I can set period and prescaler value to 2MHz or 8KHz. I can't set both of two values in one timer.

How can I set two different values in one timer?

Second: I can use TIM3_CH1 for 2MHz and TIM2_CH4 for 8KHz. When I set both of them, there are right values but they are not synchronous. So this is a problem for the system.

How can I set and start two timers synchronously?

I'm waiting for your kindly help.