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

nrf_gpio_cfg() function leaks current to pins

When I run an infinite loop of NOP on the NRF52DK, the led's remain dark. But when I run an infinite loop of:

nrf_gpio_cfg(
pin,
NRF_GPIO_PIN_DIR_INPUT,
NRF_GPIO_PIN_INPUT_DISCONNECT,
NRF_GPIO_PIN_PULLDOWN,	// !!! pulldown
NRF_GPIO_PIN_H0H1,	// !!! high current
NRF_GPIO_PIN_NOSENSE);
}

(iterating on all the gpio pins) the led's glow very faintly. I expected the led's to remain dark, since the reset state of the pins is dark (loosely speaking) and the call to nrf_gpio_cfg doesn't change that.

Might it be a "break before make" problem in the HW implementation? Maybe SW must change pin configuration bits in a certain order?

This continues the discussion in my previous post devzone.nordicsemi.com/.../. If blindly configuring gpio pins DOES leak current to the physical pin, might it disrupt the LFXO if you configure a pin that is also a LFXO pin?

  • You're explicitly attaching a pulldown to the pin. The reset state of the pins is NOPULL. Looking at the GPIO diagram, pull is attached after direction (input disconnect isn't shown explicitly on the input buffer but the intention of that is to disconnect the read circuit, not to prevent pull, you often need to pull a pin you don't need to read).

    So you are explicitly pulling all your pins low so I'd expect them all to glow.

    Change it to NOPULL to hi-Z them and the LEDs won't glow. That is the actual reset state. I believe Hung Bui suggested this in the last thread.

  • Thanks. Finally an answer that explains missing parts of the diagram. Why would you need to pull a pin that you don't read? My reasoning: if you don't read it implies not an input implies is output, and the output circuitry will drive it low or high.

  • if you set it as an output you're actually driving it, it's a push-pull circuit (totem-pole?) so if the thing you're connected to doesn't have a lot of resistance you could be pulling a current through it. The pull is passive, just connects a virtual resistor (10k? ish) between the pin and VDD or VCC, so that won't ever draw that much current and just anchors the pin.

    Imagine you connect, say, to a reset pin on a chip on your board. You don't want it to float when you're not using it, you don't want to drive it, you don't need to read it, so you just set it as input, turn off the buffer and pull it high. At the point you need to actually use it, then you configure it as output and drive it where you want.

    So consider input + pull + disconnect as a 'passive', guaranteed low power way to stop a pin floating.

    The diagram could be more clear here.

Related