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

SPI slave buffers nrf52833

Hello,

I am a bit confused about the SPI api documentation: https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/reference/peripherals/spi.html#spi-api

The spi_transceive function accepts multiple tx and rx buffers. How are these used? I think my question is not specific for SPI slave or master, but just for context: I am trying to implement a SPI slave. All the examples I found all use a 1 or 2 byte single tx and rx buffer. But the api accepts multiple buffers, and even a different amount of buffers for tx and rx, I don't see how this is supposed to be used.

What I need is as much throughput as I can get, and BLE with the nrf52 has a max throughput of about 1.4 Mbit, right? and the uarte has a max of 1Mbit baudrate. So we would like to use the spi slave to transfer data at a higher rate.

Is it possible to configure 2 buffers in a ping pong configuration, for example? So, new data can still be received when part of it is being transferred over BLE?

thank you

Parents
  • Hi,

    BLE with the nrf52 has a max throughput of about 1.4 Mbit, right?

     This depends on several factors both external such as environment but also the internal state of the IC such as what GATT role it implements and the connection interval etc. See this.

    Is it possible to configure 2 buffers in a ping pong configuration, for example? So, new data can still be received when part of it is being transferred over BLE?

     Yes this is possible. The SPIM peripheral itself supports double buffering, which means that the TX and RX buffer can updated once the STARTED event has been generated. If you're using the nrfx driver directly you can update the buffer by using the NRFX_SPIM_FLAG_TX_POSTINC and NRFX_SPIM_FLAG_RX_POSTINC flags when you call nrfx_spim_xfer(), this will use the array list functionality of the peripheral.

    AFAIK this requires you to use the nrfx driver directly as I don't think the Zephyr API exposes this possibility. 

    Here is an example that uses the Zephyr API and sets up an SPI Master and Slave on the same device. It should give you an overview on how to use the API.

    regards

    Jared 

  • Do you also have an answer to this part?

    The spi_transceive function accepts multiple tx and rx buffers. How are these used? I think my question is not specific for SPI slave or master, but just for context: I am trying to implement a SPI slave. All the examples I found all use a 1 or 2 byte single tx and rx buffer. But the api accepts multiple buffers, and even a different amount of buffers for tx and rx, I don't see how this is supposed to be used.

    The example, you mentioned is exactly what I mean. It uses a 2 single 2 byte buffers for both tx and rx. How does this work with multiple buffers? What is happening when multiple buffers are provided?

Reply
  • Do you also have an answer to this part?

    The spi_transceive function accepts multiple tx and rx buffers. How are these used? I think my question is not specific for SPI slave or master, but just for context: I am trying to implement a SPI slave. All the examples I found all use a 1 or 2 byte single tx and rx buffer. But the api accepts multiple buffers, and even a different amount of buffers for tx and rx, I don't see how this is supposed to be used.

    The example, you mentioned is exactly what I mean. It uses a 2 single 2 byte buffers for both tx and rx. How does this work with multiple buffers? What is happening when multiple buffers are provided?

Children
  • Hi,

    Martijn Jonkers said:
    The example, you mentioned is exactly what I mean. It uses a 2 single 2 byte buffers for both tx and rx. How does this work with multiple buffers? What is happening when multiple buffers are provided?

     It will assert. Using multiple buffers via the Zephyr API is not supported by nrfx. From transceive() which is called by spi_nrfx_transcieve_async() which again is called by spi_transceive_async():

     

    Martijn Jonkers said:
    Thank you. That thoughput of 1.3Mbps, is that also possible with the nrf connect sdk

     I'm not sure but my guess is that it's comparable with the Softdevice. 

     

    Martijn Jonkers said:
    And the  NRFX_SPIM_FLAG_TX_POSTINC and NRFX_SPIM_FLAG_RX_POSTINC flags, they are for the SPI master. are there slave equivalents?

     The nRFX driver for the SPIS does not have this option, but the peripheral and HAL supports it. Which means that it should be possible to implement this feature in the driver as what has been done for the SPIM. You would have to create a function that implements it yourself by using the array list feature of the EasyDMA. 

    regards

    Jared 

Related