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

Buffer order swap of SAADC used with NRF Mesh

Hello,

I am using NRF52840 with SDK 16.0.0 and Mesh SDK 4.1.0

.I am trying to use SAADC with BLE Mesh(SDK 4.1.0). I used default example of SAADC with multiple channel available in SDK(16.0.0)

Example path: nRF5_SDK_16.0.0_98a08e2\examples\peripheral\saadc

I used 5 Analog input channels and configured it and work perfectly, means gets samples and data buffer order is in sequence, no swapping.

When I used this code with Mesh code, and change SAADC interrupt priority to 3, then It seems to work (no SAADC buffer data swapping). But after 4-5 hours, SAADC gets issue of SAADC data buffer sequence swapped. I read mostly available solution for it. but I think this example implemented these solution already, like use of PPI.

Please help us to solve this problem of SAADC data buffer  order swapping.   

Thank You

Bivay





  • Hi,

    If you are referring to this solution with connecting END event to START task using PPI, this is not used in any SDK examples as far as I know.

    The SDK SAADC example uses PPI to trigger the SAMPLE task, but this is what's causing the issue in the first place. You need to setup an additional PPI channel to trigger the START task on END event. Something like this should work:

    nrf_ppi_channel_t saadc_buffer_swap_ppi_channel;
    nrf_drv_ppi_channel_alloc(&saadc_buffer_swap_ppi_channel);
    nrf_drv_ppi_channel_assign(saadc_buffer_swap_ppi_channel,
                               (uint32_t)&NRF_SAADC->EVENTS_END,
                               (uint32_t)&NRF_SAADC->TASKS_START);
    nrf_drv_ppi_channel_enable(saadc_buffer_swap_ppi_channel);

    When adding this to the application, you may also need to remove the triggering of the START task in the interrupt handler (nrfx_saadc.c:128 in SDK 16.0.0). 

    Best regards,
    Jørgen

  • Thanks Your this solution, I have a doubt about this that I only have to change on nrfx_saadc.c to comment the  line 128 ,

    nrf_saadc_task_trigger(NRF_SAADC_TASK_START);

    and add above solution in my application code.

    Thank you

  • I have tried your solution, initially works well, but after few hours buffer get swapped.

    I have tested with below conditions:

    1) Used SAADC example of SDK with 1ms Interval of 5 adc, and sample buffer of 5

    2) Used SAADC example of SDK with 1ms Interval of 5 adc, and sample buffer of 100

    3) Added Brust On and oversampling to 4x with 1ms Interval of 5 adc, and sample buffer of 100

    4) Your Solution Of START_EVENT with PPI (added on 3rd condition) with 1ms Interval of 5 adc, and sample buffer of 100

    In all cases buffer get swapped after 5-6 hours of average.

    Please help me to solve this issue.

  • Can you post your project for a review and for me to reproduce the issue? There should not be any way (at least that I'm aware of) for a buffer swap to happen if this workaround is used, but it could be something else in your application that causes this.

  • Sorry for late response, We are testing your solution again, and we found that node SAADC buffer not swapped since 2 days, may this work, we are observing this and let  you know result.

Related