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

nRF52 SAADC Sampling Rate w/ ESB

Hello,

I am currently trying to transmit around 800kbps of data using the Nordic ESB protocol. I am also attempting to sample 2 inputs using the SAADC at around 32 khz rate. My current settings for the SAADC are as follows:

ret_code_t err_code;

nrf_saadc_channel_config_t channel_0_config =
      NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN0);
channel_0_config.acq_time = NRF_SAADC_ACQTIME_3US;
channel_0_config.gain = NRF_SAADC_GAIN1_6;

nrf_saadc_channel_config_t channel_1_config =
			NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN2);
channel_1_config.acq_time = NRF_SAADC_ACQTIME_3US;
channel_1_config.gain = NRF_SAADC_GAIN1_6;

nrf_drv_saadc_config_t config_t = NRF_DRV_SAADC_DEFAULT_CONFIG;
config_t.resolution = NRF_SAADC_RESOLUTION_12BIT;

err_code = nrf_drv_saadc_init(&config_t, saadc_callback);
APP_ERROR_CHECK(err_code);

err_code = nrf_drv_saadc_channel_init(0, &channel_0_config);
APP_ERROR_CHECK(err_code);
err_code = nrf_drv_saadc_channel_init(1, &channel_1_config);
APP_ERROR_CHECK(err_code);

err_code = nrf_drv_saadc_buffer_convert(m_buffer_pool[0], SAMPLES_IN_BUFFER);
APP_ERROR_CHECK(err_code);

err_code = nrf_drv_saadc_buffer_convert(m_buffer_pool[1], SAMPLES_IN_BUFFER);
APP_ERROR_CHECK(err_code);

I am under the impression that the p_buffer in the following line of code will contain a two sample buffer where channel 0 sample is located p_buffer[0], and channel 1 sample is located p_buffer[1].

	err_code = nrf_drv_saadc_buffer_convert(p_event->data.done.p_buffer, SAMPLES_IN_BUFFER);

So my questions are these:

  • What sample rate can the SAADC handle when running the ESB at these rates?
  • What is the highest SAADC sample rate when running the ESB wide open?
  • How would I calculate the volts / LSB value using the GAIN and REFERENCE settings?
  • Is there any work around for using SCAN mode (SAADC) with OVERSAMPLING for multiple channels?
  • Is there an example of performing the SAADC CALIBRATION or do the drivers handle this at initialization?
  • Hi

    I think it is matter of trial and error to find out if the nRF52 can handle this high ESB transmit rate and this high sample rate. I think this is a matter of how much the nRF52 M4 CPU can process. The SAADC itself does not however put any strain on the CPU, as it can sample autonomously and transfer samples directly to RAM via EasyDMA, but at some point you would need the CPU to process the samples in RAM, transfer them via SPI, UART, BLE or something else, and that requires CPU time. I suspect anyway that if transmitting 800kbps with ESB works and you receive your data from serial interface, UART, SPI etc, then processing data from SAADC will not be more CPU demanding than processing data from any serial interface. The SAADC can handle up to 200k samples per second so it will not be a bottleneck.

    For your oversampling and calibration questions, I think the saadc_low_power example on Github has some documentation on this. Also, there are a lot of in-code documentation that could help understand the rules of oversampling, scan mode and calibration.

Related