The results of nRF52840 ADC conversion are not as expected

I'm using PCA10040 for studying nRF SDK, and I tried running the sample 'saadc_pc10040' with the following change in the 'config.h':

#define NRFX_SAADC_CONFIG_RESOLUTION 2

I connected the board to my PC via USB and applied an external power source with the negative terminal connected to GND and +0.6V to P0.02.

At this point, I expected the ADC value (p_event->data.done.p_buffer) to be calculated as follows:

RESULT = [V(P) – V(N)] * GAIN/REFERENCE * 2^(RESOLUTION - m)

 

Where:

  • V(P) is the voltage at input P
  • V(N) is the voltage at input N
  • GAIN is the selected gain setting
  • REFERENCE is the selected reference voltage
  • m = 0 if CONFIG.MODE=SE, or m = 1 if CONFIG.MODE=Diff.

In this case:

  • V(P) = 0.6
  • V(N) = 0.0
  • GAIN = 1/6
  • REFERENCE = 0.6
  • m = 0

So, I expected to get the result as:

[0.6 – 0.0] * (1/6)/0.6 * 2^(12 - 0) = 682

However, in reality, I got 62000.

Can you please explain why this is happening?

 

Parents Reply
  • Symptoms occur in 2 out of 4 units.

    Initially, during development, I recall that the issue was not present, but there is no recorded evidence, and my memory is the only basis, so it's not definitive.

    When running the exact same program on different boards, the problem appears inconsistently for each board.

    In the test program (an adaptation of the saadc_pca10056 sample to work with KAGA's board), it seems that calibration is not performed at all.

    Just to be sure, I placed a breakpoint in the following line in nrfx_sadc.c:

        nrf_saadc_int_disable(NRF_SAADC_INT_END | NRF_SAADC_INT_CALIBRATEDONE);
    =>  if (m_cb.adc_state == NRF_SAADC_STATE_CALIBRATION)
        {
            :
    

    But when I broke into it, the condition (m_cb.adc_state == NRF_SAADC_STATE_CALIBRATION) did not hold.

Children
  • Can you post your current application code and configuration?

    The SAADC sample in nRF5 SDK does not use offset calibration by default.

    The results from the SAADC is given as 2's complement 16-bit values (corresponding to int16_t type). int16_t have a range between [-32768, +32767]. If you see values in the 62000 range, your data type is incorrect.

    You should not enable any other peripherals (e.g., GPIOTE) on the same pins used for SAADC input.

Related