LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

SPI coomunication on FPFGA

 

Hello,

For one of my projects I needed to interface a MAX31865, which has an SPI communication, with the myRIO 1900. Not finding the code already developed in the examples or in the community, after several attempts I was able to interface the MAX31865 with the myRIO in RT mode (see code attached).

Now I would need to interface 4 MAX31865 always with a myRIO1900 but through the programming of the FPGA.

Basically I should implement SPI communication on FPGA. I have found some examples but I have not been able to use them, can someone explain to me how to implement the SPI communication in FPGA on myRIO?

 

Someone has already developed a code for SPI communication on FPGA?

 

Reegards

David

0 Kudos
Message 1 of 2
(1,033 Views)

What examples have you found? NI does have I2C and SPI libraries for use on FPGA. There are actually even several variants out there.

 

https://forums.ni.com/t5/LabVIEW-Robotics-Documents/Implementing-SPI-Communication-Protocol-in-LabVI...

https://www.ni.com/en/shop/labview/understanding-the-spi-bus-with-ni-labview.html

https://www.vipm.io/package/national_instruments_lib_ni_spi_ip/

 

Now I2C and especially SPI are not exactly a very strict standard. There are many variations in signal timing, number of bits per transfer and all that kind of stuff that make it almost impossible to create a standard library that would work for every chip out there. And if someone would come up with such a library it would come with an initialization functions that requires several dozen configuration settings that all need to be set correctly for your chip, which means that you need to understand the chip interface down to the bit level and timing anyhow.

 

While I2C can be a bit tricky to implement, as it allows various addressing modes and mixes and matches address and data in the stream at different  levels, SPI is usually pretty straightforward to implement. It is basically in most cases a shift register of a chip specific size with sometimes a little extra address logic for more complex chips.

 

Working on this level requires some understanding of the involved hardware and if you do not have some way of monitoring the actual pins on the chip such as with a digital storage oscilloscope or similar you are generally poking in the dark when trying to figure out why the chip doesn't answer at all or not with what you would expect. This is not just software where you can quickly change a bit here and a function there to try to get something working with trial and error, but really requires  to work methodically and with the right tools, including some way of actually being able to monitor the hardware signals itself to verify that your FPGA program really does what you think it should do. 

Rolf Kalbermatter
My Blog
0 Kudos
Message 2 of 2
(993 Views)