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

How can I use NRF_SAADC_INPUT_AIN7 ?

Hello.

When I use NRF_SAADC_INPUT_AIN7 in SAADC, I get an error in calling nrf_drv_saadc_channel_init().
Looking at nrfx_saadc_channel_init() in nrfx_saadc.c, it seems to be rejected by the following ASSERT.

NRFX_ASSERT(channel < NRF_SAADC_CHANNEL_COUNT);

"channel" specifies NRF_SAADC_INPUT_AIN7, which is 8.
And NRF_SAADC_CHANNEL_COUNT is defined to be 8 in nrf_saadc.h.

How can I use AIN7?

Parents
  • Hello,

    I get an error in calling nrf_drv_saadc_channel_init().
    Looking at nrfx_saadc_channel_init() in nrfx_saadc.c, it seems to be rejected by the following ASSERT.
    "channel" specifies NRF_SAADC_INPUT_AIN7, which is 8.

    I think you might have mixed up channels and inputs of the SAADC. The Assert here triggers if you pass a channel number higher than existing channels(memory allocations in the SAADC peripheral) to be initialized. There are 8 channels in total, numbered 0-7, like the inputs, but they are not directly related to the input with the same number.
    That is, you can have any channel sample from any of the valid sources (AIN0-AIN7, VDD). The channel is just the block of registers containing the configuration for this particular sampling channel. One of these configurations indicate which input the channel should sample from - PSELP(if using single-ended sampling).

    How can I use AIN7?

    First, create a channel configuration with analog input 7(AIN7) as PSELP. Then, initialize any of the channels( 0-7 ) with this configuration.
    Try this, and let me know if it resolves your issue.

    Please do not hesitate to let me know if any part of this is still unclear, or if you encounter any other issues or questions!

    Best regards,
    Karl

  • Thanks for the comment.

    I see, I was mistaken.
    I'll give it a try.

    Thank you for your help.

  • sc.staka said:
    I see, I was mistaken.
    sc.staka said:
    Thanks for the comment.
    sc.staka said:
    Thank you for your help.

    No problem at all, I am happy to help!

    Please do not hesitate to open a new ticket if you encounter any other issues or questions in the future.

    Good luck with your development!

    Best regards,
    Karl 

Reply Children
No Data
Related