Here is another problem (NI-DAQmxBase 2.1 on Mac OS X 14.4.11, M6251 card): I create an externally clocked DO task, stop it, clear it and try to do it again. On the 2nd attempt, writing samples to the DO buffer consistently times out. So I can only execute a DO task once: not very useful. Here is an excerpt of my code:
ctr0 is configured to output a 1 MHz clock which is manually wired to PFI0, this works so I will omit for clarity:
DAQmxErrChk (DAQmxBaseCreateTask("dummyDO",&taskHandleDO));
DAQmxErrChk (DAQmxBaseCreateDOChan(taskHandleDO, "Dev1/port0/line0", NULL, DAQmx_Val_ChanForAllLines));
#define dummySampleRate 1000
#define dummyNumSamples 1000
DAQmxErrChk (DAQmxBaseCfgSampClkTiming(taskHandleDO, "/Dev1/PFI0", dummySampleRate, DAQmx_Val_Rising, DAQmx_Val_ContSamps, dummyNumSamples)); // does not accept DAQmx_Val_FiniteSamps
#define FIFOmax 2047
// write the first chunk of samples to DO buffer, dataDO_32bit contains an arbitrary pulse pattern
DAQmxErrChk (DAQmxBaseWriteDigitalU32(taskHandleDO, FIFOmax, noAutoStart, kTimeOut, DAQmx_Val_GroupByChannel, dataDO_32bit, NULL, NULL));
DAQmxErrChk (DAQmxBaseStartTask(taskHandleDO));
// start the ctr0 task: this will clock the DO samples out
DAQmxErrChk (DAQmxBaseStartTask(taskHandleC0));
// write the final zero buffer to the FIFO, this stops the pulse generation; dataDOzero_32bit contains all 0's ***
DAQmxErrChk (DAQmxBaseWriteDigitalU32(taskHandleDO, FIFOmax, noAutoStart, kTimeOut, DAQmx_Val_GroupByChannel, dataDOzero_32bit, NULL, NULL));
// do it again just to see if we can write to buffer again w/o timeout: yes we can ***
DAQmxErrChk (DAQmxBaseWriteDigitalU32(taskHandleDO, FIFOmax, noAutoStart, kTimeOut, DAQmx_Val_GroupByChannel, dataDOzero_32bit, NULL, NULL));
// now try the above again with a new DO task:
DAQmxBaseStopTask(taskHandleDO); // stop the first DO task
DAQmxBaseStopTask(taskHandleC0); // stop the clock too
DAQmxBaseClearTask(taskHandleDO); // clear the task so we can start over
// recreate an identical task to above
DAQmxErrChk (DAQmxBaseCreateTask("dummyDO",&taskHandleDO));
DAQmxErrChk (DAQmxBaseCreateDOChan(taskHandleDO, "Dev1/port0/line0", NULL, DAQmx_Val_ChanForAllLines));
DAQmxErrChk (DAQmxBaseCfgSampClkTiming(taskHandleDO, "/Dev1/PFI0, dummySampleRate, DAQmx_Val_Rising, DAQmx_Val_ContSamps, dummyNumSamples));
// write the first chunk of samples to DO buffer as before:
DAQmxErrChk (DAQmxBaseWriteDigitalU32(taskHandleDO, FIFOmax, noAutoStart, kTimeOut, DAQmx_Val_GroupByChannel, dataDO_32bit, NULL, NULL));
THIS LAST CALL TIMES OUT AND FAILS. WHY?
Why is it that I can write to the running DO task as many times as I want above (see commented lines with ***), yet I cannot perform a 2nd identical DO task with a brand new taskHandleDO?
How do you get around this one now?
Peter.