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

Inconsistent ADC Behaviour with DFU

Hi all,

I have a working ADC implementation (S130 + Application) and use it to measure an analog input continuously.

However if I use the same code on top of bootloader (S130+DFU+Application), it starts acting weird. When I check the ADC values, I noticed that they are fluctuating in a large margin. What may cause this issue when I use the code with DFU but works as expected without DFU code?

Regards

  • Also may it still be a hardware issue when the problem occurs when I transmit the package over DFU only? Without DFU, it works as expected.

    Edit: In my previous messages, I have posted the following image and marked the HIGH value as expected analog value but now I noticed that it is not correct. Expected analog value must be at 1V level, but in the image it is about 3V.

    pasteboard.co/GK23FHl.jpg

    So to summarize the issue:

    1. When we load the application on top of S130 by using nrfGo, it works as expected (we can measure the analog signal about 1V)
    2. When we load the application on top of S130+DFU by using NRF Toolbox, analog signal goes to 3V level during normal operation which should have been 1V actually, and draws a wavesquare each time ADC sampling occurs. Once the ADC sampling stopped, it goes to 3V level again. May it be an internal pullup-pulldown issue during ADC sampling?
  • Could you try configuring the GPIO pull settings using the GPIO pin number in the call to nrf_gpio_cfg_input()? The define you are using will not evaluate to the correct GPIO pin number (AIN2 = P0.01):

    NRF_ADC_CONFIG_INPUT_2 = ADC_CONFIG_PSEL_AnalogInput2  = (4UL) 
    

    Try changing from this:

    nrf_gpio_cfg_input(NRF_ADC_CONFIG_INPUT_2,NRF_GPIO_PIN_NOPULL);
    

    To this:

    nrf_gpio_cfg_input(1,NRF_GPIO_PIN_NOPULL);
    
  • Hi Jorgen,

    I found the root cause of the problem but it looked like a bug on SDK and I still need a solution for this.

    I noticed that I set the pin 1 as output in bootloader code as follows:

    nrf_gpio_cfg_output(1); nrf_gpio_pin_set(1);

    But I am expecting the application code to reset this pin as input in my main code with the following code:

    nrf_gpio_cfg_input(1,NRF_GPIO_PIN_NOPULL);

    But it doesn't. Do you have any idea why it is not reset as input in application code or may you offer a workaround for me?

    Regards

  • Hi Jorgen,

    Sorry, I didn't notice your suggestion while writing my comment. Yes, changing pin conffiguration solved the issue. I don't know if it is an expected behaviour but it seems the chip carries the pin configuration from DFU code to the application code. After correcting the pin configuration in app code, all looks fine. Thanks for all your help.

  • You will allways go through the bootloader when restarting the chip, to check for a valid application. If you are setting the pins in the bootloader code, this will be retained when executing the application.

Related