08-21-2017 05:16 AM
Hello,
I am trying to implement my own SPI communication on LabView FPGA (NI sbRIO 9607). In order to send a constant 1 byte data, I prepared a vi that is attached to this post (screenshot is provided below). I am trying to send the bits of the byte one by one. I checked the hardware line, it is working correctly, I can send a clock signal on this line with any clock, with a very similar (shift registers and an boolean inverter is used) vi.
Could anybody help me with this issue, thank you.
ONUR YILDIZ
Solved! Go to Solution.
08-21-2017 05:59 AM - edited 08-21-2017 06:00 AM
08-21-2017 05:59 AM
1) Make sure your number is actually binary 11000101 (decimal 197), and not decimal 11000101. Set it to U8 representation, and show radix (right click visible items)
2) The shift register is taking the carry from the previous iteration, when you actually need the value from the current iteration. If you are stopping after 1 cycle this won't matter anyway (and you don't need the bool shift register. Also, you should use 7 for your stop condition as the iteration is zero-indexed. You could use the rotate function instead, then you'll have to pull out the MSB value still.
I suggest changing to use "Number to boolean array", then auto-indexing this through a for loop where you set the value and have the timer etc. Still need to make sure you have a 197 decimal in this case.
Lastly, there are several SPI implementations which already exist for FPGA, just google it. Might save you a lot of effort.
08-21-2017 06:50 AM
Hi Ian and GerdW,
My problem is actually I can not see any signal other than noise on my oscilloscope, while I am trying to send a serial data to my microcontroller by this code. I checked my hardware and confirmed for several times, osciloscope and microcontroller pins are working properly. Indeed, I can send HIGH or LOW signals, or any clock signal, which shows me the hardware line is clear. Indeed in labview, I added an indicator and a timer controller for checking if I send the true value from software and it also shows me everything is all right. I add a picture of some "other" configuration, which I know it consist of unnecessary things, but for just test purpose.
I tried to use "for loop" configuration first, instead of "while loop", but my control signals which is mentioned above are not worked properly for "for loop" configuration. Because of this, I changed it to a "while loop".
I chose "Rotate Left with Carry" function, since it gives me the MSB, but Ian you wrote that "You could use the rotate function instead, then you'll have to pull out the MSB value still.". That function initially does not have any carry out the MSB as you mentioned also, or am I missing something, how could I pull out MSB with this function?
Thank you for your help again,
Best Regards
ONUR YILDIZ
08-21-2017 07:53 AM
Hi Ian,
Your suggestion about using "Number to Boolean Array" has solved my probelem. However, I could not understand why I could not observe any meaningful signal (i.e. other than white noise) with "Rotate Left with Carry" function, but it is no matter for me which solution does the work.
Thank you very much for your help sir,
Best Regard
ONUR YILDIZ
08-21-2017 03:02 PM - edited 08-21-2017 03:09 PM
@onrep wrote:
Hi Ian,
Your suggestion about using "Number to Boolean Array" has solved my probelem. However, I could not understand why I could not observe any meaningful signal (i.e. other than white noise) with "Rotate Left with Carry" function, but it is no matter for me which solution does the work.
Thank you very much for your help sir,
Best Regard
ONUR YILDIZ
Let me shed just a bit of light on that. Is it possibly be because you wired the Rotate Left with Carry to a I32 and the 24 MSBs were all Zeros?
Frankly I prefer something a bit more scaleable
Did you also need me to point out the case structure where the True and False cases differ only by the value of a boolean constant? (And yes, go look at that again a "T" constant in the True case and (you gussed it) an "F" constant in the False case