SDK version: nRF5_SDK_15.0.0_a53641a
Softdevice version: s132_nrf52_6.0.0_softdevice
PDK: PCA10040
I am trying to read the ADC pin value using the SAADC module, I have softdevice enabled and running. I am adding the section of code for your reference. I find that the value being read seems to be random. For example, if I apply a signal on the pin, the value still remains the same, with or without the signal. Similary if I apply ground to the pin, still no change. I think that the pin is actually not being sampled. Any help to resolve this appreciated. Also I find the saadc_callback function is never triggered.
void sensor_mngr_init()
{
uint32_t err_code;
nrf_saadc_channel_config_t channel_config = NRFX_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN0);
err_code = nrf_drv_saadc_init(NULL, saadc_callback);
APP_ERROR_CHECK(err_code);
channel_config.gain = NRF_SAADC_GAIN1_2;
err_code = nrf_drv_saadc_channel_init(0, &channel_config);
APP_ERROR_CHECK(err_code);
}
void get_sensor_data(sensor_data_struct *p_sensor_data)
{
nrf_saadc_value_t analog_value;
nrfx_err_t err_code;
err_code = nrfx_saadc_sample_convert(0,&analog_value);
}
sdk_config:
#ifndef SAADC_ENABLED
#define SAADC_ENABLED 1
#endif
#ifndef NRFX_SAADC_ENABLED
#define NRFX_SAADC_ENABLED 1
#endif
#ifndef NRFX_SAADC_CONFIG_RESOLUTION
#define NRFX_SAADC_CONFIG_RESOLUTION 1
#endif
#ifndef NRFX_SAADC_CONFIG_OVERSAMPLE
#define NRFX_SAADC_CONFIG_OVERSAMPLE 0
#endif
#ifndef NRFX_SAADC_CONFIG_LP_MODE
#define NRFX_SAADC_CONFIG_LP_MODE 0
#endif
#ifndef NRFX_SAADC_CONFIG_IRQ_PRIORITY
#define NRFX_SAADC_CONFIG_IRQ_PRIORITY 7
#endif
#ifndef NRFX_SAADC_CONFIG_LOG_ENABLED
#define NRFX_SAADC_CONFIG_LOG_ENABLED 0
#endif
#ifndef NRFX_SAADC_CONFIG_LOG_LEVEL
#define NRFX_SAADC_CONFIG_LOG_LEVEL 3
#endif
#ifndef NRFX_SAADC_CONFIG_INFO_COLOR
#define NRFX_SAADC_CONFIG_INFO_COLOR 0
#endif
#ifndef NRFX_SAADC_CONFIG_DEBUG_COLOR
#define NRFX_SAADC_CONFIG_DEBUG_COLOR 0
#endif