This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Checking the ADC value range with SAADC

OS in development environment :Windows7
HARD :(Taiyo Yuden)EBSHSN Series Evaluation Board : Central / Peripherals
CPU :(Nordic) nRF52832 / ARMR Cortex-M4F 32 bit processor 28-pin Land Grid Array / 15GPIOs / SWD
Soft Ver:nRF5_SDK_15.2.0_9412b96
CPU Vcc=3V SAADC = 12bit

Even if 3V is converted to AD, it is about “0x0dac” and does not become “0X0FFF”.
Please tell me how to fix it.
Thank you.

Parents
  • Hi

    Could you send me the SAADC configuration parameters that you use when you initialize it?

    Depending on how you have configured the internal reference, which gain settings you are using etc, VDD might not correspond to 0xFFF. 

    Best regards
    Torbjørn

  • void saadc_init(void)
    {
    ret_code_t err_code;
    /*-< SAADC Register initial parameter >-*/
    nrf_drv_saadc_config_t saadc_config = NRF_DRV_SAADC_DEFAULT_CONFIG; /* SET to SAADC Data area or initial data */

    /*-< SAADC Channel Setting parameter >-*/
    nrf_saadc_channel_config_t channel0_config =
    NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN2); /* Channel 2 [Fingertip pulse wave] data */
    nrf_saadc_channel_config_t channel2_config =
    NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN0); /* Channel 0 [pulse wave] data */

    /*-< SAADC initial >-*/
    err_code = nrf_drv_saadc_init(&saadc_config, saadc_callback);
    APP_ERROR_CHECK(err_code);

    /*-<ADC offset calibration >-*/
    err_code = nrfx_saadc_calibrate_offset();
    APP_ERROR_CHECK(err_code);
    while(nrfx_saadc_is_busy()) // Wait for calibration to complete
    {
    __WFE(); //
    __SEV(); //
    __WFE(); // This sequence puts the system to sleep (SystemON) while waiting
    }

    /*-< SAADC Channel Setting >-*/
    err_code = nrf_drv_saadc_channel_init(0, &channel0_config); /*Channel 0 setting */
    APP_ERROR_CHECK(err_code);
    err_code = nrf_drv_saadc_channel_init(2, &channel2_config); /*Channel 2 setting */
    APP_ERROR_CHECK(err_code);

    /*-<SAADC double baffer Setting >-*/
    err_code = nrf_drv_saadc_buffer_convert(m_buffer_pool[0], SAADC_SAMPLES_IN_BUFFER); /* 1st buffer setting */
    APP_ERROR_CHECK(err_code);
    err_code = nrf_drv_saadc_buffer_convert(m_buffer_pool[1], SAADC_SAMPLES_IN_BUFFER); /* 2nd buffer setting */
    APP_ERROR_CHECK(err_code);
    }

  • Hi

    It appears you are mostly using default SAADC settings, which means you are using the internal 0.6V reference, and a gain setting of 1/6. 

    You can calculate the voltage of the measured signal like this: Voltage = ADC_reading / 2^12 * INT_REF / GAIN

    In your case this equals 3.003V, which seems pretty accurate if your voltage is supposed to be 3V.

    In other words I think the ADC is working as intended Slight smile

    If you want the ADC scale to be 0-0xFFF for 0-VDD then you shoult set the internal reference to VDD1_4 and the gain setting to GAIN1_4, as described in the product specification

    Best regards
    Torbjørn

Reply
  • Hi

    It appears you are mostly using default SAADC settings, which means you are using the internal 0.6V reference, and a gain setting of 1/6. 

    You can calculate the voltage of the measured signal like this: Voltage = ADC_reading / 2^12 * INT_REF / GAIN

    In your case this equals 3.003V, which seems pretty accurate if your voltage is supposed to be 3V.

    In other words I think the ADC is working as intended Slight smile

    If you want the ADC scale to be 0-0xFFF for 0-VDD then you shoult set the internal reference to VDD1_4 and the gain setting to GAIN1_4, as described in the product specification

    Best regards
    Torbjørn

Children
No Data
Related