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

SAADC in blocking mode without activating the DMA

Hi,

I need to use the SAADC to check battery status (infrequently).

I would like to do this in blocking mode without accidently leaving the easyDMA powered-on unnecessarily.

It seems that "nrf_drv_saadc_sample_convert" is the function to use. It further seems that it requires also "nrf_drv_saadc_channel_init".

1) Is this right?

2) Do I need further using "nrf_drv_saadc_init"?

3) Do I need to use an "uninit" function?

Thanks,
Daniel
  • Hi Daniel,

    I do not fully understand the reasoning for wanting to use blocking mode. The SAADC does not have any other way of transferring samples to memory than DMA, so this is still used for the blocking API. The only difference is that the driver will busy wait (keeping the CPU active and waysting power and/or preventing the CPU from doing other useful stuff) instead of sleeping. I do not see any practical benefit of this in an end application, though it can be slightly simpler for fast experimentation or similar.

    For the specific questions:

    1) Yes, the nrf_drv_saadc_sample_convert() is a blocking function call that will return when there is a valid sample. You must always configure the channel first with nrf_drv_saadc_sample_convert(), which is where you configure most parameters (gain, acquisition time etc.).

    2) You must call nrf_drv_saadc_init() once before you can call any other nrf_drv_saadc_* functions (and again if you have previously called nrfx_saadc_uninit()).

    3) Yes, you should call nrf_drv_saadc_uninit() when you are done to disable the SAADC peripheral so that it does not draw any current or request any other resources (such as the high frequency clock).

    Einar

  • Einar thanks! I fully understand your argument and will implement accordingly, 

    Daniel

Related