Hi,
I am working on the ADC and trying to sense the battery level to measure it voltage.
And I have configure the ADC with normal conditions as present in example of SDK-10(S110).
I have connected my battery sense line followed by the Voltage dividing rules as mentioned in this page.
I am facing problem while taking reading from the ADC pin, it gives the constant value continuously, however if voltage goes it gives the same value.
I don't that ADC conversion is working or not.
Here I am sharing small portion of code for adc configuration kind reference. If I have gone wrong in something please correct me.
Output of ADC:
173 continuously without any changes(however voltages drops it shows the same).
My code for ADC
volatile int32_t adc_sample = 0; void ADC_IRQHandler(void) { nrf_adc_conversion_event_clean(); adc_sample = nrf_adc_result_get(); } void adc_config(void) { const nrf_adc_config_t nrf_adc_config = NRF_ADC_CONFIG_DEFAULT; // Initialize and configure ADC nrf_adc_configure( (nrf_adc_config_t *)&nrf_adc_config); nrf_adc_input_select(NRF_ADC_CONFIG_INPUT_1); // batt adc_sense pin at ch no. 1 nrf_adc_int_enable(ADC_INTENSET_END_Enabled << ADC_INTENSET_END_Pos); NVIC_SetPriority(ADC_IRQn, NRF_APP_PRIORITY_HIGH); NVIC_EnableIRQ(ADC_IRQn); } int main(void) { adc_config(); //Initialize ADC nrf_adc_start(); nrf_gpio_cfg_output(12); err_code = ble_advertising_start(BLE_ADV_MODE_FAST); APP_ERROR_CHECK(err_code); // Enter main loop. for (;;) { uint8_t str[4]; sprintf((char*)str, "%d", (int)adc_sample); ble_nus_string_send(&m_nus, str, strlen((char*)str)); nrf_gpio_pin_clear(12); power_manage(); } }
Looking forward for the possible guidance...
Thanks