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

ADC fastest channel sampling rate

I need to sample ADC channel at the fastest deterministic rate.

If i use burst mode with 3us acquisition time, do i get a sample exactly every 5us? 

does t(conv) is always 2us or does it vary?

should i use a timer instead of burst mode to get the rate predicted?

If yes - can i use timer that clocks every 5us when using t(acq)=3us? or can i go lower?

  • Hi,

    How long sample time you get with BURST enabled will depend on the configuration of OVERSAMPLE register. From the SAADC peripheral documentation:

    CH[n].CONFIG.BURST can be enabled to avoid setting SAMPLE task 2OVERSAMPLE times. With BURST = 1 the ADC will sample the input 2OVERSAMPLE times as fast as it can (actual timing: <(tACQ+tCONV)×2OVERSAMPLE). Thus, for the user it will just appear like the conversion took a bit longer time, but other than that, it is similar to one-shot mode. Scan mode can be combined with BURST=1, if burst is enabled on all channels.

    If OVERSAMPLE is not enabled, enabling BURST mode will have no effect. If OVERSAMPLE is enabled, the sample time will be <(tACQ+tCONV)×2OVERSAMPLE

    You would need a timer to trigger the SAMPLE task, regardeless of if BURTS mode is enabled or not. If you do OVERSAMPLE and BURST, you need to increase the triggering of SAMPLE task to the actual sample timing from above.

    tCONV is specified at typical <2µs, you cannot expect it to be lower than this, and it is without specs to sample more often.

    Best regards,
    Jørgen

  • Not sure i understood - i using oversampling=0 since i do not want oversampling at all.

    I just want to find a way to sample 1000 times the ADC channel as fast as i can and fill in a memory buffer with these 1000 samples (with sa,pling rate of 5us, 7us, or as fast as the nRF52 can do with EasyDMA).

    I only asked about BURST since i thought it can provide me a way to sample a channel faster than a timer would.

    Another question - you said t(conv) is typical 2us. Can it be greater than 2us? how big can it get?

    thanks for the fast response 

  • Like I said, BURST will only work with OVERSAMPLE, and you will only get out the averaged sample in the buffer, not every sample.

    You need to setup a timer to trigger sample every 5 µs, this is the fastest way to sample the channel 1000 times.

    Typical <2 µs is what the specification say. I have never seen or heard about higher values. You should be fine with 5 µs sample interval.

    Best regards,
    Jørgen

  • I am using 3us SAADC sampling rate with double buffer EasyDMA.

    The SAADC driver calls me back when one buffer is filled up by the EasyDMA.

    Is it possible that during the software interrupt, when i need to call nrf_drv_saadc_buffer_convert to switch buffers, that 1 or 2 samples shall be missed?

    In other words - is it a real HW double buffer where the EasyDMA automatic sampling into memory continuous while i am inside the interrupt? 

    I saw that RESULT.MAXCNT and RESULT.PTR are updated within the software interrupt, so this made me think about a possible race conditions....

  • This is described in the SAADC peripheral documentation:

    The RESULT.PTR register is double-buffered and it can be updated and prepared for the next START task immediately after the STARTED event is generated.

    In the SAADC driver, the first buffer will be set when you call nrfx_saadc_buffer_convert. Then you call nrfx_saadc_buffer_convert the second time, the buffer will be stored in the second buffer pointer. The second buffer is set in the IRQ handler when a END event is received (NRF_SAADC_EVENT_END). The START task will be triggered when the new buffer is set, to prepare it for next event. If you need to set the new buffer before the END event is received (for instance when STARTED event is received), you need to modify the driver or setup SAADC using registers directly. This is typically not an issue in the driver as you will trigger the START task from the same interrupt where you set the second buffer. Note that some users have seen buffer-swap issues when sampling multiple channels and triggering SAMPLE task through PPI.

Related