96 MC.31xx Manual
Setup synchronization for use with FIFO mode and equally clokked boards Synchronization (Option)
for each board that runs synchronuously in FIFO mode. If this is not done a deadlock will occur and the program will
not start properly.
(10) Start all of the trigger master boards
After having armed the synchronized boards, you must start all of the boards, that are defined as trigger masters.
This example shows how to set up three boards for synchronization in FIFO mode. Board 0 is clock master and board 2 is trigger master.
It is assumed, that the created threads start in the same order as they are called from within the program. As described before, starting of
the FIFO mode in synchronization has to be done in different threads to avoid a deadlock. A simple example for a FIFO thread can be found
below.
Example of FIFO task. It simply starts the boards and counts the buffers that have been transfered:
Additions for synchronizing different boards
General information
Spectrum boards with different speed grades, different number of channels or even just different clock settings for the same types of boards
can be synchronized as well. To get the boards working together synchronously some extra setups have to be done, which are described in
the following passages.
Register Value Direction Description
SPC_COMMAND 0 r/w Command register of the board
SPC_FIFOSTART 10 Starts the board with the current register settings in FIFO mode and waits for the first interrupt.
// (3) ----- trigger synchronization of trigger master board(s) -----
SpcSetParam (hDrv[2], SPC_COMMAND, SPC_SYNCTRIGGERMASTER); // board 2 set as trigger master
// (4) ----- trigger synchronization of trigger slave boards -----
SpcSetParam (hDrv[0], SPC_COMMAND, SPC_SYNCTRIGGERSLAVE); // as trigger slaves
SpcSetParam (hDrv[1], SPC_COMMAND, SPC_SYNCTRIGGERSLAVE); // as trigger slaves
// (5) ----- synchronization information for clock master board -----
SpcSetParam (hDrv[0], SPC_COMMAND, SPC_SYNCMASTERFIFO);
// (6) ----- synchronization information for clock slave boards -----
SpcSetParam (hDrv[1], SPC_COMMAND, SPC_SYNCSLAVEFIFO);
SpcSetParam (hDrv[2], SPC_COMMAND, SPC_SYNCSLAVEFIFO);
// (7) ----- start the synchronization -----
SpcSetParam (hDrv[0], SPC_COMMAND, SPC_SYNCSTART);
// (8) ----- start the FIFO tasks. Trigger slaves are started first -----
CreateThread (NULL, 0, &dwFIFOTask, (void*) hDrv[0], 0, &dwThreadId[b]);
CreateThread (NULL, 0, &dwFIFOTask, (void*) hDRV[1], 0, &dwThreadId[b]);
// (9) ----- start the trigger master FIFO task -----
CreateThread (NULL, 0, &dwFIFOTask, (void*) hDrv[2], 0, &dwThreadId[hDrv[2]]);
unsigned long __stdcall dwFIFOTask (void* phDrv)
{
int16 hDrv = (int16) phDrv;
int32 lCmd = SPC_FIFOSTART;
int16 nBufIdx = 0, nErr;
int32 lTotalBuf;
lTotalBuf = 0;
do
{
nErr = SpcSetParam (hDrv, SPC_COMMAND, lCmd); // wait for buffer
lCmd = SPC_FIFOWAIT; // here you can do
printf ("Board %d Buffer %d total buffers: %d\n", nIdx, nBufIdx, lTotalBuf);// e.g. calculations
// just a printf here
SpcSetParam (hDrv, SPC_COMMAND, SPC_FIFO_BUFREADY0 + nBufIdx); // release buffer
nBufIdx++;
lTotalBuf++;
if (nBufIdx == FIFO_BUFFERS)
nBufIdx = 0;
}
while (nErr == ERR_OK);
return 0;
}