
SC5412A Operating & Programming Manual
Rev 1.1.0
22
Function:
sc5412a_CloseDevice
Definition:
int
sc5412a_CloseDevice(
unsigned
int
deviceHandle)
Input:
unsigned
int
deviceHandle
(handle to the device to be closed)
Description:
sc5412a_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:
sc5412a_RegWrite
Definition:
int
sc5412a_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:
sc5412a_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:
int
status = sc5412a_RegWrite(devHandle, RF_FREQUENCY, 2000000000);
// set 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 = sc5412a_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 sc5412a devices detected. Press enter to continue.\n"
);
return
1;
}
//** sc5412a_OpenDevice, open device 0
status = sc5412a_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 = sc5412a_CloseDevice(deviceHandle);