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

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?

Parents
  • 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?).

    Ole

Reply
  • 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?).

    Ole

Children
Related