Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

saadc blocking issue

I can run the SAADC example and read the analog inputs fine, now I've modified the code to simply read the adc with the blocking nrf_drv_saadc_sample_convert call

All I get back is 0's on the read....using the same input AIN1 in the example program with a callback works and shows values?

One thing I note, if I change the config to have a acquisition time of 3us it reads values...but anything higher (like the default 40us) it reads 0?

in Main I do these steps:

 nrf_saadc_channel_config_t cfg =  NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN1);

 nrf_drv_saadc_channel_init(NRF_SAADC_INPUT_AIN1,&cfg);

while(1)

{

 nrf_pwr_mgmt_run();

 retval = nrf_drv_saadc_sample_convert(NRF_SAADC_INPUT_AIN1,&myval);
 if (retval == NRF_SUCCESS)
{   
    NRF_LOG_INFO("TESTING ch1=%d ",myval);
}

NRF_LOG_FLUSH();

}

  • Hi,

     

    I tried to cut down the saadc example in the SDK to run as you've done, and it seems to work as intended at my end.

    My pin is floating, and therefore prints ADC values between 0 and 800, but when grounding or pulling the pin to VDD, I see ~0 (GND) and ~800 (VDD)

    Attached is my example program.

    Best regards,

    Håkon

  • Thank you, oddly, I paste your code in and it works....and bringing my code back also now works....yet I have changed no code....I think the problem must be between keyboard and screen :-)

    Thanks!