LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

General questions about FPGA Interface C API 2.0

Solved!
Go to solution

I have developed an application in LabVIEW FPGA 2011 on an R-series PXI board and a LabVIEW 2011 host application on Windows XP to communicate with it via DMA FIFO.  I'm trying to adapt the interface to CVI 8.1 (preferred) or CVI 2009 using the FPGA Interface C API 2.0.  The FIFO example that it stores in the C:\Documents and Settings\All Users\Documents\National Instruments\FPGA Interface C API\Examples\ directory left me with a few questions:

 

  1. Are the functions NiFpga_WriteFifoI16 and NiFpga_AcquireFifoWriteElementsI16 two different ways of doing the same thing? I wasn't clear on where I would do the addtional copy if using NiFpga_WriteFifoI16. I assume that the combination of NiFpga_AcquireFifoWriteElementsI16 with NiFpga_ReleaseFifoElements is the proper way to go if I wish to stay out of trouble.  
     
  2. I intend to call NiFpga_Initialize and NiFpga_Open in an initialization function that I call at the beginning, then keep the session handle to pass in calls from other functions.  Is the session handle always non-zero when it opens successfully?  Could I use that as a test to assure that I have a valid session before calling other functions example:
         if(session) {NiFpga_WriteFifoI16(...)}
     
  3. The FPGA Interface C API 2.0 is only advertised to work in CVI 2009 on up.  If I include NiFpga.c and .h in my CVI 8.1 project, it seems to compile fine, but I haven't had a chance to integrate it yet.  Is there anything specific that would make CVI 8.1 not work?  Our application deployment environment makes CVI upgrades difficult

 

- Jim

 

0 Kudos
Message 1 of 4
(3,674 Views)
Solution
Accepted by topic author JKneale

Jim,

 

In regards to your questions:

 

1. Yes those two functions do the same thing, however there is one big difference between the two. NiFpga_AcquireFifoWriteElementsI16 acquires, writes and releases FIFO elements to prevent the need to write first into a separate user-allocated buffer then copy the contents of elements to the host memeory buffer. Whereas, NiFpga_WriteFifoI16 does not. So the NiFpga_ReleaseFifoElements should always be used with the NiFpga_WriteFifoI16. The example is just showing how the code should be used, but is not necessarily showing which functions should be used together. I completely understand why it was confusing.

 

2. The best way to ensure that you have a valid session is by using the NiFpga_IsNotError() function. I've attached a screenshot of example code that demonstrates the best way to accomplish this and inserted the image below.

_CAPI.JPG

3. In regards to using CVI 8.1, there isn't anything in specific that would make your code not work in 8.1, however we can guarantee that C API 2.0 will work successfully with 9.0. 

 

Regards,

Larry H.

Applications Engineer
National Instruments
0 Kudos
Message 2 of 4
(3,665 Views)
  1. The simple version seems to work okay.  I assume that the second method would be faster if one was dealing with a large array.  I'll try it out and see if it helps in my application
  2. If opening the session and doing later data transfers are performed in two separate functions, then I need to retain a copy of the session id to pass into any function using the FPGA calls.  I can manually set it to zero if the NiFpga_IsNotError() indicates a problem, as long as zero isn't one of the normal session numbers to be expected. 

    I was just trying use it for both a session id, and as an indicator that we didn't successfully connect.  It would let me exercise the non-FPGA portions of that code when I'm offline
  3. I tried running it in CVI 8.1 this morning and got error -63192 (Invalid resource num). I then loaded CVI 2009, reloaded FPGA Interface C API 2.0 to assure that it had the files in the correct directory, restarted, and was able to sucessfully run the project that was previously giving me the error in CVI 8.1.  That thing is f a a a s s t!
0 Kudos
Message 3 of 4
(3,655 Views)

Jim,

 

In regards to question 2, if a session is successfully initialized, you would expect a non-zero number. When a session is not initialized, I believe you should expect a value of 0 to be present.

 

In regards to quesiton 3, it appears that using older versions of CVI are not compatible with C API 2.0 when it comes to actually running the code. But yes, I must agree, it is very fast when used with the proper software.

 

Applications Engineer
National Instruments
0 Kudos
Message 4 of 4
(3,651 Views)