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;
adc_sample = nrf_adc_result_get();
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);
adc_config(); //Initialize ADC
err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
// Enter main loop.
sprintf((char*)str, "%d", (int)adc_sample);
ble_nus_string_send(&m_nus, str, strlen((char*)str));
Looking forward for the possible guidance...
Hi, maybe you have used the wrong pin? have you tried to check other analog inputs etc? Does the example in the SDK without softdevice work as-is?\nRF51_SDK_10.0.0_dc26b5e (1)\examples\peripheral\adc_simple\pca10028\arm5_no_packs
It has been resolved ... I have just added some delay in between the successive samples ...
Thanks for the reply .... Kenneth