Programming the Board

Initialization

 

 

This means as a result that it is not necessary to check each driver call for an error but to check for an error before the board is started to see whether all settings have been valid.

By reading all the error information one can easily examine where the error occured. The following table shows all the error related registers that can be read out.

Register

Value

Direction

Description

SPC_LASTERRORCODE

999999

r

Error code of the last error that occured. The errorcodes are found in spcerr.h. If this register is read,

 

 

 

the driver will be unlocked.

SPC_LASTERRORREG

999998

r

Software register that causes the error.

SPC_LASTERRORVALUE

999997

r

The value that has been written to the faulty software register.

The error codes are described in detail in the appendix. Please refer to this error description and the descrip- tion of the software register to examine the cause for the error message.

Example for error checking:

SpcSetParam (hDrv, SPC_MEMSIZE, -345);

 

// faulty command

if (SpcSetParam

(hDrv, SPC_COMMAND, SPC_START) != ERR_OK)

// try to start and check for an error

{

(hDrv, SPC_LASTERRORCODE,

&lErrorCode);

// read out the error information

SpcGetParam

SpcGetParam

(hDrv, SPC_LASTERRORREG,

&lErrorReg);

 

SpcGetParam

(hDrv, SPC_LASTERRORVALUE,

&lErrorValue);

 

printf („Error %d when writing Register %d with Value %d !\n“, lErrorCode, lErrorReg, &lErrorValue);

}

This short program then would generate a printout as:

Error 101 when writing Register 10000 with Value -345 !

Initialization

Starting the automatic initialization routine

Before you can access the boards in your program, you have to initialize them first. Therefore the Spectrum function SpcInitPCIBoards is used. If it is called, all Spectrum boards in the host system are initialized automatically. If no errors occured during the initialization, the returned value is 0 (ERR_OK). In any other cases something has gone wrong. Please see appendix for explanations of the different error codes.

If the process of initializing the boards was successful, the function returns the total number of Spectrum boards that have been found in your system. The third return value is the revision of the PCI Bus, the Spectrum boards are installed in.

The following example shows how to start the initialization of the board and check for errors.

//----- Initialization of PCI Bus Boards------------------------------------

if (SpcInitPCIBoards (&nCount, &nPCIBusVersion) != ERR_OK) return;

if (nCount == 0)

{

printf ("No Spectrum board found\n"); return;

}

PCI Register

These registers are set by the driver after the PCI initialization. The information is found in the on-board ROM, and can easily be read out by your own application software. All of the following PCI registers are read only. You get access to all registers by using the Spectrum function SpcGetParam with one of the following registers.

Register

SPC_PCITYP

Value

Direction

Description

2000

r

Type of board as listed in the table below

 

 

 

One of the following values are returned, when reading this register.

Boardtype

Value hexade-

Value dezimal

 

Boardtype

Value hexade-

Value dezimal

 

zimal

 

 

 

zimal

 

TYP_MI6110

6110

24848

 

TYP_MI6111

6111

24849

(c) Spectrum GmbH

37

Page 37
Image 37
Spectrum Brands MI.61XX manual Initialization, Starting the automatic initialization routine, PCI Register