cancel
Showing results for 
Search instead for 
Did you mean: 

Sending a one-time-pulse on multiple timers, synced with the same start time

LMorr.3
Senior II

I have an array of times, currently TIM3 and TIM4 on a STM32F373.  I may want to add more timers in the future, so I enable them in a loop.  Is there a way to ensure they all start at the exact same time or will the loop iteration be so fast that they will look synced on a scope?  I'm also thinking an interrupt may occur while the loop is in the process of enabling timers, causing them to start out of sync.  

Is the only way to use the external interrupt with a master timer and have all other timers as slave?  ( can I trigger it in software only, eg. setting a master timer to expire after 0 ticks?

1 ACCEPTED SOLUTION

Accepted Solutions

That depends on your requirements. If you disable interrupts during enabling timers, and set them up beforehand so that the delay in software is compensated (i.e. set CNT of the first enabled timer to 0, second to around 4-6, third around 10-12 etc.), you can achieve zero or only a few cycles of difference.

JW

View solution in original post

4 REPLIES 4

That depends on your requirements. If you disable interrupts during enabling timers, and set them up beforehand so that the delay in software is compensated (i.e. set CNT of the first enabled timer to 0, second to around 4-6, third around 10-12 etc.), you can achieve zero or only a few cycles of difference.

JW

In my case I always send a 5ms one-time-pulse out of all timers.  I think in my case I can disable interrupts, enable the timers in a loop and compensate for when the pulse stops but I guess there will still be some cycles of different when I enable the timers.

You always can use the master-slave connection, and trigger several slave timers from one master timer, You need to plan this well as not all timers are interconnected.

But if all timers output a pulse of the same width at the same time, why do you need several timers at all? 

JW

Ok thanks.  The timers generating the one-time-pulse will at most times be in sync starting at the exact same time, but other times they will need to start a few hundred ms based on calculations made.  So it the cases where they need to start at the same time, I need a way to trigger them.