PulseBlasterESR-PRO
There are currently six example C programs available with the SpinAPI package in the PulseBlasterESR-
PRO directory.
Example Use of C Functions
2019/09/26
#include <stdio.h>
#include <stdlib.h>
#define PBESRPRO
#include "spinapi.h"
#define CLOCK 400.0 // PulseBlaster core clock rate
int main (int argc, char **argv)
{
int start;
printf ("Copyright (c) 2010 SpinCore Technologies, Inc.\n\n");
printf("Using SpinAPI library version %s\n", pb_get_version());
if (pb_init () != 0) {
printf ("Error initializing board: %s\n", pb_get_error());
system("pause");
}
// Tell driver what clock frequency the board uses
pb_core_clock(CLOCK);
// Prepare the board to receive pulse program instructions
pb_start_programming(PULSE_PROGRAM);
// Instruction 0 - Continue to instruction 1 in 20ns. The lower 4 bits
// (all BNC connectors) will be driving high. For PBESR-PRO boards,
// or-ing THREE_PERIOD with the flags causes a 3 period short
// pulse to be used.
start = pb_inst(THREE_PERIOD | 0xF, CONTINUE, 0, 20.0 * ns);
// Instruction 1 - Continue to instruction 2 in 40ns
// The BNC1-3 will be driving high the entire 40ns.
pb_inst(ON | 0xE, CONTINUE, 0, 40.0 * ns);
// Instruction 2 - Branch to "start" (Instruction 0) in 40ns
// Outputs are off
pb_inst(0, BRANCH, start, 40.0 * ns);
pb_stop_programming(); // Finished sending instructions
pb_reset();
pb_start(); // Trigger the pulse program
// End communication with PulseBlasterESR-PRO board. The pulse program
// will continue to run even after this is called.
pb_close();
return 0;
}