I have issue about calibartion using saadc.
I use 52832, S332, SDK 15.3.0
when calibration is excuting, ANT+ and BLE is also doing.
I use low power mode in saadc.
issue is first calibration is normal
but after that periodly do calibration (like one time for 30min) NRF_DRV_SAADC_EVT_CALIBRATEDONE event is not trigger.
I search about this one in nordic dev. I know PAN-86. but i can't find that. all link was broken..
second calibration process, nrf_log_info(saadc is wating) <- infinite loop in here.
under blow is my code.
And If don't calibrate periodly, how much error about temperature drift ? in doc, there is only gain error temperature coefficient (0.02%).
if I measure 25 degree, which temperature range is normal value in error?
Thank you.
void battery_config_value_init() { memset(&saadc_config, 0 , sizeof(saadc_config)); saadc_config.resolution = (nrf_saadc_resolution_t)NRFX_SAADC_CONFIG_RESOLUTION; // 10bit saadc_config.oversample = (nrf_saadc_oversample_t)NRFX_SAADC_CONFIG_OVERSAMPLE; // disable saadc_config.interrupt_priority = NRFX_SAADC_CONFIG_IRQ_PRIORITY; saadc_config.low_power_mode = NRFX_SAADC_CONFIG_LP_MODE; memset(&channel_config, 0 , sizeof(channel_config)); channel_config.resistor_p = NRF_SAADC_RESISTOR_DISABLED; channel_config.resistor_n = NRF_SAADC_RESISTOR_DISABLED; channel_config.gain = NRF_SAADC_GAIN1_6; channel_config.reference = NRF_SAADC_REFERENCE_INTERNAL; channel_config.acq_time = NRF_SAADC_ACQTIME_10US; channel_config.mode = NRF_SAADC_MODE_SINGLE_ENDED; channel_config.burst = NRF_SAADC_BURST_DISABLED; channel_config.pin_p = (nrf_saadc_input_t)(NRF_SAADC_INPUT_AIN0); channel_config.pin_n = NRF_SAADC_INPUT_DISABLED; }
static void user_battery_saadc_handler(nrf_drv_saadc_evt_t const * p_event) { nrf_saadc_value_t *value = p_event->data.done.p_buffer; // nrf_saadc_value_t = uint16_t switch(p_event->type) { case NRF_DRV_SAADC_EVT_CALIBRATEDONE : CaliState = false; break; case NRF_DRV_SAADC_EVT_DONE : Calculate_Voltage(value, &voltage); break; default: break; }
static void Calibration_init() { NRF_LOG_INFO("SAADC Calibration Start"); CaliState = true; nrf_drv_saadc_abort(); while(nrf_drv_saadc_is_busy()){}; while( nrf_drv_saadc_calibrate_offset() != NRF_SUCCESS ){ NRF_LOG_INFO("SAADC is offset"); NRF_LOG_PROCESS(); } while(CaliState){ NRF_LOG_INFO("SAADC is waiting"); NRF_LOG_PROCESS(); } }