03-22-2012 06:23 PM
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:
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:
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;
is there a way to write one 16-bit value at a time to the analog out fifo?
Solved! Go to Solution.
03-23-2012 12:17 PM
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:
but so far I have not found a similar mechanism for analog output.
national instruments guys, can you comment?
03-28-2012 10:00 AM
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.
03-28-2012 10:39 AM
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
to get rid of it. but for a continuous waveform or multiple channels, this won't work.
03-28-2012 05:00 PM
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!
03-28-2012 06:00 PM
awwww yeah! that works:
tAddressSpace bar0Space = nub->GetBar0AddressSpace();