
Software
Driver functions
(c) Spectrum Instrumentation GmbH
49
Example:
Function spcm_dwSetParam
All hardware settings are based on software registers that can be set by one of the functions spcm_dwSetParam. These functions set a register
to a defined value or execute a command. The board must first be initialized by the spcm_hOpen function. The parameter lRegister must have
a valid software register constant as defined in regs.h. The available software registers for the driver are listed in the board specific part of
the documentation below. The function returns a 32 bit error code if an error occurs. If no error occurs the function returns ERR_OK, what is
zero.
Function spcm_dwSetParam
Example:
This example sets the memory size to 16 kSamples (16384). If an error occurred the example will show a short error message
Function spcm_dwGetParam
All hardware settings are based on software registers that can be read by one of the functions spcm_dwGetParam. These functions read an
internal register or status information. The board must first be initialized by the spcm_hOpen function. The parameter lRegister must have a
valid software register constant as defined in the regs.h file. The available software registers for the driver are listed in the board specific part
of the documentation below. The function returns a 32 bit error code if an error occurs. If no error occurs the function returns ERR_OK, what
is zero.
Function spcm_dwGetParam
Example:
The example reads out the serial number of the installed card and prints it. As the serial number is available under all circumstances there is
no error checking when calling this function.
Different call types of spcm_dwSetParam and spcm_dwGetParam: _i32, _i64, _i64m
The three functions only differ in the type of the parameters that are used to call them. As some of the registers can exceed the 32 bit integer
range (like memory size or post trigger) it is recommended to use the _i64 function to access these registers. However as there are some
spcm_vClose (hDrv);
uint32 _stdcall spcm_dwSetParam_i32 ( // Return value is an error code
drv_handle hDevice, // handle to an already opened device
int32 lRegister, // software register to be modified
int32 lValue); // the value to be set
uint32 _stdcall spcm_dwSetParam_i64m ( // Return value is an error code
drv_handle hDevice, // handle to an already opened device
int32 lRegister, // software register to be modified
int32 lValueHigh, // upper 32 bit of the value. Containing the sign bit !
uint32 dwValueLow); // lower 32 bit of the value.
uint32 _stdcall spcm_dwSetParam_i64 ( // Return value is an error code
drv_handle hDevice, // handle to an already opened device
int32 lRegister, // software register to be modified
int64 llValue); // the value to be set
if (spcm_dwSetParam_i64 (hDrv, SPC_MEMSIZE, 16384) != ERR_OK)
printf (“Error when setting memory size\n”);
uint32 _stdcall spcm_dwGetParam_i32 ( // Return value is an error code
drv_handle hDevice, // handle to an already opened device
int32 lRegister, // software register to be read out
int32* plValue); // pointer for the return value
uint32 _stdcall spcm_dwGetParam_i64m ( // Return value is an error code
drv_handle hDevice, // handle to an already opened device
int32 lRegister, // software register to be read out
int32* plValueHigh, // pointer for the upper part of the return value
uint32* pdwValueLow); // pointer for the lower part of the return value
uint32 _stdcall spcm_dwGetParam_i64 ( // Return value is an error code
drv_handle hDevice, // handle to an already opened device
int32 lRegister, // software register to be read out
int64* pllValue); // pointer for the return value
int32 lSerialNumber;
spcm_dwGetParam_i32 (hDrv, SPC_PCISERIALNO, &lSerialNumber);
printf (“Your card has serial number: %05d\n”, lSerialNumber);
Summary of Contents for M2p.59 Series
Page 190: ......