I have two of the devices (a while loop in the code) that need to start at the same time, within 50ms or less of each other. Each is using the same GPS module, and I am using "ARM® Cortex®-M3 Giant Gecko Microcontroller IC 32-Bit 48MHz".

The logic in the code, is as follows. Get GPS time, compare GPS time with start_loop_time. Time to start the loop? If not check again GPS time Else start loop on the next 32kHz rising edge pulse.

The biggest issue is the GPS queries on each device are sometime 700-800ms apart. This then can make each "while loop" start more than 1 sec apart.

Any suggestion to get the "while loop" to start closer to each other?

  • 1
    \$\begingroup\$ You will need to explain more about where that 700-800ms delay is coming from. If you are repeatedly checking GPS time it should not take 700ms to check it once. Why are the queries so far apart? \$\endgroup\$ – Glenn Willen May 25 '19 at 4:33
  • \$\begingroup\$ Hi, one GPS module could report. on one device, for example, 10:11:09.010 and another GPS module could report, on the other device, could be 10:11:09:800. Hope this helps. \$\endgroup\$ – Joseph_stack May 25 '19 at 4:45
  • 1
    \$\begingroup\$ I think I might understand, although I'm not totally sure. When you "get gps time" repeatedly, are you getting a fresh timestamp every time? Or does the GPS timestamp you're getting only update once per second, or something to that effect? You're not saying your GPS receivers actually think the current time is 800 ms apart, right? Since that wouldn't really make sense. \$\endgroup\$ – Glenn Willen May 25 '19 at 4:48
  • 1
    \$\begingroup\$ I think you need to show us your code, because your verbal description is too vague. Trim it down to the minimum that demonstrates the problem. \$\endgroup\$ – Dave Tweed May 25 '19 at 12:12

Pretty much all GPS modules I have worked with will have a Pulse per second (PPS) outputs. They will be precise up to a few 10s of nanoseconds. You can use them to synchronise your two boards.

The PPS outputs will be periodically synced to the very accurate rubidium based clocks(present in GPS satellites) from the GPS signal and hence for your requirement they are really over design.

Another option is to use the time information command. The MCU can query the command from GPS module and update its RTC time accordingly.

The query itself and the response to the query should be timed so that you can correct the delta accordingly to achieve sub 50 ms sync expected


If you are using an NMEA based request over a serial line to get time, then this is at best accurate to within 1 second.
Read the documentation for your GPS.

For an example, here is the SiRF GPS manual, and the NMEA time request output:

enter image description here

To sync your two units, you need to first sync to the same second, and only then sync to the 1PPS signal edge.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.