How to use SPIM EasyDMA with nrf52?

Hi All,

I am struggling with this question from many days. Does the SPI transmit or receive operation in SPI master code uses DMA? While using SAADC DMA I have specified buffer size as N(some uint8_t value) and directly started the sampling SAADC through PPI. So as soon as buffer is fulled NRF_DRV_SAADC_EVT_DONE generated and we can read the data using nrf_drv_saadc_buffer_convert instruction. Upto this point it is clear that I can read the data from RAM when DMA buffer is full.

Now in similar way I want to transfer 20 bytes to external accelerator (which uses SPI) using DMA over SPIM. How can I achieve this specifying buffer size and buffer data.

As per DMA concept I can do my usual work in main function till all bytes getting transferred. How can I write data packets to RAM without CPU involvement and then to accelerator in nrf52?

  • Hi,

    The SPI master code (nrf_drv_spi) will use DMA (SPIM peripheral) if SPIx_USE_EASY_DMA is defined for the corresponding SPI instance (here denoted with x).

    Then use the nrf_drv_spi_transfer(..) function to set up the transfer and send data. The tx and rx data will be in the buffers passed into the function.

    You can even use the NRF_DRV_SPI_FLAG_HOLD_XFER if you want to setup the transfer, but not start it right away. Then you can for example start the transfer automatically using PPI when saadc is done (if this was what you intend to do?).


  • Yes, Ole you are right. Now I am using nrf_drv_spi_transfer(..) function to transfer 20 bytes using SPIM. I have initialized the buffer with the value that I want to transfer.Then I have just given that buffer and number of bytes to transfer to above function. As soon as all the bytes gets transferred, I have received the interrupt in the SPI interrupt handler.

    Thanks for your support.. I have some another questions regarding SD card writing with BLE and SADC mention [here](link text)` Can you suggest something regarding that...

    I want to write to SD card and want to use BLE for streaming at 1000sps

  • You mean this case?:

    This is handled by my colleagues Petter and Pawel, you should wait for their response.