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

stop and restart SAADC to power saving

Hello, I'm using softdevice 6.0 and SDK 15.

In my application, I would like stop the SAADC at the disconnection and then restart SAADC at the connection to power saving.

To start SAADC I use this code:

void saadc_init(void)
{
    ret_code_t err_code;

    err_code = nrf_drv_saadc_init(NULL, saadc_callback);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_drv_saadc_channel_init(0, &channel_config_PRESSURE);
    APP_ERROR_CHECK(err_code);

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

 }

To launch a sampling I use the call:

nrf_drv_saadc_sample();

To stop the SAADC I use the call:

nrf_drv_saadc_uninit()

The problem is that after the stop the interrupt handler of SAADC no longer works.

The code for interrupt handler is the following:

void saadc_callback(nrf_drv_saadc_evt_t const * p_event)
{
  nrf_saadc_value_t adc_result;
  uint16_t pressure_mV_local;
  uint16_t pressure_mV_acc;
  int i;
  char debug_str[10] = {0};

    if (p_event->type == NRF_DRV_SAADC_EVT_DONE)
    {
        ret_code_t err_code;

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

        adc_result = p_event->data.done.p_buffer[0];

    }
}

What is the correct procedure to stop and then to restart the SAADC?

Thanks

 

Parents Reply Children
No Data
Related