Timestamps
Reading out the timestamps
(c) Spectrum GmbH
111
Definition of the transfer buffer
Before any data transfer can start it is necessary to define the transfer buffer with all its details. The definition of the buffer is done with the
spcm_dwDefTransfer function as explained in an earlier chapter. The following example will show the definition of a transfer buffer for
timestamp data, definition for ABA data is similar:
In this example the notify size is set to zero, meaning that we don’t want to be notified until all extra data has been transferred. Please have
a look at the sample data transfer in an earlier chapter to see more details on the notify size.
Please note that extra data transfer is only possible from card to PC and there’s no programmable offset available for this transfer.
Buffer handling
A data buffer handshake is implemented in the driver which allows to run the card in different data transfer modes. The software transfer
buffer is handled as one large buffer for each kind of data (timestamp and ABA) which is on the one side controlled by the driver and filled
automatically by busmaster DMA from the hardware extra FIFO buffer and on the other hand it is handled by the user who set’s parts of this
software buffer available for the driver for further transfer. The handshake is fulfilled with the following 3 software registers:
Directly after start of transfer the SPC_XXX_AVAIL_USER_LEN is every time zero as no data is available for the user and the
SPC_XXX_AVAIL_CARD_LEN is every time identical to the length of the defined buffer as the complete buffer is available for the card for
transfer.
The counter that is holding the user buffer available bytes (SPC_XXX_AVAIL_USER_LEN) is sticking to the de-
fined notify size at the DefTransfer call. Even when less bytes already have been transferred you won’t get
notice of it if the notify size is programmed to a higher value.
Remarks
• The transfer between hardware FIFO buffer and application buffer is done with scatter-gather DMA using a busmaster DMA controller
located on the card. Even if the PC is busy with other jobs data is still transferred until the application buffer is completely used.
• As shown in the drawing above the DMA control will announce new data to the application by sending an event. Waiting for an event is
done internally inside the driver if the application calls one of the wait functions. Waiting for an event does not consume any CPU time
and is therefore highly requested if other threads do lot of calculation work. However it is not necessary to use the wait functions and one
can simply request the current status whenever the program has time to do so. When using this polling mode the announced available
spcm_dwDefTransfer_i64 (hDrv, SPCM_BUF_TIMESTAMP, SPCM_CARDTOPC, 0, pvBuffer, 0, lLenOfBufferInBytes);
Register
Value
Direction
Description
SPC_ABA_AVAIL_USER_LEN
210
read
This register contains the currently available number of bytes that are filled with newly transferred
slow ABA data. The user can now use this ABA data for own purposes, copy it, write it to disk or start
calculations with this data.
SPC_ABA_AVAIL_USER_POS
211
read
The register holds the current byte index position where the available ABA bytes start. The register is
just intended to help you and to avoid own position calculation
SPC_ABA_AVAIL_CARD_LEN
212
write
After finishing the job with the new available ABA data the user needs to tell the driver that this
amount of bytes is again free for new data to be transferred.
SPC_TS_AVAIL_USER_LEN
220
read
This register contains the currently available number of bytes that are filled with newly transferred
timestamp data. The user can now use these timestamps for own purposes, copy it, write it to disk or
start calculations with the timestamps.
SPC_TS_AVAIL_USER_POS
221
read
The register holds the current byte index position where the available timestamp bytes start. The reg-
ister is just intended to help you and to avoid own position calculation
SPC_TS_AVAIL_CARD_LEN
222
write
After finishing the job with the new available timestamp data the user needs to tell the driver that this
amount of bytes is again free for new data to be transferred.