Quick question: How do you configure the trigger in the FPGA C interface API?
I am attempting to interface to an NI (7965R) through Matlab MEX (C) function. I have programmed most the FPGA functions, including the NiFpga_ReadXXXX functions, the FIFO configuration functions, etc. I call NiFpga_Initialize, NiFpga_Open and they return status 0. The NIFpga_ReadArray functions return with status 0 but they don't return meaningful data (all zeros).
However there is one function that appears in our Labview code that I can't seem to find a C interface equivalent for, and that is a function to configure the trigger. Thsi is important because our FPGA is triggered externally. When I call the ReadFIFO functions I am getting a timeout, no matter how long a timeout or how small of a buffer I give it. I think because the trigger is misconfigured somehow.
Update: OK, in the configure trigger VI, they call a 'Read/Write Control' VI, I'm assuming this means it calls an NIFpga_WriteXXX function ?
Solved! Go to Solution.
Typically FPGA triggering is done with interrupts. Our FPGA Interface provides an interrupt example. If you have the latest version installed, you should be able to access the example by going to Start>>All Programs>>National Instruments>>NI FPGA Interface C API X.X>>NI FPGA Interface C API Examples>>IRQs.
Actually I think I may have found the solution - I looked at the LabView code and it uses Read/Write Control. So I need to call the WriteXXXX functions (for controls) and the ReadXXXX functions(for the indicators). The mapping from the control/indicator name that I see in Labview to the integer values is defined in the header file when you use the conversion wizard.
However, one of the controls is a cluster, which isn't supported by the conversion wizard. I'm assuming I will have to change the cluster to a series of values or an array, and recompile the bits file, then re-run the conversion wizard?
The conversion wizard wasn't able to convert the cluster because there isn't an exact correlation in C. The closest representation would be a struct. Changing to a series of values is probably the better option, unless the items in your structure are all the same data type.
Have tried the same memory dump four times with repeated calls of each of:
the array functions just repeat the first 4 bytes
the ReadI16 cannot cope with addresses which are only multiples of 2 rather than 4
no errors are reported
I advise you restrict yourself to using NiFpga_ReadU32.
Even then may need to consider swapped bytes? though this is more an Intel feature than an NI fault.
(was using a 7831R with 12.0 API)