SC5312A Operating & Programming Manual
Rev 1.0.2
23
Function:
sc5312a_CloseDevice
Definition:
int
sc5312a_CloseDevice(
unsigned
int
deviceHandle)
Input:
unsigned
int
deviceHandle
(handle to the device to be closed)
Description:
sc5312a_CloseDevice
closes the device associated with the device handle and turns off
the
“active” LED on
the front panel if it is successful.
Example:
Code to exercise the functions that open and close the device:
Function:
sc5312a_RegWrite
Definition:
int
sc5312a_RegWrite(
unsigned
int
deviceHandle,
unsigned
char
commandByte,
unsigned
long
long
int
instructWord)
Input:
unsigned int
deviceHandle
(handle to the opened device)
unsigned
char
commandByte
(register address)
unsigned
long
long
int
instructWord
(data for the register)
Description:
sc5312a_RegWrite
writes the instructWord data to the register specified by the
commandByte. See the register map on Table 2 for more information.
Example:
To set the frequency to 2 GHz:
// Declaring
char
**visaResource = (
char
**)malloc(
sizeof
(
char
*)*10);
// 10 devices
unsigned
int
deviceHandle;
int
devicesFound;
int
i,status;
// Allocate memory for 10 device with 20 characters to hold ID
for
(i = 0; i< 10; i++)
visaResource[i] = (
char
*)malloc(
sizeof
(
char
)*20);
status = sc5312a_ListResources(visaResource, &devicesFound);
printf(
"There are %d SignalCore PXI devices found. \n"
, devicesFound);
if
(devicesFound == 0)
//If no device are found deallocate memory and end the program
{
for
(i = 0; i<10;i++)
free(visaResource[i]);
free(visaResource);
printf(
"No sc5312a devices detected. Press enter to continue.\n"
);
return
1;
}
//** sc5505a_OpenDevice, open device 0
status = sc5312a_OpenDevice(visaResource[0], &deviceHandle);
// Free memory
for
(i = 0; i<10;i++)
free(visaResource[i]);
free(visaResource);
//
// Do something with the device
//
//Close the device
int status = sc5312a_CloseDevice(deviceHandle);
int
status = sc5312a_RegWrite(devHandle, RF_FREQUENCY, 2000000000);
// set frequency
to 2 GHz