Hi,
I would like to read and update value of the characteristic received from AD pin AIN0. I already tested the following code, where I got very weird results (value is approximately 0x01EE all the time). The code was tested on PCA10005 board. I used AIN0 (NRF_ADC_CONFIG_INPUT_0) channel for data acquisition. Is it possible that defined NRF_ADC_CONFIG_INPUT_0 does not correspond with AIN0 pin on the PCA10005 board?
Many thanks for your help in advance.
static void adc_configure(void)
{
ret_code_t err_code = nrf_drv_adc_init(NULL, adc_event_handler);
APP_ERROR_CHECK(err_code);
//channel.config.config.input = NRF_ADC_CONFIG_SCALING_SUPPLY_ONE_THIRD;
static nrf_drv_adc_channel_t adc_1 = NRF_DRV_ADC_DEFAULT_CHANNEL(NRF_ADC_CONFIG_INPUT_0);
adc_1.config.config.input = (uint32_t)NRF_ADC_CONFIG_SCALING_INPUT_FULL_SCALE ;
nrf_drv_adc_channel_enable(&adc_1);
err_code = nrf_drv_adc_buffer_convert(&adc_1_buf,1);
APP_ERROR_CHECK(err_code);
}
static void adc_timer_handler(void * p_context)
{
nrf_drv_adc_sample();
}
void adc_event_handler(nrf_drv_adc_evt_t const * p_event)
{
if(p_event->type == NRF_DRV_ADC_EVT_DONE)
{
nrf_adc_value_t adc_result;
uint32_t err_code;
adc_result = p_event->data.done.p_buffer[0];
err_code = nrf_drv_adc_buffer_convert(p_event->data.done.p_buffer,1);
err_code = ble_adcs_1_update(&m_adcs,adc_result);
}
}