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

Read one sample from ADC without timers.

I'm having trouble reading value from ADC. What I want is to read a sample and not set any timer, since I want to run it inside a timer itself and have the refreshed value. I want to read a sample and not fill a buffer because I need a value without being too precise, and that doesn't raise the consumption too much or take too long so that most of the time it can be in low consumption. I have been trying to run sample code mixing what I have found around here as what comes in the saadc example on SDKs

The example I am referring to specifically of not using timers is found here:

devzone.nordicsemi.com/.../simplest-way-to-read-an-adc-input

Best regards

Parents
  • Hi,

    The thread you linked is for the ADC in nRF51 series. It differs quite a bit from the SAADC in nRF52 series.

    I have created a minimal blocking SAADC example in SDK 16.0.0 that you can use for reference:

    saadc_simple_blocking_sdk_16.0.0.zip

    Note that the SAADC will always work in an event-driven way. The difference with blocking mode is that the function will busy loop inside the function until the sampling is done.

    Best regards,
    Jørgen

  • Okay thanks, I'm trying to adapt to my code and see if works. I'm tryimg to understand your example and my biggest doubt is about "saadc_callback". Could you explain what purpose that function has?

    As a complementary question, I want to use ADC throught P0.28(supposed to be Analog Input 4).. How result the code? I tried changing 

    nrf_saadc_channel_config_t channel_config = NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN0);

    to

    nrf_saadc_channel_config_t channel_config =
    NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN4);

    but not work.

    Thank you, best regards

Reply
  • Okay thanks, I'm trying to adapt to my code and see if works. I'm tryimg to understand your example and my biggest doubt is about "saadc_callback". Could you explain what purpose that function has?

    As a complementary question, I want to use ADC throught P0.28(supposed to be Analog Input 4).. How result the code? I tried changing 

    nrf_saadc_channel_config_t channel_config = NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN0);

    to

    nrf_saadc_channel_config_t channel_config =
    NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN4);

    but not work.

    Thank you, best regards

Children
No Data
Related