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

Problem stopping ADC and restart again

Hello,

I am trying to get a low consumption and I detect that the activation of the ADC increases the consumption.
So I am trying to configure the ADC and when I make the conversion I try to desactivate it completly.

I desactivate the ADC using this functions:

nrf_drv_saadc_uninit();
NVIC_ClearPendingIRQ(SAADC_IRQn);

I detect in my code that I can not desactivate the ADC as quickly as I want.
I can not desactivate it as soon as I have the last read adc conversion. i have to delay about 5 ms to apply this functions.

I would like to know why I need this delay to execute this functions.
If not I do this delay then I can not restart the ADC again .

Parents
  • Hi,

    You should not need any delay before uninitializing the SAADC. What is the issue when you do not add the delay? 

    Where are you calling the uninit function? Please post some code showing what you are trying to do, and how you have configured the SAADC.

    Which SDK version are you using?

    Best regards,
    Jørgen

  • Hello Jørgen,

    If I don't do the delay then I can no restart the ADC.

    #define NRF_DRV_SAADC_LULABYTES_CHANNEL_CONFIG_SE(PIN_P) \
    {                                                      \
        .resistor_p = NRF_SAADC_RESISTOR_DISABLED,         \
        .resistor_n = NRF_SAADC_RESISTOR_DISABLED,         \
        .gain       = NRF_SAADC_GAIN1_4,                   \
        .reference  = NRF_SAADC_REFERENCE_INTERNAL,        \
        .acq_time   = NRF_SAADC_ACQTIME_10US,              \
        .mode       = NRF_SAADC_MODE_SINGLE_ENDED,         \
        .pin_p      = (nrf_saadc_input_t)(PIN_P),          \
        .pin_n      = NRF_SAADC_INPUT_DISABLED             \
    }

    void saadc_init(void){
            ret_code_t err_code;
        
            //
            adc_stat = 0x00;
            nrf_saadc_channel_config_t channel_config = NRF_DRV_SAADC_LULABYTES_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN4);            // NEW VERSION
        
        err_code = nrf_drv_saadc_init(NULL, saadc_callback);
        APP_ERROR_CHECK(err_code);

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

        err_code = nrf_drv_saadc_buffer_convert(m_buffer, SAMPLES_IN_BUFFER);
        APP_ERROR_CHECK(err_code);
        
    }

    Best regards,

    Juan

Reply
  • Hello Jørgen,

    If I don't do the delay then I can no restart the ADC.

    #define NRF_DRV_SAADC_LULABYTES_CHANNEL_CONFIG_SE(PIN_P) \
    {                                                      \
        .resistor_p = NRF_SAADC_RESISTOR_DISABLED,         \
        .resistor_n = NRF_SAADC_RESISTOR_DISABLED,         \
        .gain       = NRF_SAADC_GAIN1_4,                   \
        .reference  = NRF_SAADC_REFERENCE_INTERNAL,        \
        .acq_time   = NRF_SAADC_ACQTIME_10US,              \
        .mode       = NRF_SAADC_MODE_SINGLE_ENDED,         \
        .pin_p      = (nrf_saadc_input_t)(PIN_P),          \
        .pin_n      = NRF_SAADC_INPUT_DISABLED             \
    }

    void saadc_init(void){
            ret_code_t err_code;
        
            //
            adc_stat = 0x00;
            nrf_saadc_channel_config_t channel_config = NRF_DRV_SAADC_LULABYTES_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN4);            // NEW VERSION
        
        err_code = nrf_drv_saadc_init(NULL, saadc_callback);
        APP_ERROR_CHECK(err_code);

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

        err_code = nrf_drv_saadc_buffer_convert(m_buffer, SAMPLES_IN_BUFFER);
        APP_ERROR_CHECK(err_code);
        
    }

    Best regards,

    Juan

Children
No Data
Related