SPI support for bare metal (version 2.0.99?)

Hello,

I would like to use spi to connect to a ADC on a nrf54l15dk at high speed using DMA.

I want to use nrfconnect bare metal, but cannot find a starting example.

In  https://github.com/nrfconnect/sdk-nrf-bm there are a few spi-examples.

How can I use them? It seems that this is part of a version v2.0.99.

So, how can I use these examples starting from bm version v2.0.1? That is the only option I have in vscode.

    Thanks in advance, Sietse

Parents
  • Hie Sieste,

    Can you please confirm if I am understanding you correctly - You want to use SPI to connect to "external" ADC at high speed using DMA.
    If you need high speed, we recommend using SPIM00 and GPIOs on P2. 
    It is possible to use the nrfX peripeheral drivers to run in NCS-BM. You can refer to the one in main(2.0.99) and use it as a guide on how to add the driver. 

    Use relevant nrfx interface header in your application source file.

    #include <nrfx_spim.h>

    Or for direct register (HAL) access, e.g. GPIO:

    #include <hal/nrf_gpio.h>
    NCS-BM also provides the SPI Transaction Manager library (bm_spi_mngr) to manage a FIFO queue of transactions. Please let us know if you you need more assistance with your issue.

    BR

    Pallavi

  • Thanks for the reply!

    Yes, I am using an external 16 bit adc that I hope to use at 300k samples/sec.  It is to become a kind of software defined radio (SDR).

    I now see an example in nrf-bm/v2.0.1/modules/hal/nordic/nrfx/samples/src/nrfx_spim.

    I will try to use that to get familiar with the spi device.

      Regards, Sietse

Reply Children
  • the nrfx_spim example is not offered via the vscode interface in "Create a new example". Is there a reason for this?

  • Yes, you are right. I couldnt myself find the SPi sample in V2.0.1. If you can tell me your exact requirement,  can ask the team for it. I hope that will be more helpful to resolve your issue quickly.

    Regards

    Pallavi

  • Thanks again.

    I found a few examples on how to combine an nrfx driver in zephyr. I need to properly understand how everything works, so I will try to solve this myself. Often the best way to learn.

    But I have another question. I want to stream the ADC data at 300kHz, so roughly each 3 microsecond a sample. I see how I can receive a block of data (say 2000 bytes) in one transaction, using EasyDMA. But how to connect transactions into a proper stream?

    I understand that after a transaction an interrupt can be generated to start a next block. But is that quick enough? How to make sure the time between each sample always is the same. Some variations are allowed but not too much. Almost half of the 3 usec is used for the actual data acquisition and the spi tranfer, so not much more than 1 usec is available for the interrupt to occur and finish.

    Is it a good idea to use the coprocessor for this? Each interrupt some status is set and the next block is started. In the main loop the received data is copied away to be processed by the main processor using double buffering. Can this be made to work in the bare metal environment?Thanks again.

Related