Spectrum Brands MC.31XX 用户手册

下载
页码 102
Programming the Board
Initialization
(c) Spectrum GmbH
37
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.
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:
This short program then would generate a printout as:
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.
PCI Register
These registers are set by the driver after the PCI initialization. The information is found in the on-board EEPROM, 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.
One of the following values is returned, when reading this register.
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.
SpcSetParam (hDrv, SPC_MEMSIZE, -345);                              // faulty command
if (SpcSetParam (hDrv, SPC_COMMAND, SPC_START) != ERR_OK)           // try to start and check for an error
    {
    SpcGetParam (hDrv, SPC_LASTERRORCODE,  &lErrorCode);            // read out the error information
    SpcGetParam (hDrv, SPC_LASTERRORREG,   &lErrorReg);
    SpcGetParam (hDrv, SPC_LASTERRORVALUE, &lErrorValue);
    printf („Error %d when writing Register %d with Value %d !\n“, lErrorCode, lErrorReg, &lErrorValue);
    }
Error 101 when writing Register 10000 with Value -345 !
// ----- Initialization of PCI Bus Boards------------------------------------
if (SpcInitPCIBoards (&nCount, &nPCIBusVersion) != ERR_OK) 
    return;
if (nCount == 0) 
    {
    printf ("No Spectrum board found\n"); 
    return;
    }
Register
Value
Direction
Description
SPC_PCITYP
2000
r
Type of board as listed in the table below.
Boardtype
Value hexa-
dezimal
Value dezimal
Boardtype
Value hexa-
dezimal
Value dezimal
TYP_MC3110
13110h
78096
TYP_MC3122
13122h
78114
TYP_MC3111
13111h
78097
TYP_MC3130
13130h
78128
TYP_MC3112
13112h
78098
TYP_MC3131
13131h
78129
TYP_MC3120
13120h
78112
TYP_MC3132
13132h
78130
TYP_MC3121
13121h
78113