Hello,
I was wondering whether or not the standard analog pins on the nrf52832 have to be defined as analog inputs with the gpio methods.
I ask this because I am trying to sample some of those pins (NRF_SAADC_INPUT_AIN4,P0.31 on pca10040 DK for instance) with the SAADC and I don't get the value that I would expect.
My init for the SAADC looks like this
#define SAADC_BUF_SIZE (2)
#define SAADC_CHANNELS (4)
#define SAADC_INITIAL_CHANNEL (4)
nrf_saadc_value_t bufferSAADC[SAADC_CHANNELS];
//Temperature sensor 4
temperatureReadings[0].adc_pin_no = NRF_SAADC_INPUT_AIN4; // SAADC channel 4
//Temperature sensor 3
temperatureReadings[1].adc_pin_no = NRF_SAADC_INPUT_AIN5; // SAADC channel 5
//Temperature sensor 2
temperatureReadings[2].adc_pin_no = NRF_SAADC_INPUT_AIN6; // SAADC channel 6
//Temperature sensor 1
temperatureReadings[3].adc_pin_no = NRF_SAADC_INPUT_AIN7; // SAADC channel 7
uint32_t saadc_start(temp_meas_param_t tempSensors[])
{
uint32_t err_code;
nrf_drv_saadc_config_t saadc_config = NRF_DRV_SAADC_DEFAULT_CONFIG;
err_code = nrf_drv_saadc_init(&saadc_config, saadc_handler_interrupt);
APP_ERROR_CHECK(err_code);
// we calibrate the SAADC before configuring it
err_code = saadc_calibrate(saadc_config);
APP_ERROR_CHECK(err_code);
for(uint8_t temperaruteChannel=SAADC_INITIAL_CHANNEL; temperaruteChannel< SAADC_INITIAL_CHANNEL + SAADC_CHANNELS; temperaruteChannel++)
{
nrf_saadc_channel_config_t channel_config = NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(tempSensors[temperaruteChannel].adc_pin_no);
channel_config.burst = NRF_SAADC_BURST_ENABLED;
channel_config.gain = SAADC_GAIN1_6;
// channel_config.acq_time = SAADC_CH_CONFIG_TACQ_10us;
err_code = nrf_drv_saadc_channel_init(temperaruteChannel, &channel_config);
APP_ERROR_CHECK(err_code);
}
err_code = nrf_drv_saadc_buffer_convert((nrf_saadc_value_t*)bufferSAADC, SAADC_BUF_SIZE);
APP_ERROR_CHECK(err_code);
saadc_is_initialized = true;
return M_TEMP_STATUS_CODE_SUCCESS;
}
I am using as input for the analog device one of the VDD pins and on of the GND pins of the pca10040DK.
Am I setting something wrong on for the SAADC?
thanks in advance