2017-01-31 02:25 PM
I want to synchronize micros that each have their own clock. Is that possible? I was thinking of having a Master control the synchronization with GPIO. Essentially, when the pin is high (or low), you start whatever you want and since I told them to start at the same time. In my case, I want to output digital pulse trains from each slave micro, but with 'accurate' timing between the two (I am talking 10 ms timing). My only worry is that the different clocks do not fall and rise at the same time, but since those clocks are in the Mhz, it is way above the magnitude of the timing I actually need. I guess if I start the process with the GPIO and make the rise and fall times controlled by software delays, that would work? Does that sound feasible or stupid? Sorry if this sounds all over the place....
#synchronize-micros-with-independent-clocks2017-01-31 02:47 PM
I want to output digital pulse trains from each slave micro
What sort of 'output digital pulse trains'? How do you intend to output that from one micro (forgetting the synchronicity problem for now)?
JW
2017-01-31 03:31 PM
hi,
this is a good example of Input Capture using timers
have the master put out a 1mS timing PWM pulse train.
the slaves can capture each successive rising edge, then with the captured difference in time, the software can calculate its timer source frequency.
However,
if you enable the Input Capture interrupt, then all of your micros will be in the exact same interrupt byte within 1uS.
but you must make sure that it is the highest priority interrupt.
the Interrupt is primarily used to lock all processors to the 1uS.
all slaves will enter this highest priority interrupt within a few clock cycles, hence the 1uS suggested jitter.
aside:
another function inside this interrupt would be to calculate the timer frequency, which is not needed but an exercise of understanding. This will also allow you to verify the actual processor clocking rate.
2017-01-31 04:11 PM
Depending on the STM32 that is being used you can time-stamp edges finer than 10ns against the local clock. One could use TIM+DMA+GPIO to capture signals with a regular interval. Suspect you will run out of resources if you have many pins/slaves.
On the other hand 10ms is a long time, you'd be able to use interrupts.
Can you share a time-base with the slaves?