
160
(c) Spectrum Instrumentation GmbH
Reading out the timestamps
Timestamps
Example for initialization of timestamp reference clock and synchronization of a seconds signal with the PC clock:
Reading out the timestamps
General
The timestamps are stored in an extra FIFO that is located in hardware on the card. This extra FIFO can read out timestamps using DMA
transfer similar to the DMA transfer of the main sample data DMA transfer. The card has three completely independent busmaster DMA en
-
gines in hardware allowing the simultaneous transfer of both timestamp and sample data.
As seen in the picture there are separate FIFOs holding ABA and timestamp data.
Although an M4i is shown here, this applies to M4x and M2p cards as well. Each FIFO has its own DMA channel, the way data is handled
by the DMA engine is similar for both kinds of extra FIFOs and is also very similar to the main sample data transfer engine. Therefore addi
-
tional information can be found in the chapter explaining the main data transfer.
Commands and Status information for extra transfer buffers.
As explained above the data transfer is performed with the same command and status registers like the card control and sample data transfer.
It is possible to send commands for card control, data transfer and extra FIFO data transfer at the same time
spcm_dwSetParam_i32 (hDrv, SPC_TIMESTAMP_CMD, SPC_TSMODE_STANDARD | SPC_TSCNT_REFCLOCKPOS);
spcm_dwSetParam_i32 (hDrv, SPC_TIMESTAMP_TIMEOUT, 1500);
if (ERR_TIMESTAMP_SYNC == spcm_dwSetParam_i32 (hDrv, SPC_TIMESTAMP_CMD, SPC_TS_RESET_WAITREFCLK))
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, (lSyncDate >> 16) & 0xffff);
printf ("Start time: %02d:%02d:%02d\n", (lSyncTime >> 16) & 0xff, (lSyncTime >> 8) & 0xff, lSyncTime & 0xff);
Table 95: Spectrum API: extra DMA commands (ABA and Timestamp)
Register
Value
Direction
Description
SPC_M2CMD
100
write only
Executes a command for the card or data transfer
M2CMD_EXTRA_STARTDMA
100000h
Starts the DMA transfer for an already defined buffer.
M2CMD_EXTRA_WAITDMA
200000h
Waits until the data transfer has ended or until at least the amount of bytes defined by notify size are available. This
wait function also takes the timeout parameter into account.
M2CMD_EXTRA_STOPDMA
400000h
Stops a running DMA transfer. Data is invalid afterwards.
M2CMD_EXTRA_POLL
800000h
Polls data without using DMA. As DMA has some overhead and has been implemented for fast data transfer of large
amounts of data it is in some cases more simple to poll for available data. Please see the detailed examples for this
mode. It is not possible to mix DMA and polling mode.
Image 75: Overview of acquisition data, ABA data and timestamp data DMA transfer
Содержание M2p.59 Series
Страница 190: ......