Regarding the Value Obtained from the ADC

conducted an ADC experiment using the nRF5 DK (PCA10056).

The power supply for the nRF5 was provided via USB.

Based on the SAADC sample, I coded the following:

[main.c]
  void saadc_init(void)
  {
         :
      nrf_saadc_channel_config_t channel_config =
          NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN1);
+     channel_config.gain = NRF_SAADC_GAIN1_6;

      err_code = nrf_drv_saadc_init(NULL, saadc_callback);
                     :
  }

[sdk_config.h]
  // <o> NRFX_SAADC_CONFIG_RESOLUTION  - Resolution
  // <0=> 8 bit 
  // <1=> 10 bit 
  // <2=> 12 bit 
  // <3=> 14 bit 
  #ifndef NRFX_SAADC_CONFIG_RESOLUTION
- #define NRFX_SAADC_CONFIG_RESOLUTION 1
+ #define NRFX_SAADC_CONFIG_RESOLUTION 2
  #endif

While running, I checked the value of "channel_config," and it was as follows.

channel_config
  .resistor_p : NRF_SAADC_RESISTOR_DISA3LED ( 0 )
  .resistor_n : NRF_SAADC_RESISTOR_DISA3LED ( 0 )
  .gain       : NRF_SAADC_GAIN1_6 ( 0 )
  .reference  : NRF_SAADC_REFEREUCE_INTERNAL ( 0 )
  .acq_time   : NRF_SAADC_ACQTIME_10US ( 2 )
  .mode       : NRF_SAADC_MODE_SINGLE_ENDED ( 0 )
  .burst      : NRF_SAADC_BURST_DESABLED ( 0 )
  .pin_p      : NRF_SAADC_INPUT_AIN1 ( 2 )
  .pin_n      : NRF_SAADC_INPUT_DISABLED ( 0 )

I applied 3.0V to P0.03 and checked the value at the following line (the line marked with "!").

  void saadc_callback(nrf_drv_saadc_evt_t const * p_event)
  {
      if (p_event->type == NRF_DRV_SAADC_EVT_DONE)
      {
                :
          err_code = nrf_drv_saadc_buffer_convert(p_event->data.done.p_buffer, SAMPLES_IN_BUFFER);
!         APP_ERROR_CHECK(err_code);
                :
      }
  }

The expected value was:

3413.3333 = ((3.0 - 0.0)*(1/6))/0.6 * 2^12

However, the actual value was 860.

I verified the value with a tester and confirmed that 3.0V was properly applied.

Why is there such a discrepancy?

I haven’t performed calibration, but I don't think that would result in a 4x difference.

I believe there is a misunderstanding somewhere, but what could it be?

Related