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.

SPI Sending and Receiving at the Same Time Via Stream API

Other Parts Discussed in Thread: OMAP-L138

Hi,

 

Iam using the PSP SPI driver via the stream API layer. Writing and reading from the stream is done in 2 concurrent tasks. The read as well as the write function blocks forever, until data can be written or data is available for read. However, if I want to write data to the stream at the same time the read function is blocked by waiting for data to receive, the write call throws the following exception:

  ti.sdo.io.Stream: line 520: assertion failure: A_pendingReclaims: Packets issued but not reclaimed

  xdc.runtime.Error.raise: terminating execution

 

Since SPI is a bidrectional bus, Iam wondering on how to read and write data at the same time. Can you tell me how I can achieve this goal? Is it possible using the stream API or do I have to use the SPI interfaces directly?

 

Any help and explanation on this issue is very appreciated.

 

Kind Regards,

Steve

 

P.S.  Iam using IPC version 1_21_02_23, bios version 6_30_03_46 and PSP version 02_10_01. If you need additional info please let me know....

  • Hi Steve,

    Can you please elaborate your application setup?. Like - are you doing a loopback? or board to board transfer? and which stream API's you are using?.

    Steve Kreyer said:

      ti.sdo.io.Stream: line 520: assertion failure: A_pendingReclaims: Packets issued but not reclaimed

      xdc.runtime.Error.raise: terminating execution

    The Stream would not allow you to do a write greater than the "streamparams.maxIssues", unless the packets of the previous write requests are reclaimed. So, you are getting this exception.

    Well, during stream creation, what are you setting this value to? - "streamparams.maxIssues"

    In the sample application, it is set to 2. Changing this to your requirement as to how many concurrents writes you are doing, might solve your problem..

    Hope this helps..

     

    Thanks & regards,

    Raghavendra

  • Hi Raghavendra,

    thanks for your answer. Sorry for the big delay but Iam currently involved in another topic at work.

     

    According to your answer:

    I think your suggestion has to do with concurrent writes, but my problem is that I just want to "read and write" at the same time using the same stream, not "write and write" at the same time. Because the Stream_read-call issues the buffer and blocks until the buffer is reclaimed, the variable object->issues is greater than 0 (Stream_issue increments this variable, and only Stream_reclaim decrements it (when the buffer is reclaimed)) and my Stream_write call (which is concurrently issued to blocking Stream_read) fails and throws an exception if obj->issues is not equal zero. Is this intendet in a concurrent read-write scenario? Stream_read and Stream_write are using different buffers, so in my opinion there is no need to forbid concurrent read-write scenarios.

    Is this a bug in the PS version Iam using or am I just missing something important?

    Thanks for your help.

     

    Kind Regards,

    Steve

  • Hi Steve,

     

    Which SPI Slave device are you using/communicating to?.

    I am not clear with the following statement..

    Steve Kreyer said:
    I just want to "read and write" at the same time using the same stream,

    can you please elaborate?..

    If you refer the BIOSPSP Userguide, section 4.6.4 the NOTE section specifies that the "channel will be created only in DriverTypes_INOUT mode". Hope you are taking this into consideration. Also, can you please explain your test setup?. Or would it be possible to share your application project?.

     

    Thanks & regards,

    Raghavendra

  • Hi Raghavendra,

     

    the slave device is the OMAP-L138 and Iam talking to a PPC host device (which serves as the SPI master). Please see the attachment for the test setup. This should make my issue clear.I've also wrote some comments to make it easier to understand.

     

    Thanks for your time and effort.

     

    Kind Regards,

    Steve

     

    Attachment

    7230.spit_shortened.c.txt

  • Hi Steve,

    Since Stream_write() / Stream_read() are synchronous calls(blocking), you cannot use it in multiple task scenario.

    This is because when Stream_read() is called it blocks the present task and the next task gets the time slot to execute. As Stream_read() is already blocked in the task1, the BIOS does not allow subsequent Stream_ call in the task2, since stream layer maintains the number of buffers issued. 

     

    You can refer – Stream.c file(placed in: ipc_1_20_00_23\packages\ti\sdo\io\Stream.c) function, Stream_submit(..) :  (obj->issued == 0) is where you are getting an exception.

    Stream_write()/Stream_read() are equivalent to an Stream_issue()/Stream_reclaim() pair. Since you cannot use Strem_write() (as it is a synchronus call), replace it with Stream_issue () and Stream_reclaim() pair. Stream_issue() and Stream_reclaim() pair are asynchronous calls(non blocking) and can service multiple buffers, hence can be ideal for your requirement.

    Replace Stream_write() with the following pair:

              Stream_issue(handle, buf, size, NULL, NULL);

              Stream_reclaim(handle, (Ptr *)&buf, BIOS_WAIT_FOREVER, NULL, NULL);

    Secondly, when issuing two packets from a single handle you should make sure "maxIssues" of the streamParams is correctly set.

                /* This value should be equal to the number of buffers used in the application */

                streamParams.maxIssues = 10;

    Hope this helps..

     

    Thanks & regards,

    Raghavendra

     

  • Hi Raghavendra,

     

    I see. Thanks for the suggestion I will try that out and give you feedback in the next days.

     

    Thanks,
    Steve