Time Handling (proposal)


file  clock.h

wall clock

file  clock.c

wall clock

Detailed Description

This is a proposal how to handle time-keeping. Feel free to add your comments.

We have the following sources for elapsed time:

Sources for absolute time are:

The functions in xpal_async32khz.c configure Timer2 to wrap-around once per second, this gives a resolution of 7.812 ms. It may be possible to use the start time of a new data packet from the GPS as indication that a second has just started (not tested yet).

Upon receipt of a message from the GPS the following steps should be taken:

  1. Convert time from message into internal format. Depending on GPS data protocol used, the date or the century may have to be guessed.
  2. For finer time resolution, remember the T2 counter value at reception of the first byte of the message bunch.
  3. Calculate and store the difference between GPS time and internal time.
  4. From several samples, a drift value of the internal clock can be calculated. (This step will be implemented in a later version.)