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

How to configure IO pin as analog input

Hi all,

I am having ADXL335 Acellarometer board. Here its giving data of X,Y and Z axis directly in analog form. So how should i configure my IO pins of PCA10001 board so i can read the data from Accelarometer board and print it over UART.

I try to search many reference for "How to configure IO pin of nrf51822 as Analog Input " but i am not getting any reference. Can anybody help me out in this...

  • For reference:

    So did you check out the ADC HAL Example which is /examples/peripheral/adc_simple in the SDK? Here's also an example of reading from two inputs 'simultaneously' (without nrf adc driver).

    In the SDK example, input is selected with:

    nrf_adc_input_select(NRF_ADC_CONFIG_INPUT_2);
    

    and that's about it. Triggering a conversion reads the analog value from the selected input pin.

    From the reference manual:

    Other peripherals in the system can attach themselves to GPIO pins and override their output value and configuration, or read their analog or digital input value ...

    With the nRF you don't need to explicitly configure the pins unless you wish to use them as digital GPIO. Just configure the ADC and your pin is good to go.

Related