112
M3i.48xx / M3i.48xx-exp Manual
Reading out the timestamps
Timestamps
bytes still stick to the defined notify size!
• If the on-board FIFO buffer has an overrun data transfer is stopped immediately.
Buffer handling example for DMA timestamp transfer (ABA transfer is similar, just using other registers)
The extra FIFO has a quite small size compared to the main data buffer. As the transfer is done initiated by
the hardware using busmaster DMA this is not critical as long as the application data buffers are large
enough and as long as the extra transfer is started BEFORE starting the card.
Data Transfer using Polling
When using M2i cards the Polling mode needs driver version V1.25 and firmware version V11 to run. Please
update your system to the newest versions to run this mode. Polling mode for M3i cards is included starting
with the first delivered card version.
If the extra data is quite slow and the delay caused by the notify size on DMA transfers is inacceptable for your application it is possible to
use the polling mode. Please be aware that the polling mode uses CPU processing power to get the data and that there might be an overrun
if your CPU is otherwise busy. You should only use polling mode in special cases and if the amount of data to transfer is not too high.
Most of the functionality is similar to the DMA based transfer mode as explained above.
The polling data transfer mode is activated as soon as the M2CMD_EXTRA_POLL is executed.
Definition of the transfer buffer
is similar to the above explained DMA buffer transfer. The value „notify size“ is ignored and should be set to 4k (4096).
Buffer handling
The buffer handling is also similar to the DMA transfer. As soon as one of the registers SPC_TS_AVAIL_USER_LEN or
SPC_ABA_AVAIL_USER_LEN is read the driver will read out all available data from the hardware and will return the number of bytes that
has been read. In minimum this will be one DWORD = 4 bytes.
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);
do
{
// we wait for the next data to be available. After this call we get at least 4k of data to proceed
dwError = spcm_dwSetParam_i32 (hDrv, SPC_M2CMD, M2CMD_EXTRA_STARTDMA | M2CMD_EXTRA_WAITDMA);
if (!dwError)
{
// if there was no error we can proceed and read out the current amount of available data
spcm_dwGetParam_i32 (hDrv, SPC_TS_AVAIL_USER_LEN, &lAvailBytes);
spcm_dwGetParam_i32 (hDrv, SPC_TS_AVAIL_USER_POS, &lBytePos);
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