Changing SPI Mode (SPI_CS_HIGH Flag)

Applications, development tools, FPGA, C, WEB
Post Reply
User avatar
renegade264
Posts: 15
Joined: Mon Apr 08, 2019 1:08 pm

Changing SPI Mode (SPI_CS_HIGH Flag)

Post by renegade264 » Thu Jul 18, 2019 7:24 pm

Hi,

I have had great success using the SPI code provided by Red Pitaya from the docs. However I have encountered a situation where I need to change the SPI CS Pin to be active high during run time, as I am interfacing with a number of different SPI devices simultaneously, but consecutively. I have tried to assert the "SPI_CS_HIGH" flag by OR'ing it with the mode, however I get an invalid argument error, this has also been verified with the Spidev_test program (armbedded.taskit.de/node/318).

This leads me to believe that the spi device on board the Red Pitaya does not support this functionality, but it sounds like it shouldn't be impossible to achieve especially since it is connected and controlled by a module in the FPGA (to my understanding), I also see you can add overlays at boot-time, completely re purposing the SPI pins. I am wondering what changes I need to make so that I can change the state of the CS pin on the fly, as setting the flag might suggest? (remapping the CS pin to a gpio is not an option as the system is connected with a plug in header, I also would like a clean solution)

I am running version 0.98, uboot: 2016.4, linux kernel: 2017.2 with the c program loading the 'classic_fpga' bitstream at runtime.

Any help would be much appreciated, Renegade.

User avatar
redpitaya
Site Admin
Posts: 453
Joined: Wed Mar 26, 2014 7:04 pm

Re: Changing SPI Mode (SPI_CS_HIGH Flag)

Post by redpitaya » Tue Mar 03, 2020 3:47 pm

Hi and thank you for posting!

Please take a look here: https://redpitaya.readthedocs.io/en/lat ... /spi.html.

especially at function static int init_spi();

Tyler.Davidson
Posts: 1
Joined: Wed Feb 17, 2021 2:10 am

Re: Changing SPI Mode (SPI_CS_HIGH Flag)

Post by Tyler.Davidson » Wed Feb 17, 2021 2:13 am

renegade264 wrote:
Thu Jul 18, 2019 7:24 pm
however I get an invalid argument error
Hey renegade, have you found a solution for this? Experiencing the exact same problem.

Thanks,
Tyler

User avatar
renegade264
Posts: 15
Joined: Mon Apr 08, 2019 1:08 pm

Re: Changing SPI Mode (SPI_CS_HIGH Flag)

Post by renegade264 » Wed Feb 17, 2021 11:21 am

Hi Tyler,

No didn't manage to find a solution in software. I luckily had buffers on the CS line for all of my chips and replaced the ones which needed the CS high flag to be the other way around, i.e active low, to inverting buffers. I think I actually prefer my hardware solution, though I would also like to know how and if you could modify the state of CS High on the fly.

Thanks.

Post Reply
jadalnie klasyczne ekskluzywne meble wypoczynkowe do salonu ekskluzywne meble tapicerowane ekskluzywne meble do sypialni ekskluzywne meble włoskie

Who is online

Users browsing this forum: No registered users and 2 guests