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

Setting SAADC sampling interval with Easy-DMA in nRF52832

I am trying to change analog-to-digital (SAADC) sampling interval when sampling using Easy-DMA in nRF52832. The code looks like follows (error checks removed for clarity):

    void saadc_sampling_event_init(void)
      {
          nrf_drv_ppi_init();
          nrf_drv_timer_init(&m_timer, NULL, timer_handler);
          /* setup m_timer for compare event every X ms */
          uint32_t ticks = nrf_drv_timer_ms_to_ticks(&m_timer, ANALOGIN_SAMPLE_INTERVAL_ms);
          nrf_drv_timer_extended_compare(
            &m_timer, ANALOGIN_TIMER_CHANNEL, ticks,
            NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, true);
          nrf_drv_timer_enable(&m_timer);
          uint32_t timer_compare_event_addr =
            nrf_drv_timer_compare_event_address_get(&m_timer, ANALOGIN_TIMER_CHANNEL);
          uint32_t saadc_sample_event_addr = nrf_drv_saadc_sample_task_get();
          /* setup ppi channel so that timer compare event is triggering sample task in SAADC */
          nrf_drv_ppi_channel_alloc(&m_ppi_channel[0]);
          nrf_drv_ppi_channel_assign(m_ppi_channel[0],
            timer_compare_event_addr, saadc_sample_event_addr);
      }

However, it looks like no matter what I put into ANALOGIN_SAMPLE_INTERVAL_ms, the interval stays very high. E.g. trying 1000 ms doesn't give me a sample per second, but is much more faster (don't know how much). Any idea what could be wrong with the code? I am using nRF5_SDK version 11.

Related