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

How to use DMA in NRF52 while writing on SD card, while BLE is also operating?

Hi,

In my application of interfacing SD card with nrf52, I am using SAADC to sample the input signal at 1000 samples per seconds. These samples I am combining in 84 packets each consisting 12 samples and 20 bytes. In one second I am sending 84 packets over BLE to remote tablet device.

So, I want to write these packets in SD card. Writing one packet at a time is not a good practice. So I want to write 40 packets at a time in SD card. For this I need DMA. As I am never used DMA before, I want to understand what is the correct steps to use DMA for my application.

Does any one has any idea about this?

SDC+BLE.c

Parents
  • FATFS port present in SDK 12 is using the asynchronous SD card driver (which uses SPI master driver in EasyDMA mode on nRF52). Unfortunately FATFS API is synchronous, so if it's not modiffied and used without preemptive OS, CPU has to wait for SD card operations to complete on every synchronous API call. However, when there is a serial data transfer in the background (card read/write operation), higher priority interrupts should not affect SD communication (except the possible delay), as far as SPI driver interrupts are being handled.

    I'd suggest the following scenario:

    • allocate 2 buffers,
    • set current buffer to #1,
    • start ADC sampling (N=12 samples appended into the current buffer)
    • send the samples over BLE and trigger the next sampling,
    • if current buffer is ful then switch current buffer to #2, start the ADC sampling into #2 and trigger the write of #1 into SD; while writing the data, you can still send the packets over BLE and trigger ADC sampling in interrupts
    • ...and so on...

    Note that the worst case scenario for SD write operation (according to SD specifications) is 250 or 500ms, depending on card type.

  • Hi Pawel,

    Thanks for your suggestion in mentioned attached code above.I will change it volatile bool . Actually I am initializing SAADC before SD card and BLE but not starting it to sample the input signal.After every thing has been initialized properly, then using Nordic UART service I am sending some values(1 or 2) to start sampling the SAADC. (This happens after BLE starts advertising ). So AS sson as received any value from master control panel ADC samples the signal and after 12 samples it generates EVENT DONE event in Callback.

    I am using IAR for developing my code and using MCP to get the values over APP. AS soon as I sent any value 1 or 2 , entire code gets stopped and over MCP I received GATT error :133(0x85). In IAR it is not showing the cause of sopping the code.

    In SAADC initialization I have set priority as APP_IRQ_PRIORITY_LOW from default value of lowest.

Reply
  • Hi Pawel,

    Thanks for your suggestion in mentioned attached code above.I will change it volatile bool . Actually I am initializing SAADC before SD card and BLE but not starting it to sample the input signal.After every thing has been initialized properly, then using Nordic UART service I am sending some values(1 or 2) to start sampling the SAADC. (This happens after BLE starts advertising ). So AS sson as received any value from master control panel ADC samples the signal and after 12 samples it generates EVENT DONE event in Callback.

    I am using IAR for developing my code and using MCP to get the values over APP. AS soon as I sent any value 1 or 2 , entire code gets stopped and over MCP I received GATT error :133(0x85). In IAR it is not showing the cause of sopping the code.

    In SAADC initialization I have set priority as APP_IRQ_PRIORITY_LOW from default value of lowest.

Children
No Data
Related