Sending a one-time-pulse on multiple timers, synced with the same start time
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-08-28 02:19 PM
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?
Solved! Go to Solution.
- Labels:
-
STM32F3 Series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-08-28 03:24 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-08-28 03:24 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-08-28 04:43 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-08-28 11:24 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-08-29 04:11 AM
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.