Digital I/O

Showing results for 
Search instead for 
Did you mean: 

SPI Communication using PXIe-6556

I routinely have to communicate with various ASICs using mostly the SPI interface and occasionally the I2C bus.  Typical usage would be to write to programming registers in the ASIC or reading back the register values to update fields in my LabVIEW code.  I have built LabVIEW software to do this using the HSDIO driver VIs.  The software is rather complex, and I was looking for a way to simplify it when I came across the SPI Digital Waveform Reference Library. 


It was pretty easy and straightforward to put together a VI to write the bits out to the ASIC.  My problem is that I don't see a way to read back the register values from the ASIC and post the values.  The can handle full duplex communication, but does not seem to return the waveform read back from the ASIC.   Nor does the  Using the HSDIO driver I setup a generation and acquisition session, and program the ASIC for a read operation.  The acquisition session is triggered from the generation session, and then fetches the waveform data from the 6556 memory.  From there I can parse the bits and ascertain what the individual register values are. 


My question then is how do I do this using the SPI library?

0 Kudos
Message 1 of 7

Hello SenorBob


After you installed the SPI Library did you try to use the examples it installed in Example Finder.


Help>>Find Examples>>Browse > SPI then verify the list of examples.


Also, which LabVIEW Version are you using?


Could you attach the list of examples you found by a screenshot?



0 Kudos
Message 2 of 7

Hello David,


Thanks for your reply.  I did play around with the one and only example from the SPI Library, aptly named SDW 16-bit Register  I am currently using LabVIEW 2016.  I've attached the block diagram of the example file that I started playing with.  I used that example to get me started with my own example. 


I've attached the front panel and block diagram of that VI as well.  Keep in mind that I'm still playing around with this VI and so it's no where near complete (or even well thought out) yet.  The front panel shows to arrays of clusters (Input and Output) that represent what in practice I would like to do.The Input Array has the registers I'm trying to write to including their name, register value, address, and register length.  The write part is clear to me. 


The second part of what I want to do is to read from those same registers and use the read back data to fill in the Output Array's register value. Since the Swap.VI is a full duplex operation, I'm assuming that the write and read occur at the same time, and the SDO read back data is available after the operation.  If that's the case then I just have to parse the SDO data for the register values and update the Output Array.  Does that sound about right?


Thanks again,

Senor Bob

0 Kudos
Message 3 of 7

Hello SenorBob


I am glad to hear that for writing everything is good. Regarding with the reading on the bus we probably need to know where the information was located(Address) in order to ask for that data.


Also, I found this video in relation with the link adobe. (SPI Digital Waveform Reference Library)



0 Kudos
Message 4 of 7

Hi David, 

I'm afraid I couldn't find your video link.  Both of the links were to the SPI Digital Waveform Reference Library.  But I did put together some images that maybe can help provide a better understanding of what I'm trying to do.  Pictures as they say are worth a thousand words.


The first image I want to show you is an example of our SPI Interface.  It shows the SPI Interface in relation to the Registers.  The SPI packets are 32 bits in legth, but the register data is 27 bits in length.


SPI Blk Dgm Example.PNGThe next image breaks down the 32-bit SPI packet to show how our write data is constructed.

SPI Packet Example.PNG

The 4-bit address is the register address.  An example of what the I'm calling the Register Map provides details of the 27-bit Data field, and is shown in the next image.  The 27 bits in the Register Map comprise the 27-bit Data field above.


Register Map Example.PNG

And finally because the image is too big to be included inline, I've attached an updated version of my experimental front panel, so please refer to it for the following discussion. 


I've kludged my experiment so that the MISO and MOSI data are the same and are coming from the Input Array.  Looking at the MISO data, starting around sample 1 is the MSB and it is the R/W bit.  The next 4 bits are the address bits, and the final 27 bits represent the Data field. I parse that full 32 bits of data into the various sub fields, and then further parse the 27-bit Data field in the register data, which I use to fill in the Output Array. 


The code all works as expected offline.  My question is will it work in reality.  Will SPI Library's actually work in full duplex and return what's in the registers, or do I need to break this up into 2 phases where I write to the registers using the, and the read back the registers using the


Sorry this got a little long winded.  I hope this helps to clarify what I'm trying to do.  And thanks for the help.



0 Kudos
Message 5 of 7

Hello SenorBob


Thank you very much for the information. Is there possible we could try using the with a simple code in order to norrow down the issue. Also I would like to know if before this code worked. Lastly, the is just running one time, isn't it?




0 Kudos
Message 6 of 7

Hi David,

So I was in our lab today playing around with this some more.  I was trying to capture the waveforms on a scope to see what was actually going on, and I never captured any waveforms.  So I started digging into more of the low level VIs in the SPI library, and I think the light finally came on.  The SPI Reference library doesn't contain any VIs for actually causing the HSDIO to initiate a generation or acquisition session.  It simply provides VIs that help build up the waveforms, but you still need to use the HSDIO drivers to generate the waveforms. 


This image is typical of how I actually cause the hardware to generate my waveforms.


So the SPI library is the equivalent of my DIO SPI Data Config VI in the upper left of the image.  Then I configure the DIO hardware with the Config Read and Config Write VIs.  Then I use the HSDIO driver to actually make the hardware run.  For some reason I assumed that the SPI library would handle the whole process.  So the SPI library might make creating the waveforms a little easier, and it does provide for setting up all the timing in one nice place, but at this point I'm not sure that it really provides me with any significant advantages over what I already do. 


Do you think I'm understanding this correctly?  If so I think my experiments are done, and I'll move on.

Thanks for helping.  Sometimes explaining what you're doing to someone else helps turn on the light in your own head.





0 Kudos
Message 7 of 7