ProgrammingStandard generation modes
Starting without interrupt (classic mode)
Command register
Register | Value | Direction | Description | |
SPC_COMMAND | 0 | r/w | Command register of the board. | |
| SPC_START | 10 | Starts the board with the current register settings. | |
|
|
|
| |
| SPC_STOP | 20 | Stops the board manually. |
In this mode the board is started by writing the SPC_START value to the command register. All settings like for example the size of memory and postcounter, the number of activated channels and the trigger settings must have been programmed before. If the start command has been given, the setup data is transferred to the board and the board will start.
If your board has relays to switch between different settings a programmed time will be waited to prevent having the influences of the relays settling time in the signal. For additional information please first see the chapter about the relay settling time. You can stop the board at any time with the command SPC_STOP. This command will stop immediately.
Once the board has been started, it is running totally independent from the host system. Your program has full CPU time to do any calculations or display. The status register shown in the table below shows the current status of the board. The most simple programming loop is simply waiting for the status SPC_READY. This status shows that the board has stopped automatically.
The read only status register can be read out at any time, but it is mostly used for polling on the board’s status after the board has been started. However polling the status will need CPU time.
Status register
Register | Value | Direction | Description | |
SPC_STATUS | 10 | r | Status register, of the board. | |
| SPC_RUN | 0 | Indicates that the board has been started and is waiting for a triggerevent. | |
| SPC_TRIGGER | 10 | Indicates that the board is running and a triggerevent has been detected. | |
|
|
|
| |
| SPC_READY | 20 | Indicates, that the board has stopped. |
The following shortened excerpt of a sample program gives you an example of how to start the board in classic mode and how to poll for the SPC_READY flag. It is assumed that all board setup has been done before.
// | start the | board | SPC_START); |
| |
nErr = SpcSetParam | (hDrv, |
| |||
// Here you can check for | driver errors | as mentioned in | the relating chapter | ||
// | Wait for Status Ready (polling | for SPC_READY in a loop) | |||
do |
|
|
|
|
|
{
SpcGetParam (hDrv, SPC_STATUS, &lStatus);
}
while (lStatus != SPC_READY);
printf ("Board has stopped\n");
Starting with interrupt driven mode
In contrast to the classic mode, the interrupt mode has no need for polling for the board’s status. Starting your board in the interrupt driven mode does in the main not differ from the classic mode. But there has to be done some additional programming to prevent the program from hanging. The SPC_STARTANDWAIT command doesn’t return until the board has stopped. Big advantage of this mode is that it doesn’t waste any CPU time for polling. The driver is just waiting for an interrupt and the System has full CPU time for other jobs. To benefit from this mode it is necessary to set up a program with at least two different tasks: One for starting the board and to be blocked waiting for an interrupt. The other one to make any kind of calculations or display activities.
Command register
Register | Value | Direction | Description | |
SPC_COMMAND | 0 | r/w | Command register, of the board. | |
| SPC_STARTANDWAIT | 11 | Starts the board with the current register settings in the interrupt driven mode. | |
| SPC_STOP | 20 | Stops the board manually. |
If the board is started in the interrupt mode the task calling the start function will not return until the board has finished. If no trigger event is found or the external clock is not present, this function will wait until the program is terminated from the taskmanager (Windows) or from another console (Linux).
46 | MI.61xx Manual |