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

Sending 30000 bytes to Android Phone every 30 seconds while UART is receiving data every 40ms

Hi all,

I am working on a project where the requirement is a sensor collecting data and sending to the NRF52832 via UART. Every 40ms, the NRF52832 will receive 40 bytes of data. I need to store 30 seconds worth of data in RAM (about 30000 bytes) then transfer everything via BLE to a mobile app. While it is transferring this data, UART still needs to work and collect 40 bytes every 40ms.

What I have done previously was to send the data out via BLE immediately at every 40ms and this works fine. However, the app developer ask that I only send the data over only every 30s. I am now stuck with how I can collect 30000 bytes first and still have UART working while doing the BLE transfer. I don't really have an idea of what kind of modifications I will need to make to the BLE_UART example code.

Anyone can help? Thanks in advance.

Parents
  • Hi,

    It sounds like using your UART with EasyDMA combined with a timer, a counter, and some PPI channels could solve your problem. In short, you can set up a timer to trigger an event every 40ms and connect this via PPI to a transfer task in your UART. You can then use EasyDMA and let the UART transfer data directly to a buffer in RAM. Use the counter to count the number of transfers and fire an interrupt when you have enough data to send. You can do all these things completely autonomously, without using the CPU and hence, not block any BLE transfers. After 30k samples, when it is time to transfer your data, the counter interrupt triggers, you swap your buffer to a secondary one and then start transferring your first buffer. 

  • Hi MartinBL,

    I am revisiting this thread to clarify about the method you suggested about using EasyDMA and UART. I posted a separate thread to understand about using PPI and UARTE here. However I was told that the EasyDMA feature of UARTE peripheral on nRF52832 have a maximum size of 255 bytes. Does it mean that I can only store up to 255 bytes in RAM using EasyDMA? I am confuse now. Moreover, I have not been able to get PPI to work with a UARTE RX task.

  • Yes, unfortunately you can only store 255 bytes at a time. In other words, after 255 bytes you will have to trigger an interrupt and switch buffers. So it is possible to read a continuous stream of data, but you will have to use the CPU at 255 bytes intervals to manage the buffers and process the data. If you are able to upgrade to nRF52840 then you can use 1023 bytes long buffers instead.

    Moreover, I have not been able to get PPI to work with a UARTE RX task.
    Where are you stuck?

  • Hi MartinBL,

    Thanks for the help. I figure out another method to solve my problem. Using PPI with UARTE is just too complicated for me. Thanks again!

Reply Children
No Data
Related