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

How to read three adc pin ?

Hello everyone,

I use SDK14.2 and s132 softdevice. I can read "NRF_SAADC_INPUT_AIN0" and "NRF_SAADC_INPUT_VDD" pins and system is working properly. 

Working Code like this;

Now I want to add new ADC pin and read "NRF_SAADC_INPUT_AIN1". I added new configuration in saadc_init function;

nrf_saadc_channel_config_t channel_2_config =
NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN1);

err_code = nrf_drv_saadc_channel_init(2, &channel_2_config);
APP_ERROR_CHECK(err_code);

err_code = nrf_drv_saadc_buffer_convert(&adc_buffer[2], 2);
APP_ERROR_CHECK(err_code);

And I add new value variable in saadc_calback function

nrf_saadc_value_t   adc_value_2;

adc_value_2= p_event->data.done.p_buffer[2];

NRF_LOG_INFO("adc_value_2= %u",adc_value_2);

I can compile the code but when I upload the code device can not advertise and RTT Viewer output get  fail.

 "0> <error> app: Fatal error"

Do you have any suggestion ? 

Parents
  • Hello,

    Can you please try to add DEBUG to your preprocessor defines, and turn off the optimization (set it to 0, -O0).

    Then set a breakpoint in app_error.c on line 73, and see if you can find what err_code and file name and line number that the error appeared.

     

    Best regards,

    Edvin

  • Hi Edvin, Thanks for your response. I set optimization to 0 and put a breakpoint on line 73 but I can do debug cause of error57-illegal address 0x00023000 (I do not know why)


  • I guess I can not debug with keil because I use segger_RTT. But I do not know exactly why.

    Also, RTT Viewer screen is like this;

Reply Children
  • Hello,

    You also have to define DEBUG in your preprocessor defines. Or else the line will not be included by the compiler.

    Can you test that?

    BR,

    Edvin