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.

  • I'm following this thread as I too encounter this behavior. I'm NOT using FreeRTOS, SDK 12.1.0, three channels in scan mode at 8 KSPS, with double-buffering. The buffer sizes are a multiple of 6 so there shouldn't be any boundary issues. For me, the issue of channel order switching occurs during normal operation. This means that the system is working and I witness the switch of the channels in real time.

  • @Jørgen: I created a case in MyPage with a code example that has quite much overhead stripped away.

  • Hello I have not seen a resolution to this situation? I have a case where I can get this to occur every single time...

    1. Clear Bonding info -> Reset nRF52
    2. Connect using Master Control Panel ADC is running and providing samples in correct order... p_event->data.done.p_buffer[0] = My Signal Voltage p_event->data.done.p_buffer[1] = My battery voltage
    3. Bond to device
    4. Discover Services
    5. Enable Services -> BANG the samples get swapped in the ADC.... p_event->data.done.p_buffer[0] = My battery voltage p_event->data.done.p_buffer[1] = My signal voltage

    We are trying to release this product next week and this is a major killer...I will be sending my project into a support case and it will be configured to work on the nRF52 DK...

  • As far as I know, there's no resolution, yet. I changed my implementation so that I'm sampling the channels one by one using ppi and counters. Now the samples stay in the correct order, but somehow turning on bluetooth manages to screw up the DC levels. Hoping to get some info soon. I have not foung a bullet proof solution/workaround, yet.

  • I had the same issue when sampling two pins at 1kHz with BURST enabled, Oversample set to 4x and BLE enabled. It seems I managed to fix it by setting the SAADC_CONFIG_IRQ_PRIORITY to 2 (it was 7 before). I also reduced the acquisition time from 40us to 20us but I am quite sure that the change that made the difference is the priority. I let the device run over night at 1kHz sampling rate with burst and oversample at 4x, I also connected/disconnected to the device several times and the channels did not get switched at all. I am using the SDK 12.2.0. Maybe you can try this and see if it works for you as well. I will be doing more testing these days.