Timestamps
Timestamp modes
(c) Spectrum GmbH
109
Refclock mode
The counter is split in a HIGH and a LOW part and an additional external signal, that affects both parts of the counter, needs to be fed in
externally. The external reference clock signal will reset the LOW part of the counter and increase the HIGH part of the counter. The upper
counter will hold the number of the clock edges that have occurred on the external reference clock signal and the lower counter will hold the
position within the current reference clock period with the resolution of the sampling rate.
This mode can be used to obtain an absolute time reference when using an external radio clock or a GPS receiver. In that case the higher
part is counting the seconds since the last reset and the lower part is counting the position inside the second using the current sampling rate.
Please keep in mind that as this mode uses an additional external signal. If using plain M2i cards the option
BaseXIO needs to be installed on the card. Otherwise there is no additional reference clock input available
and this mode has no functionality. If using a digitizerNETBOX this additional timestamp reference clock input
is available as a standard and no option is needed to use this mode.
The counting is initialized with the timestamp reset command. Both counter parts will then be set to zero.
The following table shows the valid values that can be written to the timestamp command register for this mode:
To synchronize the external reference clock signal with the PC clock it is possible to perform a timestamp reset command which waits a spec-
ified time for the occurrence of the external clock edge. As soon as the clock edge is found the function stores the current PC time and date
which can be used to get the absolute time. As the timestamp reference clock can also be used with other clocks that don’t need to be syn-
chronized with the PC clock the waiting time can be programmed using the SPC_TIMESTAMP_TIMEOUT register.
Example for initialization of timestamp reference clock and synchronization of a seconds signal with the PC clock:
Register
Value
Direction
Description
SPC_TIMESTAMP_STARTTIME
47030
read/write
Return the reset time when using reference clock mode. Hours are placed in bit 16 to 23, minutes are
placed in bit 8 to 15, seconds are placed in bit 0 to 7
SPC_TIMESTAMP_STARTDATE
47031
read/write
Return the reset date when using reference clock mode. The year is placed in bit 16 to 31, the month
is placed in bit 8 to 15 and the day of month is placed in bit 0 to 7
SPC_TIMESTAMP_TIMEOUT
47045
read/write
Sets a timeout in milli seconds for waiting for a reference clock edge
SPC_TIMESTAMP_CMD
47000
read/write
Programs a timestamp mode and performs commands as listed below
SPC_TSMODE_DISABLE
0
Timestamp is disabled.
SPC_TS_RESET
1h
The counters are reset. If reference clock mode is used this command waits for the edge the timeout time.
SPC_TSMODE_STANDARD
2h
Standard mode, counter is reset by explicit reset command.
SPC_TSMODE_STARTRESET
4h
Counter is reset on every card start, all timestamps are in relation to card start.
SPC_TSCNT_REFCLOCKPOS
200h
Counter is split, upper part is running with external reference clock positive edge, lower part is running with sampling
clock
SPC_TSCNT_REFCLOCKNEG
400h
Counter is split, upper part is running with external reference clock negative edge, lower part is running with sam-
pling clock
spcm_dwSetParam_i32 (hDrv, SPC_TIMESTAMP_CMD, SPC_TSMODE_STANDARD | SPC_TSCNT_REFCLOCKPOS);
spcm_dwSetParam_i32 (hDrv, SPC_TIMESTAMP_TIMEOUT, 1500);
if (ERR_TIMEOUT == spcm_dwSetParam_i32 (hDrv, SPC_TIMESTAMP_CMD, SPC_TS_RESET))
printf ("Synchronization with external clock signal failed\n");
// now we read out the stored synchronization clock and date
int32 lSyncDate, lSyncTime;
spcm_dwGetParam_i32 (hDrv, SPC_TIMESTAMP_STARTDATE, &lSyncDate);
spcm_dwGetParam_i32 (hDrv, SPC_TIMESTAMP_STARTTIME, &lSyncTime);
// and print the start date and time information (European format: day.month.year hour:minutes:seconds)
printf ("Start date: %02d.%02d.%04d\n", lSyncDate & 0xff, (lSyncDate >> 8) & 0xff, (lSyncData >> 16) & 0xffff);
printf ("Start time: %02d:%02d:%02d\n", (lSyncTime >> 16) & 0xff, (lSyncTime >> 8) & 0xff, lSyncTime & 0xff);