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

sending data in BLE asynchronously

Hi,

I am reading a 24-bit data from SPI by getting a data-ready interrupt from GPIOTE pin in a NRF52832 chip. I have to buffer data for the BLE interval duration then send data after minimum required interval for example every  30 ms. If SPI data-ready signal rate get high enough I will lose some data from SPI while I am sending data synchronously in BLE so I thought there may be a solution to either using DMA and sending data asynchronously or using DMA to fill buffer from SPI instead of using interrupt. Unfortunately, I did not find any example that implements DMA in SDK.

Parents
  • Hi,

    Both the SPI Master Example and the nrfx SPI Master Example utilizes SPIM peripheral with EasyDMA support. The peripheral will clock out/fill the buffer with the requested buffer length before it generates any interrupts/events.

    Anyways, it sounds like you just need to store the SPI data in a larger buffer and transmit a larger buffer over BLE. DMA will not help with this, as the buffer provided to the SPIM peripheral would be overwritten if you start a new transfer with the same buffer. I'm not sure which BLE service you use to transfer data over BLE, but you would typically receive an error code if the transmit buffers are full. You then need to wait for an event from the softdevice telling you that a transfer completed, in order to prevent data loss.

    Possibly the Ring buffer library could be useful for your application. You fill it with the SPI data in the SPI event handler and transmit a larger chunk of data over BLE when the buffer has been filled enough.

    Best regards,
    Jørgen

  • Thank you for your response,

    I got your point about DMA and SPIM so what is your suggestion about my problem. I am new to BLE and nRF, I explain my problem below,

    I need sampling ADC with a minimum rate of 640 Sps and every sample contains 6 bytes of data. my samples is interrupting system uniformly so I have an interrupt every 1.5 ms(I think that I may miss some data while I am sending data over BLE so I suggest sending data using DMA). I currently use ble-uart example and I have problem to send all data using nRF52832. what service do you suggest or is there any example that can help me on this issue.

  • davidjonz2005 said:
    I think that I may miss some data while I am sending data over BLE so I suggest sending data using DMA

    Do you mean that you are missing data since the CPU is blocked by the softdevice and you cannot read out the samples from the ADC fast enough over SPI? Does the ADC not provide a FIFO or something that can allow you to read larger chunks of data?

    The alternative is to use EasyDMA list feature to receive multiple samples in consecutive buffers in RAM. You would then need some mechanism to count the number of completed transfers in RAM (for instance a TIMER in Count mode where the COUNT task is triggered though PPI on the END event from SPIM peripheral.

    The SPI master driver supports advanced features to allow you do start a transfer using PPI, and to use the EasyDMA list feature with post-incrementing of the buffer addresses. Unfortunately, we do not have any examples showing how to use these features in the examples.

    davidjonz2005 said:
    I currently use ble-uart example and I have problem to send all data using nRF52832. what service do you suggest or is there any example that can help me on this issue.

     This should be fine, you just need to send larger packets of multiple samples, and make sure you check all error codes to prevent data loss.

Reply
  • davidjonz2005 said:
    I think that I may miss some data while I am sending data over BLE so I suggest sending data using DMA

    Do you mean that you are missing data since the CPU is blocked by the softdevice and you cannot read out the samples from the ADC fast enough over SPI? Does the ADC not provide a FIFO or something that can allow you to read larger chunks of data?

    The alternative is to use EasyDMA list feature to receive multiple samples in consecutive buffers in RAM. You would then need some mechanism to count the number of completed transfers in RAM (for instance a TIMER in Count mode where the COUNT task is triggered though PPI on the END event from SPIM peripheral.

    The SPI master driver supports advanced features to allow you do start a transfer using PPI, and to use the EasyDMA list feature with post-incrementing of the buffer addresses. Unfortunately, we do not have any examples showing how to use these features in the examples.

    davidjonz2005 said:
    I currently use ble-uart example and I have problem to send all data using nRF52832. what service do you suggest or is there any example that can help me on this issue.

     This should be fine, you just need to send larger packets of multiple samples, and make sure you check all error codes to prevent data loss.

Children
No Data
Related