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

how to resign pins in saadc example

Hi 

I'm not familiar with C language, I tested the saadc example in SDK, it worked well in P0.02

But I dont see how they set CH[X].PSELP or CH[X].PSELN (V(p) and V(n)) in main.c

I dont know how to implement this code to work with other ADC pins.  

Please help me with it and correct me if I was wrong. 

I'm using nrf52 dk and segger embedded studio. 

Cindy

Parents
  • Hi Cindy

    These parameters can be found in the channel_config struct, which is used to initialize the ADC channel inside the saadc_init() function. 

    By default this function will just use the default settings, defined by the NRFX_SAADC_DEFAULT_CHANNEL_CONFIG_SE(PIN_P) macro, but you can override the various parameters after initializing the struct if you like. 

    As an example, to override the positive pin, you just run the following code: 

    channel_config.pin_p = NRF_SAADC_INPUT_AIN1;

    Then the full saadc_init() function would look like this:

    Best regards
    Torbjørn

Reply
  • Hi Cindy

    These parameters can be found in the channel_config struct, which is used to initialize the ADC channel inside the saadc_init() function. 

    By default this function will just use the default settings, defined by the NRFX_SAADC_DEFAULT_CHANNEL_CONFIG_SE(PIN_P) macro, but you can override the various parameters after initializing the struct if you like. 

    As an example, to override the positive pin, you just run the following code: 

    channel_config.pin_p = NRF_SAADC_INPUT_AIN1;

    Then the full saadc_init() function would look like this:

    Best regards
    Torbjørn

Children
Related