I’ve been recently asked to help out with some SPI communication support with FTDI FT4222 device. For those who don’t have idea about this comm., it’s one of the famous inter-controller communication method. The SPI comm. speed with FT4222 can go up to 53.8Mbps. Really, it’s that much speed however you should have board designed for that much speed.
Here is a short story on how I did it.
I developed low-level LabVIEW drivers which essentially uses the LibFT422 DLL from FTDI. The 4 important SPI comm., functions to be achieved are
- SPI Master Read
- SPI Master Write
- SPI Slave Read
- SPI Slave Write
After writing the low-level drivers in LabVIEW, I wanted to do the real testing. But to do the real testing, I don’t have access to the real hardware and I have to do away with other options. It has stricken me that I can make use of my hobby electronic items to do this real project testing. So, I used hobby items like
- Arduino Uno board,
- Saleae Logic Analyzer,
- Few burg wires.
The easiest of those 4 functions is the SPI Master Write. I can do the SPI Master Write with only UMFT4222ev EVM on hand and connect those SPI lines (MOSI, SCK, SS) to my hobby logic analyzer to check if I’m really getting the data I have written in LabVIEW. Ooohlaa! I got the same string I had written in LabVIEW.!
Next easier one is SPI Slave Write. Similar to SPI Master Write, I just wanted to write some bytes in LabVIEW and check in logic analyzer whether I can receive the same bytes. Here too, I got the same string I had written in LabVIEW.!
Next tricker one is SPI Slave Read. For this, I wanted some master to keep sending the data so that I can read them back in my LabVIEW. And, that’s the purpose of Arduino here. I generated some texts in Arduino sketch and streamed those texts in it’s SPI Master. I tried to read them with my low-level LabVIEW drivers. Wow, I got them too..! LabVIEW shows the text I generated in Arduino.
In FT4222, SPI Slave works in 3 modes viz
- Slave read With Protocol – Some extra bytes before and after payload data which gives the consistency in the data streaming. Also handshaking between master and slave happens after receiving the packet.
- Slave read Without Protocol – Simple SPI comm. where you write only the data and read back the same data
- Slave read Without Acknowledgement – Same as with-protocol, but NO handshaking happens.
I have written LabVIEW low-level for all these modes. However I written example VI for SPI Slave without-protocol, which I believe the easiest way for first time learners. Also, since that the project required only without-protocol, I used without-protocol mode. For with-protocol mode, FT4222 has a built in protocol decoder which I have not explored yet, but should be like I have to frame that protocol and send from the master.
I’m yet to do for SPI Master Read.. Awaiting..!
Ajay is a professional developer and architect of LabVIEW applications with extreme interest in getting the hardware connected to LabVIEW and automate the stuffs. He is also a good mentor for the various interns in his career. He is ready to help the people in techie roles.