Starting without interrupt (classic mode), Starting with interrupt driven mode – Spectrum Brands MI.20xx User Manual

Page 46

Advertising
background image

46

MI.20xx Manual

Programming

Standard acquisition modes

The values depend on the number of activated channels and on the type of board being used. The minimum stepsizes for setting up the mem-
size and the postcounter are shown in the table below.

Minimum and stepsize of memsize and posttrigger in samples

Starting without interrupt (classic mode)

Command register

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

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.

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.

20

20

20

21

20

30

20

31

ch0

ch1

ch2

ch3

x

64

64

64

64

x

x

32

32

32

32

x

x

n.a.

64

n.a.

64

x

x

x

x

n.a.

32

n.a.

32

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.

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.

// ----- start the board -----
nErr = SpcSetParam (hDrv, SPC_COMMAND, SPC_START);

// 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");

Advertising