Offset in SAADC samples with Easy DMA and BLE

I have a nrf52 application that samples four saadc channels at 1kHZ. That is: Map four pins to ADC input and let Easy DMA take care of the sampling so that the data is processed ten times a second (100 * 4 samples). This works pretty well, except...

When I enable the BLE connection, the data is shifted in the buffer. Without BLE enabled, the data layout in the memory is as following {{1,2,3,4}, {1,2,3,4}, ...}. But, when BLE is activated, the memory layout is: {{4,1,2,3}, {4,1,2,3}, ...} I really don't know what causes the difference. I have no way to check if the data is shifted, or did the samples just swap places. I wonder if the softdevice blocks some of the samples that would cause the problem.

The saadc implementation is double buffered, like in "saadc_sample_from_two_pins - scan mode" here

The BLE implementation is based on ble_app_hrs_freertos in SDK 12.1.0. That is also the SDK version I'm using.

Any help would be appreciated.

  • Have you tried it with a BLE application that is not based on FreeRTOS? Please have a look at this answer also.

  • I have not tried the application without FreeRTOS. I need to do some porting for that first.

    I checked the answer you posted. My case is quite much similar to that. Unfortunately the actual problem was not solved. I'm not calling nrf_drv_saadc_abort(), but I let the ACD sampling run throughout the application lifetime.

  • It would be great if you could try that. Would it be possible for you to upload your application so that I can do some testing on it? If you don't want to share the code publicly, you could create a case at MyPage and upload it there.

  • Hello I would like to know if there has been a resolution to this. I have seen similar behavior in which I have 2 A/D channels enabled and I can consistently get the samples to be swapped in the buffer. If I use a J-LINK all I have to do is set a breakpoint/halt the application and restart it and it will do this every time. I am not using FreeRTOS and I used the example that is provided on Github in which I made it so that the BLE portion is not initialized so that I can actually use a Breakpoint. I tested with AIN1(Channel0) and AIN0(Channel1) and connect AIN1 to a 3V source and AIN0 to GND and I can see the ordering get swapped either by using the LiveWatch or by simply printing out to a Segger RTT viewer...

    I am not clear on how to ensure that the Pointers for Channel0 and Channel1 are correctly aligned?

    Regards, SM

  • No solution, yet. I'll try to isolate the problem in my app and create a case about it.