From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

NI-6229 Digital Output Timing

I'm using two digital output lines to hook up to an SPI device.  I only need CS, CLK and MOSI, I do not need to hook up MISO.   The output is correct, however, I need to slow it down.  When I add the code below to slow it down, it does not work.  What am I doing wrong?
 
Thanks
 

DAQmxCreateTask(

"", handle)

DAQmxCreateDOChan(*handle,

"/dev1/port0/line0,/dev1/port0/line1",/dev1/port0/line2, DAQmx_Val_ChanForAllLines);

 

// Code inserted to try and slow down timing

DAQmxCfgSampClkTiming(*handle, "/Dev1/Ctr0InternalOutput", 10000.0, DAQmx_Val_Rising, DAQmx_Val_ContSamps,1000);

DAQmxCreateCOPulseChanFreq(*handle, "Dev1/ctr0","",DAQmx_Val_Hz,DAQmx_Val_Low,0,10000.0,0.5);

DAQmxCfgImplicitTiming (*handle,DAQmx_Val_ContSamps, 1000);

 

// code fragment to burst out CS,CLK and MOSI

DAQmxWriteDigitalU32(handle, length, TRUE, 10.0, DAQmx_Val_GroupByScanNumber, (uInt32 *)buffer, &actual, NULL);

0 Kudos
Message 1 of 2
(3,168 Views)
Hi mwalter64,

It appears that your issue may be with the task you are using.  A task can only have one "type" of channel in it, so I believe you need to separate the DO and the Ctr into two separate tasks.  Other than this,  it looks like you are on the right track with using the Ctr0InternalOutput to control the speed of both tasks.  In order to keep things straight, I would also configure one task before the other.  What I mean by this is to go through the following steps in order:

CreateTask
    Create DO Chan
    Cfg Sample Clock
    Write DO                 \\Be sure autostart is F
   
Start task

CreateTask
    CreateCOPulseChanFreq
    CfgImplicitTiming
    Start Task
    WriteCtrFreq

Stop both tasks
clear tasks
etc.

I hope this helps, if its not clear, post again and I will try to clarify.

Neal M.
NIC AE
www.ni.com/support
SR#: 1039621
   
Neal M.
Applications Engineering       National Instruments        www.ni.com/support
0 Kudos
Message 2 of 2
(3,138 Views)