Generation modes
Commands
(c) Spectrum GmbH
71
Card execution commands
Card wait commands
These commands do not return until either the defined state has been reached which is signalled by an interrupt from the card or the timeout
counter has expired. If the state has been reached the command returns with an ERR_OK. If a timeout occurs the command returns with
ERR_TIMEOUT. If the card has been stopped from a second thread with a stop or reset command, the wait function returns with ERR_ABORT.
Wait command timeout
If the state for which one of the wait commands is waiting isn’t reached any of the wait commands will either wait forever if no timeout is
defined or it will return automatically with an ERR_TIMEOUT if the specified timeout has expired.
As a default the timeout is disabled. After defining a timeout this is valid for all following wait commands until the timeout is disabled again
by writing a zero to this register.
A timeout occurring should not be considered as an error. It did not change anything on the board status. The board is still running and will
complete normally. You may use the timeout to abort the run after a certain time if no trigger has occurred. In that case a stop command is
necessary after receiving the timeout. It is also possible to use the timeout to update the user interface frequently and simply call the wait
function afterwards again.
Example for card control:
Card Status
In addition to the wait for an interrupt mechanism or completely instead of it one may also read out the current card status by reading the
SPC_M2STATUS register. The status register is organized as a bitmap showing the status of the card and also of the different data transfers.
M2CMD_CARD_RESET
1h
Performs a hard and software reset of the card as explained further above.
M2CMD_CARD_WRITESETUP
2h
Writes the current setup to the card without starting the hardware. This command may be useful if changing some
internal settings like clock frequency and enabling outputs.
M2CMD_CARD_START
4h
Starts the card with all selected settings. This command automatically writes all settings to the card if any of the set-
tings has been changed since the last one was written. After card has been started none of the settings can be
changed while the card is running.
M2CMD_CARD_ENABLETRIGGER
8h
The trigger detection is enabled. This command can be either send together with the start command to enable trigger
immediately or in a second call after some external hardware has been started.
M2CMD_CARD_FORCETRIGGER
10h
This command forces a trigger even if none has been detected so far. Sending this command together with the start
command is similar to using the software trigger.
M2CMD_CARD_DISABLETRIGGER
20h
The trigger detection is disabled. All further trigger events are ignored until the trigger detection is again enabled.
When starting the card the trigger detection is started disabled.
M2CMD_CARD_STOP
40h
Stops the current run of the card. If the card is not running this command has no effect.
M2CMD_CARD_WAITPREFULL
1000h
Acquisition modes only: the command waits until the pretrigger area has once been filled with data. After pretrigger
area has been filled the internal trigger engine starts to look for trigger events if the trigger detection has been
enabled.
M2CMD_CARD_WAITTRIGGER
2000h
Waits until the first trigger event has been detected by the card. If using a mode with multiple trigger events like Multi-
ple Recording or Gated Sampling there only the first trigger detection will generate an interrupt for this wait com-
mand.
M2CMD_CARD_WAITREADY
4000h
Waits until the card has completed the current run. In an acquisition mode receiving this command means that all data
has been acquired. In a generation mode receiving this command means that the output has stopped.
Register
Value
Direction
Description
SPC_TIMEOUT
295130
read/write
Defines the timeout for any following wait command in a milli second resolution. Writing a zero to
this register disables the timeout.
// card is started and trigger detection is enabled immediately
spcm_dwSetParam_i32 (hDrv, SPC_M2CMD, M2CMD_CARD_START | M2CMD_CARD_ENABLETRIGGER);
// we wait a maximum of 1 second for a trigger detection. In case of timeout we force the trigger
spcm_dwSetParam_i32 (hDrv, SPC_TIMEOUT, 1000);
if (spcm_dwSetParam_i32 (hDrv, SPC_M2CMD, M2CMD_CARD_WAITTRIGGER) == ERR_TIMEOUT)
{
printf (“No trigger detected so far, we force a trigger now!\n”);
spcm_dwSetParam (hdrv, SPC_M2CMD, M2CMD_CARD_FORCETRIGGER);
}
// we disable the timeout and wait for the end of the run
spcm_dwSetParam_i32 (hDrv, SPC_TIMEOUT, 0);
spcm_dwSetParam_i32 (hDrv, SPC_M2CMD, M2CMD_CARD_WAITREADY);
printf (“Card has stopped now!\n”);
Register
Value
Direction
Description
SPC_M2STATUS
110
read only
Reads out the current status information
M2STAT_CARD_PRETRIGGER
1h
Acquisition modes only: the pretrigger area has been filled.
M2STAT_CARD_TRIGGER
2h
The first trigger has been detected.
M2STAT_CARD_READY
4h
The card has finished it’s run and is ready.