This is the C# code snippet I am trying to use to generate a SPI interface using 2 digital line and a counter output of the USB-6229. The digital waveform is create and output correctly. The issue I seem to have is with the Digital input. I physically have the output line connect to the input line. The output is "clocked" out on the falling edge of the counter pulse. My intention was to sample the input data on the rising edge of the counter pulse. I get the following error message.
"An unhandled exception of type 'NationalInstruments.DAQmx.DaqException' occurred in NationalInstruments.DAQmx.dll
Additional information: Measurements: Attempted to read a sample beyond the final sample acquired. The acquisition has stopped, therefore the sample specified by the combination of position and offset will never be available." Task MOSITask;
Task MISOTask;
Task PulseTask;
DigitalSingleChannelWriter MOSIWriter;
DigitalSingleChannelReader MISOReader;
DigitalWaveform waveform;
BuildWaveForm(address, data, nBytes, out waveform);
MOSITask = new Task("MOSITask");
MOSITask.DOChannels.CreateChannel("dev2/Port0/line0:1", "", ChannelLineGrouping.OneChannelForAllLines);
MOSITask.Timing.ConfigureSampleClock("ctr0InternalOutput", 1, SampleClockActiveEdge.Falling, SampleQuantityMode.FiniteSamples, 16);
MISOTask = new Task("MISOTask");
MISOTask.DIChannels.CreateChannel("dev2/Port0/Line2", "", ChannelLineGrouping.OneChannelForAllLines);
MISOTask.Timing.ConfigureSampleClock("ctr0InternalOutput", 1e6, SampleClockActiveEdge.Rising, SampleQuantityMode.FiniteSamples, 16);
PulseTask = new Task();
PulseTask.COChannels.CreatePulseChannelTime("dev2/ctr0", "", COPulseTimeUnits.Seconds, COPulseIdleState.High, 0, CLKdelay, CLKwidth);
PulseTask.Timing.ConfigureImplicit(SampleQuantityMode.FiniteSamples, 16);
MOSIWriter = new DigitalSingleChannelWriter(MOSITask.Stream);
MOSIWriter.BeginWriteWaveform(true, waveform, null, null);
MISOTask.Start();
MISOReader = new DigitalSingleChannelReader(MISOTask.Stream);
MISOReader.BeginReadWaveform(16, null, null);
PulseTask.Start();
DigitalWaveform waveformI;
waveformI = MISOReader.ReadWaveform(16);
Thanks for any inputs