cancel
Showing results for 
Search instead for 
Did you mean: 

Timer Synchronization Issue

pant
Associate II
Posted on June 25, 2015 at 19:11

Hello everyone,

I would like to ask your ideas about something I would like to implement. I would like to have a constant timer at 50KHz (TIM1) and based on this timer, start with some specific offset a second timer at 200KHz (TIM2).

I did it in my code, but what I did will definitely not work once my code becomes heavier, because it is affected by interrupts and stuff.

Therefore I am trying a more efficient and accurate way to do it. A solution I thought would be to use a third Timer (TIM5) in master one pulse mode, and in output compare and once he gets the value of the wanted offset, trigger the second timer (TIM2), which would be in slave mode.

However in order to implement this idea I have one problem. How am I going to start the third timer (TIM5)? I was thinking of starting it in every iteration of TIM1, once the code enter the interrupt generated by TIM1. However that won't be very accurate since there will be some delay between the two Timers. On the other hand I can't find a way to set TIM5 as master and at the same time trigger it using TIM1.

What do you think?

Thank you in advance.

Regards,

Pantelis

#stm32f4 #slave #timers #master
1 REPLY 1
pant
Associate II
Posted on June 25, 2015 at 20:14

Hi again,

I returned to present to you a second idea I had. Since I use PWM1,2,3 of TIM1, I was thinking of using PWM4 of TIM1 as an external triger for TIM2 with a duty cycle equal to the time offset I need between the two timers. What do you think? Is there any way to do this internally without external wires?

Regards,

Pantelis