What is the proper way to do this using NIDAQmx? In my program I am using a ping-pong buffer to generate outputData to be written out. Semaphores take care of the data generation and consumption synchronization. The code below does not work. The output sample rate is not the Fs that I set it to be. Instead it is 800 kHz (the max rate for my 6120 board).
I can't find any examples that show how to do continuous generation (without repeating 1 buffer over and over again).
/*********************************************/
// DAQmx Configure Code
/*********************************************/
DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
DAQmxErrChk (DAQmxCreateAOVoltageChan (taskHandle, chan0, "", -10.0, 10.0, DAQmx_Val_Volts, NULL));
DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle,"",Fs,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps ,sampsPerChan));
DAQmxErrChk (DAQmxGetTaskAttribute(taskHandle,DAQmx_Task_NumChans,&numChannels));
/*********************************************/
// DAQmx Start Code
/*********************************************/
DAQmxErrChk (DAQmxStartTask(taskHandle));
while( gRunning ) {
/*********************************************/
// DAQmx Write Code
/*********************************************/
result = WaitForSingleObject(DAQReadSem[bufNum], 10000); // Blocking sempahore acquire
DAQmxWriteAnalogF64 (taskHandle, sampsPerChan, 0, TIMEOUT, DAQmx_Val_GroupByScanNumber, outputData[bufNum], &numWritten, 0);
result = ReleaseSemaphore(DAQWriteSem[bufNum], 1, NULL);
bufNum = 1 - bufNum;
}