Is it possible to configure nRF5340 with dual line SPI (CONFIG_SPI_EXTENDED_MODES / SPI_LINES_DUAL)?

Is it possible to configure nRF5340 with dual line SPI using CONFIG_SPI_EXTENDED_MODES and SPI_LINES_DUAL?

I'm trying to evaluate the Analog Devices AD7616 or the TI ADS8686S – Both defaulting to this unusual setup in serial mode.

I would like to not use the QSPI currently in use for nRF7002, keeping the throughput for that device maximised.

Examples or guidance would be much appreciated!

  • Hi Rune

    There is no support for two data out/in lines in the regular SPIM/SPIS interfaces, no. 

    The AD7616 appears to allow one wire SPI mode if you set the SER1W line low. Would this be a possibility? 
    I didn't check for the ADS8686S, but I assume it also has a way of using 1 data line. 

    Technically the QSPI can communicate over 2 data lines, but this interface is very much optimized for connecting to external memory and will only support the basic instruction set used by such devices (you can see the full instruction set here). 

    You could also run two SPIM interfaces in parallel and split the data between them, but this would be quite tricky to pull of in practice (involving some task, event tricks), and would occupy two full serial interfaces, so I doubt it's worth it. 

    Best regards
    Torbjørn

  • Thank you for your speedy reply Torbjørn!

    I have indeed tried the 1-wire serial mode on the AD7616, but it does not work as expected.
    I have an open ticket at Analog Devices, and suspect a defective chip.
    The evaluation board for the Texas Instruments part is getting delivered later today and I hope for better luck with that chip.

    In any case – It's good to know that I don't have to rat-hole on the dual MISO setup.

    Out of curiosity; would a possible hack be to set up an SPI slave on the second core of the nRF5340 and clock in the data in parallell?

    Or perhaps the second core of the nRF5340 is in use for communication with the nRF7002 on the nRF7002 DK?
    I'm not using Bluetooth, so I could possibly use both cores for my application?

  • Hi Rune

    Rune Warhuus said:
    Out of curiosity; would a possible hack be to set up an SPI slave on the second core of the nRF5340 and clock in the data in parallell?

    This might be possible, but I don't think it will provide any benefit, it will just make the development a lot more complex. 

    All the peripherals in the nRF5340 support "EasyDMA", meaning they can run in parallel and communicate directly with RAM without the CPU having to do anything (other than configure the transaction beforehand). There is no need to run one SPI peripheral from a separate core in order to have them run in parallel. 

    The application core has a lot more peripherals available, and it will also be easier to control everything if you have both peripherals on the same core. 

    Whether or not you should use SPI slave or master for the second interface is up to you. You could set it up as a slave, and make sure to connect the chip select and clock lines from the master both to the external sensor and to the SPI slave on the nRF5340. 

    Still, I think using two SPI masters is a more power efficient way. In this configuration you need to disable the clock and chip select lines of the second master and just use the clock and chip select from the first, only the data lines would be needed. 

    If you end up doing this I would recommend making SPIM4 the primary master, since this interface is not shared with any other interfaces (UARTE, TWIM, TWIS, etc), and then use SPIM0, 1, 2, or 3 for the second master. 

    For this to work you need to configure both the SPIM interfaces with similar settings, and use a DPPI channel through the EGU unit to trigger both interfaces to start at exactly the same time. 

    Rune Warhuus said:
    Or perhaps the second core of the nRF5340 is in use for communication with the nRF7002 on the nRF7002 DK?
    I'm not using Bluetooth, so I could possibly use both cores for my application?

    By default the network core is used for the Bluetooth controller only, so if you don't need Bluetooth this one will be free, yes. As mentioned I don't recommend splitting the two SPI interfaces between the two cores, as this will make the solution significantly more complex. 

    Best regards
    Torbjørn

  • Very good advice!

    I just got the ADS8686S delivered, and the 1-wire serial mode works as expected on that chip.

    That leads me to believe there was a hardware fault with the AD7616 I got.

    I can proceed with the prototype using one MOSI line and I will definitely look into your suggestions when crunch time is over. It would be nice to cut transfer time in half by clocking in two MOSI lines!

  • Hi Rune

    Rune Warhuus said:
    It would be nice to cut transfer time in half by clocking in two MOSI lines!

    How much data do you need to transfer every second? 

    The SPIM4 interface can be clocked up to 32MHz, if the sensor supports it, so unless your data transfer requirements are very high I would expect a single data line to be sufficient. 

    Because the SPI transfer happens in the background through DMA I doubt the energy efficiency will be much improved by running two data lines, but again this depends on your transfer speed requirements. 

    Best regards
    Torbjørn

Related