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.

RTOS/EK-TM4C1294XL: SPI receive of unknown length

Part Number: EK-TM4C1294XL

Tool/software: TI-RTOS

Hi,

I am just playing around with the SPI implementation within the TI-RTOS context using the launchpad. Using the SPI loopback example everything works fine. However, in this example a fixed buffer size is used for receiving a message. How can I change the code if the received SPI message length is unknown? I tryed using the SPI_Control function but the included libs does not provide any results for a partial transfer. What can i do?

  • Volker,

    The SPI master always controls the frame size. The SPI slave has no control over this. The master also decides how many frames are expected in a give transfer. If the slave is sending data to the master, the master is still in control. If the total message size is unknown, then the upper layers need to use a protocol. The master could ask how big is the next data message. Or the master could keep asking for data and the slave could send a end-of-data token.

    ~Ramsey

  • Hi Ramsey,

    first of all, thanks for your answer. My question was kind of unclear, so let me clarify this: i am aware of the fact, that the master controls the bus itself, pulling CS low and initiate the clock for a possible duplex data transport. Due to this, the slave does not necessary need to know the number of bytes transmitted, as this is ended by pulling the CS line high again. As a result the specific number of bytes for a data transport master -> slave is not mandatory to know for the slave receiver. For this behavior I have to adjust the driver myself, right?
  • Volker,

    Since you are using the SPI loopback example, I suspect the slave is calling SPI_transfer(). This call must know how many frames to receive. This requires the master to transmit the same number of frames. If the data to send is less then the transfer size, simply pad the transfer with zero. But at the SPI layer, both master and slave must agree on the number of frames in each transfer.

    Not all transfers need be the same size. But if you change the transfer size, the master must communicate this to the slave before hand. On any given transfer, both sides must agree on the transfer size.

    I would not change the driver. We cannot support custom changes at the driver layer. It would be better to use your own protocol instead.

    ~Ramsey

  • Hi,

    I see the need for another communication layer in my implementation and the fact that the sizes has to be known to both at transfer time. Thanks for the detailed explanation.