Clarification on SPI Transceive Timing in nRF Connect SDK for RHS2116 Integration

We are developing on the nRF52 Development Kit (nRF52 DK) for the nRF52832 SoC. Our application involves a 4-wire pipelined SPI communication with the Intan RHS2116 chip. According to the RHS2116 documentation (page 30, Picture 1), the SPI connection is configured such that the RHS2116 automatically outputs data two command cycles after a command is sent. This means that by the time we reach the 3rd command, there will be output data on MISO that we need to receive concurrently as the master (nRF52832) transmits the next command via MOSI.

Our challenge is with the nRF Connect SDK and Zephyr OS: specifically, it’s unclear from Zephyr’s SPI library documentation if the spi_transceive function performs read and write operations within the same command cycle, which is required to meet the pipelined data flow of the RHS2116.

Could you confirm if spi_transceive in the nRF Connect SDK supports simultaneous read/write operations in the same cycle? Additionally, if there are configurations or alternative methods recommended for achieving this synchronized SPI communication with the nRF52832, we would appreciate any guidance.

Parents
  • Hi,

    Could you confirm if spi_transceive in the nRF Connect SDK supports simultaneous read/write operations in the same cycle? Additionally, if there are configurations or alternative methods recommended for achieving this synchronized SPI communication with the nRF52832, we would appreciate any guidance.

    SPI is full duplex, ie. that you can receive and transmit in the same transaction. 

    However, the sensor that you link to seems to want two bytes on MOSI, and then it'll return the data on MISO after that, as stated in this page:

    According to the RHS2116 documentation (page 30, Picture 1),

    a “Master Out, Slave In” data line (MOSI) to receive commands from the master device;
    and a “Master In, Slave Out” data line (MISO) to send pipelined results from prior commands to the master device.

     

    Kind regards,

    Håkon

Reply
  • Hi,

    Could you confirm if spi_transceive in the nRF Connect SDK supports simultaneous read/write operations in the same cycle? Additionally, if there are configurations or alternative methods recommended for achieving this synchronized SPI communication with the nRF52832, we would appreciate any guidance.

    SPI is full duplex, ie. that you can receive and transmit in the same transaction. 

    However, the sensor that you link to seems to want two bytes on MOSI, and then it'll return the data on MISO after that, as stated in this page:

    According to the RHS2116 documentation (page 30, Picture 1),

    a “Master Out, Slave In” data line (MOSI) to receive commands from the master device;
    and a “Master In, Slave Out” data line (MISO) to send pipelined results from prior commands to the master device.

     

    Kind regards,

    Håkon

Children
  • Hi, thanks for the response!

    We’re still seeing error 22, which suggests the SPI module isn’t addressed correctly with the spi_transceive_dt function. It seems like the SPI setup might not be configured right. Any advice on adding a new SPI device properly?

    Specifically:

    1. How to configure the device tree and the device tree overlay to set up a CS pin?
    2. Is a custom .yaml file needed for this particular SPI module, and if so, how should that be structured?

    Here’s our current overlay for the SPI module:

    &spi1 {
           compatible = "nordic,nrf-spi"; // using SPI as per ERRATA 58
           status = "okay";
           pinctrl-0 = <&spi1_default>;
           pinctrl-1 = <&spi1_sleep>;
           pinctrl-names = "default", "sleep";
           cs-gpios = <&gpio0 30 GPIO_ACTIVE_LOW>;
           rhs2116: rhs2116@0 {
                 compatible = "vnd,spi-device"; reg = <0>;
                 spi-max-frequency = <1600000>;
                 label = "rhs2116";
           };
    };
    &pinctrl {
             spi1_default: spi1_default {
                    group1 {
                           psels = <NRF_PSEL(SPIM_SCK, 0, 28)>,
                                       <NRF_PSEL(SPIM_MOSI, 0, 29)>,
                                       <NRF_PSEL(SPIM_MISO, 0, 31)>;
                    };
             };
             spi1_sleep: spi1_sleep {
                      group1 {
                           psels = <NRF_PSEL(SPIM_SCK, 0, 28)>,
                                       <NRF_PSEL(SPIM_MOSI, 0, 29)>,
                                       <NRF_PSEL(SPIM_MISO, 0, 31)>;
                           low-power-enable;
                       };
             };
    };
Related