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

SAADC channel input select/nRF52832/

The function nrf_drv_saadc_channel_init() in nrf_drv_saadc.c does channel initialization by calling function nrf_saadc_channel_init() which will set PSELN and PSELP of the respective channel. However after the returning from the function, the function nrf_drv_saadc_channel_init() again will reinitialize the PSELN and PSELP to NRF_SAADC_INPUT_DISABLED. Why?

It makes sense to disable first and then configure by calling nrf_saadc_channel_init() which initializes to the right value.

Appreciate the response.

Parents
  • This seems related PAN 28 infocenter.nordicsemi.com/.../anomaly_832_28.html

    Looking at the code it looks like they are disabling the input and scanning each line by enabling each channel individually to emulate a scan mode in the interrupt handler SAADC_IRQHandler.

    This will go away when the PAN is fixed.

  • What if an application has to use AIN0 as an ONE and ONLY analog input pin and configure it to run in continuous mode and not the scan mode ?

    With the SAADC driver function nrf_drv_saadc_channel_init(

    uint8_t channel, nrf_saadc_channel_config_t const * const p_config), if one has to configure the channel 0 with default configuration, the above said function despite initializing the SAADC with the user provided input, will eventually disable the AIN0 by setting its PSELP as NC (not connected).

    So all the above configuration which the driver function nrf_drv_saadc_channel_init() does becomes futile. The fix is to call nrf_saadc_channel_input_set(channel, NRF_SAADC_INPUT_DISABLED, NRF_SAADC_INPUT_DISABLED) before nrf_saadc_channel_init(channel, p_config) unless there is a genuine reason for doing so to have a work around for the Errata.

    The example provided in nRF52832 might work, since it is sampling Vdd pin.

    I will check to see if the driver function works correctly with no modification after having access to DK/EK. If it doesn't i will seek further directions.

Reply
  • What if an application has to use AIN0 as an ONE and ONLY analog input pin and configure it to run in continuous mode and not the scan mode ?

    With the SAADC driver function nrf_drv_saadc_channel_init(

    uint8_t channel, nrf_saadc_channel_config_t const * const p_config), if one has to configure the channel 0 with default configuration, the above said function despite initializing the SAADC with the user provided input, will eventually disable the AIN0 by setting its PSELP as NC (not connected).

    So all the above configuration which the driver function nrf_drv_saadc_channel_init() does becomes futile. The fix is to call nrf_saadc_channel_input_set(channel, NRF_SAADC_INPUT_DISABLED, NRF_SAADC_INPUT_DISABLED) before nrf_saadc_channel_init(channel, p_config) unless there is a genuine reason for doing so to have a work around for the Errata.

    The example provided in nRF52832 might work, since it is sampling Vdd pin.

    I will check to see if the driver function works correctly with no modification after having access to DK/EK. If it doesn't i will seek further directions.

Children
No Data
Related