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
  • Hi,

    Apologies for the delay.

    I'm not able to replicate the issue you are seeing, using the saadc sample in nRF5 SDK 17.1.0  with the modified saadc resolution.

    Have you made any other modifications to the sample?

     

    Best regards,

    Bendik

  • I'm sorry. When I tried it again here, the numbers turned out as expected, so I'm not sure what the cause was. If it happens again, please let me know at that time.

  • It appears that the reason the analog input values become incorrect is because AIN1 has 3.3V applied to it immediately upon startup.

    When there is no external circuit connected, AIN1 doesn't exhibit such behavior, and the values are as expected.

    However, with an external circuit connected, AIN1 receives 3.3V, and the values are not as expected.

    I'm not very knowledgeable about hardware, so I'm not sure whether the cause is a software configuration issue or a hardware problem.

    Is it possible for such a phenomenon to occur due to software settings?

    The peripheral circuits include:

    SPI using P0.20, P0.08,P0.05, P0.16
    GPIO using P0.17, P0.18, P0.14, P0.11, P0.15
    AIN1 and AIN2 using P0.03 and P0.04.

    Additionally, at the beginning of the main function:

    nrf_drv_gpiote_out_config_t out_config = GPIOTE_CONFIG_OUT_SIMPLE(false);
    err_code = nrf_drv_gpiote_out_init(3, &out_config);
    nrf_drv_gpiote_out_clear(3);
    nrf_drv_gpiote_out_set(3);
    

    I forcefully configured P0.3 as a digital output (DO). In a scenario where there are no peripheral circuits connected, it worked correctly, transitioning from 0V to 3.3V. However, when peripheral circuits were connected, even after clearing, it did not transition to 0V.

Reply
  • It appears that the reason the analog input values become incorrect is because AIN1 has 3.3V applied to it immediately upon startup.

    When there is no external circuit connected, AIN1 doesn't exhibit such behavior, and the values are as expected.

    However, with an external circuit connected, AIN1 receives 3.3V, and the values are not as expected.

    I'm not very knowledgeable about hardware, so I'm not sure whether the cause is a software configuration issue or a hardware problem.

    Is it possible for such a phenomenon to occur due to software settings?

    The peripheral circuits include:

    SPI using P0.20, P0.08,P0.05, P0.16
    GPIO using P0.17, P0.18, P0.14, P0.11, P0.15
    AIN1 and AIN2 using P0.03 and P0.04.

    Additionally, at the beginning of the main function:

    nrf_drv_gpiote_out_config_t out_config = GPIOTE_CONFIG_OUT_SIMPLE(false);
    err_code = nrf_drv_gpiote_out_init(3, &out_config);
    nrf_drv_gpiote_out_clear(3);
    nrf_drv_gpiote_out_set(3);
    

    I forcefully configured P0.3 as a digital output (DO). In a scenario where there are no peripheral circuits connected, it worked correctly, transitioning from 0V to 3.3V. However, when peripheral circuits were connected, even after clearing, it did not transition to 0V.

Children
Related