Showing results for 
Search instead for 
Did you mean: 

FPGA Target to Host DMA FIFO Multiple Channels

Go to solution

Hi folks,


I'm having a bit of trouble collecting data from my FPGA application. The control loop of my FPGA application is running and reading setpoint data from a Host to Target FIFO at a period of 50 uSec. I'm running a separate loop to write collected data form two channels to a Target to Host FIFO on a period of 1000 uSec. I'm taking data from the two channels and reading it on the Host in bundles of 500 data samples. The first problem I have is that my Read Method is timing out unless I set my data acquistion loop to run at a much slower rate. The depth of my FIFO on the host side is 60000, almost as large as the total number of data samples I expect to collect in total.


I'm having another problem when trying to write the data to an array. Even when my read method does not time out, I seem to only be recording the first bundle of data that is read. I initialized a blank array outside of my acquistion loop on the Host side and used the Build Array VI to take the current bundle of data and append it to the end of that array. I then store it in a shift register and pass it into the next iteration where I attempt to append the new set of data onto the old one, and so forth. I expected to obtain an array with all the collected data, but as I said I'm only collecting the first set of 500. I wonder if the structure of my program is correct. Any help that anyone could offer would be greatly appreciated. I've attached some images of my application for reference. Thanks you.

Download All
0 Kudos
Message 1 of 3

Hi Uxorious,


For the first issue, you could try to read from the Setpoint FIFO (on the FPGA VI) when the Number of Elements to Read is greater than 0. I think this will get rid of the timeout error (which I think is more of an underflow error). You can also add increment the timeout value you have on the DMA FIFO so that won't bother.


What I first see on your Host VI is you are adding the elements in the array in the wrong order. You should wire the output of the Decimate 1D Array in the second (not first) input of the build array. Either way you should be able to see the array increment and have a history of it on the waveform graph. It's odd that you are getting just the first 500 samples on the graph on every iteration... Can you add a probe or an indicator to the FIFO on the FPGA side to see that the array is really getting into the FIFO as you would expect?

Daniel REDS
RF Systems Engineer

Help us grow.
If a post solves your question, mark it as The Solution.
If a post helps, give Kudos to it.
Message 2 of 3
Accepted by topic author Uxorious

Hi Daniel,


Thank you for your response. I seem to have found a solution to the problems I've been having. It looks like it was a combination of a couple of things. First, the data acquisition loop was not executing until the movement was already completed since I wired the stop condition from the setpoint write loop directly to the data read loop. This was fixed by creating a shared variable for the stop condition and wiring it to both loops independently. This explains why I was only receiving the first set of data as it was being stored in the FIFO until the end of the movement. However, the feedback FIFO was still timing out. Prior to fixing the stop condition error, I placed a probe on the "Elements Remaining' wire of the read method and was finding that there were only 1023 elements (the depth of the FIFO on the FPGA side) even though I set the Host side FIFO depth to 60000. I figured out that this was originally due to the Read method not being called for the first time until the end of the movement. Although solving the stop condition problem mostly fixed this issue since the Read method was now being called during the movement, I decided to take a preventative measure and calling the "Start" FIFO method before the move is initiated just to ensure that the Host side FIFO memory is available immediately.


So yeah, it turns out wrong that timing parameters I set were fine after all. Good call on the reversing the order on the Build Array function. Oh, and I also had to move the Waveform chart to before the array is built so that it is not replotting the old data on top of all the new data it receives. On the same note, I moved the array indicator at the end to outside of the Read loop. Thanks again for all your help.




John A

0 Kudos
Message 3 of 3