This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Using SPI in different tasks

Hi,

I have a single GIO object which I create using GIO_create with IOM_INOUT mode. I am using this for SPI reads and writes which are done by three different tasks. That means my single SPI channel object is being shared by three different tasks. I read in the BIOSPSP_SPI_Driver_Design document (this is the document in the Program Files/Texas Instrument/pspdrivers... folder) section 2.1.2.2.1 that a single channel handle cannot be shared between tasks.

My problem is that after my application runs for a while the internal semaphore which the SPI driver uses to synchronize multiple tasks blocks all the three different tasks using the SPI interface. Note that for my purpose I am using GIO_write and GIO_read which are blocking and not GIO_submit but they should work fine within tasks.

I tried creating other channel handles with GIO_create so I can use them in the different tasks but GIO_create returns NULL. Is it possible to create other channel handles on the same device instance as the document suggest to do?

Also in the SpiLocal.h file there is the Spi_Object struct which has this member variable

Spi_ChanObj chanObj[Spi_NUM_CHANS];

but I can't find where this value is set. Does this parameter determine the number of channels I can create on the device?

Also is creating my channel in IOM_INOUT ok? In the SpiLocal.h file before the Spi_ChanObj structure the comment is that "This mini driver must be opened for input and output separately". Does this mean I can't do IOM_INOUT?

Thanks

  • Hi Cecil,

    Can you please confirm which version of the BIOS PSP are you using?.

    As mentioned in the BIOSPSP_SPI_Driver_Design document, Yes.. a single channel handle cannot be shared between tasks.

    But, you should be able to create another channel handle on the same device instance. For this you might need to make a small change in the Spi.h file (placed in - pspdrivers_01_30_01\packages\ti\pspiom\spi) - change Spi_NUM_CHANS to (2) - which determines the number of channels that can be created on the device. And then, build the driver.

    Cecil Schandorf said:

    Also is creating my channel in IOM_INOUT ok? In the SpiLocal.h file before the Spi_ChanObj structure the comment is that "This mini driver must be opened for input and output separately". Does this mean I can't do IOM_INOUT?

    Please do not go by the comment. You can absolutely create the channel in IOM_INOUT mode. Sorry for the inconvenience.

    Hope this helps..

    Thanks & regards,

    Raghavendra 

  • Hi Raghavendra,

    I am using the 1.30.01 psp driver.

    I actually tried that after I posted the question and recompiled the spi driver with the Spi_NUM_CHANS set to 3 and I was able to create more than one channel. IOM_INOUT seems to work fine too but I wanted to verify that there will be no problems using it after I read that comment.

    Thanks for the clarification.

    Cecil

  • By the way any particular reason why the Spi_NUM_CHANS was set to 1 in the first place?

  • Hi Cecil,

    There is no particular reason though, but it was just set to a default value. In the sample application provided we only make use of single channel object.

     

    Thanks & regards,

    Raghavendra