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

Selective sampling of ADC channels at run time

I am using a 52810 custom board and the SAADC module.

It is used for sampling one analog input through AIN2 and the battery voltage directly by setting the pin to VDD

As per the documentation, since more than one channel is configured/enabled, it goes into scan mode.

i need to measure the analog input at AIN2 for 15 seconds.

However, i do not need to measure the battery voltage in every scan. I only want to measure it once every 5 seconds to check for voltage drop.

Is this possible ?

Regards

Chary BS

Parents
  • Hello Einar,

    I see that this ticket is still not closed from your side. Luckily, I had another query about the SAADC usage

    Continuing in the same thread, i wanted to ask how to do the following, in terms of initializing and un-initializing the ADC and its channels

    In my system, as mentioned earlier, i have to capture the signal at AIN2 and the battery voltage, but not simultaneously.

    So can I do nrfx_saadc_channel_init() and nrfx_saadc_channel_uninit() as and when required ? Will there be any resource fragmentation issues with that ?

    Do i have to check for ADC busy or idle state before calling uninit or is it taken care internally?

    Thanks in advance

    Chary BS

  • Hi Chary,

    There are no problems initing and uniniting. But you are right you should take care to wait for an ongoing operation to finish before uninitializing as the driver do not handle

    There should not be any resource fragmentation issues. However, if you uninit and re-init then you may se some issues which are solved by the new driver API, nrfx_saadc_v2, as it is more robust. So you may want to start using that. In that case you can refer to the nrfx_saadc_v2.h file for the API, and define NRFX_SAADC_API_V2 for the project. You can refer to the migration document which links to some official examples and this unofficial example demonstrating regular sampling of multiple channels if you want to consider using the V2 implementation.

    Einar

Reply
  • Hi Chary,

    There are no problems initing and uniniting. But you are right you should take care to wait for an ongoing operation to finish before uninitializing as the driver do not handle

    There should not be any resource fragmentation issues. However, if you uninit and re-init then you may se some issues which are solved by the new driver API, nrfx_saadc_v2, as it is more robust. So you may want to start using that. In that case you can refer to the nrfx_saadc_v2.h file for the API, and define NRFX_SAADC_API_V2 for the project. You can refer to the migration document which links to some official examples and this unofficial example demonstrating regular sampling of multiple channels if you want to consider using the V2 implementation.

    Einar

Children
No Data
Related