This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Is it possible to do back to back SPI transfers or read only during RX time?

I need to write received data from SPI to address pointed by a parameter. When doing a transfer, spi drivers also read the data sent by slave during TX. I know this is normal since SPI is full-duplex protocol. However, I have strict time constraints so I can't copy read data between buffers (I've done this and it worked but the performance wasn't great). Also, I can't use pointer arithmetics since buffer is elsewhere. I thought that if I could make TX - RX transfer back to back seperately, I can solve this problem. Is there a way to do this or do I have an alternate solution?

Parents
  •  Let me give you a small example

    void example_function(const uint8_t *p_tx, uint32_t tx_count, uint8_t *p_rx, uint32_t rx_count)
    {
    /* I need to write tx_count bytes from p_tx
    * Then I need to read rx_count bytes to p_rx
    * If I set up nrf_drv_spi_transfer or nrfx_spim_xfer to write tx_count bytes and read rx_count bytes, I only see (rx_count - tx_count) bytes in p_rx.
    * If I change it to write tx_count bytes and receive (tx_count + rx_count) bytes, I have the data that I want in my buffer but with extra tx_count bytes from tx time.
    * If I copy received data to a local buffer, then memcpy only the data that I want, it works but performance is not great. */
    }

    Why do you need a separate buffer for the two RX bytes?

    It was an example, it's not always 2 bytes.

  • seneryilmaz said:
    If I copy received data to a local buffer, then memcpy only the data that I want, it works but performance is not great.

    What exactly do you mean by 'performance is not great'? What are your requirements? 

    btw:
    If you read with fixed-width buffers and use DMA ArrayLists then you can do 'x' amount of transfers of length 'y', back-to-back, without needing to process the data until you're done with all the transfers. 

  • I need to read data from SPI slave before next interrupt rises which is approximately 100-200 microseconds.

    I think I couldn't explain myself well enough.

    I don't want bytes A, B, C sent by slave in my rx buffer. How can I do that? 

  • But do you need to process that data every 100-200µS or is it okay to keep it in RAM and process the data in larger batches at a later time? 
     

    seneryilmaz said:
    I think I couldn't explain myself well enough.

     You sit on all the context here, I'm not a telepath. 

     

    seneryilmaz said:
    I don't want bytes A, B, C sent by slave in my rx buffer. How can I do that? 

     You can't.

Reply Children
No Data
Related