Driver Development Kit (DDK)

cancel
Showing results for 
Search instead for 
Did you mean: 

x-series analog out fifo preload

Solved!
Go to solution

 

i am porting an m-series driver to x-series, and have a quick question about analog output.

 

i have found that I can preload the aout FIFO by writing sequential data to:

 

        device.AO.AO_FIFO_Data_Register.writeRegister(val);

 

however this is a 32-bit register, and through trial and error I have found that i have to write two values at a time:

 

    for(int i=0;i<preloadCount;i+=2)

    {

        u32 val = buffer[i] & 0xffff;     // buffer has correctly scaled DAC values, as 32-bit ints

 

        if (i<(preloadCount-1))           // in case preload count not divisible by 2

            val |= buffer[i+1]<<16;

 

        device.AO.AO_FIFO_Data_Register.writeRegister(val);

    }

 

is there a way to write one 16-bit value at a time to the analog out fifo?

 

thanks,

 

--spg

------------------
scott gillespie
applied brain, inc.
------------------
0 Kudos
Message 1 of 6
(9,183 Views)

 

additionally, is there a way to DMA 32-bit values to analog out, without them being interpreted as pairs of 16-bit values?

 

for analog input, both problems (writes to the fifo, and dma to the fifo) are solved by setting the fifo width:

 

aiHelper.programFIFOWidth(nAI::kFourByteFifo, status)

 

but so far I have not found a similar mechanism for analog output.  

 

national instruments guys, can you comment?

 

thanks,

 

--spg

 

------------------
scott gillespie
applied brain, inc.
------------------
0 Kudos
Message 2 of 6
(9,175 Views)

Hello,

 

Your findings about the lack of a FIFO width setting for analog output are correct. There are no mechanisms to change the FIFO width, so you are limited to using i16 values.  DMA works the same way.  There are no mechanisms to get an i32 value to be seen as an i16...instead of a pair of i16 values.

 

In your example, you can form your data buffer as an array of i16 values.  Then you can use a 32-bit pointer to load the data from the buffer into the AO_FIFO_Data_Register.

 

I hope this helps.

 

Steven T.

0 Kudos
Message 3 of 6
(9,158 Views)

 

how about if I want to create a continuous waveform using an odd number of values (without DMA)?  there appears to be no way of doing that.

 

if it is not continous, and if i'm only outputting 1 channel, i can put a garbage value in the first location, then use an extra

 

aoHelper.getOutTimerHelper(status).notAnUpdate(status)

 

to get rid of it.  but for a continuous waveform or multiple channels, this won't work.

 

thoughts?

------------------
scott gillespie
applied brain, inc.
------------------
0 Kudos
Message 4 of 6
(9,155 Views)
Solution
Accepted by topic author spg

Hello,

 

I found some rather surprising information about this.  The AO_FIFO_Data_Register is 32-bit, so everytime that a 32-bit write is performed at this register's offset, two i16 values are loaded into the FIFO.  However, I found some code that writes a single i16 value to this offset by performing a 16-bit write.  Please try this if you haven't already.

 

I was able to think up work-arounds to the your scenarios, but they started to get more and more hacky.  I like the real solution better! 🙂

 

Thanks,

Steven T.

Message 5 of 6
(9,143 Views)

 

awwww yeah!  that works:

 

...

        tAddressSpace bar0Space = nub->GetBar0AddressSpace();

        while(preloadIndex<preloadCount)

            bar0Space.write16(0x20458,buffer[preloadIndex++]);

 

thanks much!

 

cheers,

 

-spg

 

------------------
scott gillespie
applied brain, inc.
------------------
0 Kudos
Message 6 of 6
(9,138 Views)