Hei,
I'm using a PCI-6259 with Labwindows 7.0. I want to control a device with a SPI interface (CLK,DATA). CLK is an output for the PCI-6259 and DATA can be input or an output depending if I'm writting to the device or if I'm reading from the device. When I write I don't have any problem, because all the lines are outputs. But when I read, I define two different tasks : one to generate the CLK and another to read DATA with the falling edge of CLK. Here is when I get the error, because I cannot use the same port as input and output in the same task. Somebody knows how I could do that?
The following lines are the code that I have tried
// define task for generating the CLK
DAQmxCreateTask("DAQTaskSensorCommunication CLK", &taskCLK);
DAQmxCreateDOChan (taskCLK, "Dev1/port0/line2", "SPI_CLK",DAQmx_Val_ChanForAllLines);
DAQmxCfgSampClkTiming (taskCLK, "/Dev1/100kHzTimebase", 10000.0,DAQmx_Val_Rising, DAQmx_Val_FiniteSamps, 32);
DAQmxWriteDigitalLines (taskCLK, 32, 0, 10.0, DAQmx_Val_GroupByChannel,bufCLK, &read, NULL);
// define Read task
DAQmxCreateTask("DAQTaskSensorCommunication Read", &taskRead);
DAQmxCreateDIChan (taskRead, "Dev1/port0/line2", "SPI_CLK",DAQmx_Val_ChanForAllLines);
DAQmxReadDigitalLines (taskRead, 16, 10.0, DAQmx_Val_GroupByChannel,dataRDTmp, 16, NULL, NULL, 0);
DAQmxCfgChangeDetectionTiming (taskRead, "", "Dev1/port0/line3",DAQmx_Val_FiniteSamps, 16);
// start tasks
DAQmxStartTask (taskRead);
DAQmxStartTask (taskCLK);
DAQmxWaitUntilTaskDone (taskCLK, 10.0);
DAQmxClearTask (taskCLK);
DAQmxClearTask (taskRead);
I have another question regarding the DIO sampling frequency, in my case I'm using the 100Khz Timebase internal of the board, how I could divide the source in order to have slower frequencies? I have tried to change the TimebaseDiv with the function DAQmxSetTimingAttribute, but it gives me the error that this property is not supported by my board, somebody knows how I could change the sample/generation frequency of DIOs?
Merci