This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Battery issue on custom board.

I am using the SAADC on a NRF52 to read the battery voltage.

Everthing works fine on the NRF52 DK board but on my custom board I get around the half of the real voltage.

From my understanding the only hardware difference from a chip only and the DK board is the diode that should be considered when computing the voltage.

I am using this snippet to initialize SAADC

   ret_code_t err_code = nrf_drv_saadc_init(NULL, saadc_event_handler);
    APP_ERROR_CHECK(err_code);

    nrf_saadc_channel_config_t config = NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_VDD);
    err_code = nrf_drv_saadc_channel_init(0, &config);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_drv_saadc_buffer_convert(&adc_buf[0], 1);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_drv_saadc_buffer_convert(&adc_buf[1], 1);
    APP_ERROR_CHECK(err_code);

this code to start the conversion

uint32_t err_code;
err_code = nrf_drv_saadc_sample();
APP_ERROR_CHECK(err_code);

and this is the callback

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

batt_lvl_in_milli_volts = ADC_RESULT_IN_MILLI_VOLTS(adc_result) + DIODE_FWD_VOLT_DROP_MILLIVOLTS;

where the macros to covert to millivolts are the following:

#define ADC_RES_10BIT                     1024  
#define ADC_REF_VOLTAGE_IN_MILLIVOLTS     600
#define ADC_PRE_SCALING_COMPENSATION      6
#define ADC_RESULT_IN_MILLI_VOLTS(ADC_VALUE)\
        ((((ADC_VALUE) * ADC_REF_VOLTAGE_IN_MILLIVOLTS) / ADC_RES_10BIT) * ADC_PRE_SCALING_COMPENSATION)

On the DK board I am getting 800 on the adc_results while on my board that value is around 400.

Any idea on what could be wrong ?

Thanks Marco

Related