ABA mode (dual timebase)
Reading out ABA data
(c) Spectrum GmbH
121
Buffer handling example for polling timestamp transfer (ABA transfer is similar, just using other registers)
Comparison of DMA and polling commands
This chapter shows you how small the difference in programming is between the DMA and the polling mode:
ABA Mode and Timestamps
The ABA mode is well matching with the timestamp option. If timestamp
recording is activated, each trigger event and therefore each B time base
segment will get time tamped as shown in the drawing on the right.
Please keep in mind that the trigger events - located in the B area - are time
tamped, not the beginning of the acquisition. The first B sample that is
available is at the time position of [Timestamp - Pretrigger].
The first A area sample is related to the card start and therefore in a fixed
but various settings dependant relation to the timestamped B sample. To
bring exact relation between the first A area sample (and therefore all
area A samples) and the B area samples it is possible to let the card stamp
the first A area sample automatically after the card start. The following table shows the register to enable this mode:
char* pcData = new char[lBufSizeInBytes];
// we now define the transfer buffer with the minimum notify size of one page = 4 kByte
spcm_dwDefTransfer_i64 (hDrv, SPCM_BUF_TIMESTAMP, SPCM_DIR_CARDTOPC, 4096, (void*) pcData, 0, lBufSizeInBytes);
// we start the polling mode
dwError = spcm_dwSetParam_i32 (hDrv, SPC_M2CMD, M2CMD_EXTRA_POLL);
// this is pur polling loop
do
{
spcm_dwGetParam_i32 (hDrv, SPC_TS_AVAIL_USER_LEN, &lAvailBytes);
spcm_dwGetParam_i32 (hDrv, SPC_TS_AVAIL_USER_POS, &lBytePos);
if (lAvailBytes > 0)
{
printf (“We now have %d new bytes available\n”, lAvailBytes);
printf (“The available data starts at position %d\n”, lBytesPos);
// we take care not to go across the end of the buffer
if ((lB lAvailBytes) >= lBufSizeInBytes)
lAvailBytes = lBufSizeInBytes - lBytePos;
// our do function get’s a pointer to the start of the available data section and the length
vProcessTimestamps (&pcData[lBytesPos], lAvailBytes);
// the buffer section is now immediately set available for the card
spcm_dwSetParam_i32 (hDrv, SPC_TS_AVAIL_CARD_LEN, lAvailBytes);
}
}
while (!dwError); // we loop forever if no error occurs
DMA mode
Polling mode
Define the buffer
spcm_dwDefTransfer_i64 (hDrv, SPCM_BUF_TIMESTAMP, SPCM_DIR...);
spcm_dwDefTransfer_i64 (hDrv, SPCM_BUF_TIMESTAMP, SPCM_DIR...);
Start the transfer
spcm_dwSetParam_i32 (hDrv, SPC_M2CMD, M2CMD_EXTRA_STARTDMA)
spcm_dwSetParam_i32 (hDrv, SPC_M2CMD, M2CMD_EXTRA_POLL)
Wait for data
spcm_dwSetParam_i32 (hDrv, SPC_M2CMD, M2CMD_EXTRA_WAITDMA)
not in polling mode
Available bytes?
spcm_dwGetParam_i32 (hDrv, SPC_TS_AVAIL_USER_LEN, &lBytes);
spcm_dwGetParam_i32 (hDrv, SPC_TS_AVAIL_USER_LEN, &lBytes);
Min available bytes
programmed notify size
4 bytes
Current position?
spcm_dwGetParam_i32 (hDrv, SPC_TS_AVAIL_USER_LEN, &lBytes);
spcm_dwGetParam_i32 (hDrv, SPC_TS_AVAIL_USER_LEN, &lBytes);
Free buffer for card
spcm_dwSetParam_i32 (hDrv, SPC_TS_AVAIL_CARD_LEN, lBytes);
spcm_dwSetParam_i32 (hDrv, SPC_TS_AVAIL_CARD_LEN, lBytes);
Register
Value
Direction
Description
SPC_TIMESTAMP_CMD
47000
read/write
Programs a timestamp setup including mode and additional features
SPC_TSFEAT_MASK
F0000h
Mask for the feature relating bits of the SPC_TIMESTAMP_CMD bitmask.
SPC_TSFEAT_STORE1STABA
10000h
Enables storage of one additional timestamp for the first A area sample (B time base related) in addition to the trigger
related timestamps.
SPC_TSFEAT_NONE
0h
No additional timestamp is created. The total number of stamps is only trigger related.