Hello Devzone Community,
I have a question set regarding correct, best way or ways to configure nRF9160 GPIOs for high impedance. My hardware is a custom board but shares a feature set similar to Nordic nRF9160DK 1.0.0 and Sparkfun Thing Plus nRF9160. My team project is also a battery powered design, so I am tackling the multiple low power considerations of the 9160 and battery design, e.g.: external hardware power downs, on 9160 SiP peripheral config via Zephyr, LTE modem configuration for low power, and thread management in our custom app.
On the issue to configure nRF9160 for deep sleep, lowest power mode, what would be the highest impedance (lowest leak current) configuration for:
(1) a GPIO acting as output driver such as a SPI chip select line?
(2) a GPIO acting as in input, for example GPIO connected to hardware interrupt line of external sensor?
Presently I have in application firmware routines like the following, to configure nRF9160 GPIOs at firmware start time:
static uint32_t hardware_config__configure_line__led0(void) { uint32_t rstatus = ROUTINE_OK; dev_led_red = device_get_binding(LED0_LABEL); if ( dev_led_red == NULL ) { rstatus = ZR__WARNING__FAIL_ON_DEVICE_GET_BINDING; } if ( rstatus == ROUTINE_OK ) { rstatus = gpio_pin_configure(dev_led_red, LED0_PIN, GPIO_OUTPUT_ACTIVE | LED0_FLAGS); if ( rstatus < 0 ) { rstatus = ZR__WARNING__FAIL_ON_GPIO_PIN_CONFIGURE; } } if ( rstatus == ROUTINE_OK ) { gpio_pin_set(dev_led_red, LED0_PIN, CUSTOM_APP__PIN_STATE_DEFAULT_START_VALUE__LED0); } return rstatus; }
The symbol LED0_FLAGS is generated by a septet of pound defines, which I first saw in Nordic Semi ncs v1.6.1 blinky sample. It has this form, but I find that _FLAGS by default gets assigned a value of zero:
#define LED0_NODE DT_ALIAS(led0) #if DT_NODE_HAS_STATUS(LED0_NODE, okay) #warning --- --- --- macro evaluating 'led0' dts alias returns true --- --- --- #define LED0_LABEL DT_GPIO_LABEL(LED0_NODE, gpios) #define LED0_PIN DT_GPIO_PIN(LED0_NODE, gpios) #define LED0_FLAGS DT_GPIO_FLAGS(LED0_NODE, gpios) #else #warning --- --- --- macro evaluating 'led0' dts alias returns false --- --- --- #define LED0_LABEL "" #define LED0_PIN 0 #define LED0_FLAGS 0 #endif
In Zephyr RTOS 2.6.0 GPIO documentation the specific flags and flag combinations we can use to configure pin states are described or at least listed. I had read in an STMicro post somewhere that to achieve high input impedance the best setting is to configure a pin as input, with pull-up and pull-down disabled. With my nRF9160 Zephyr based application I have now tried the following GPIO configurations: GPIO_OUTPUT, GPIO_INPUT with weak pull-down enabled, GPIO_DISCONNECTED. I've tried these settings on our utilized pins, which are attached to external hardware that I am turning off.
Strange finding is, with all the explicit GPIO configurations I enable in our custom app, I find lowest current draw increasing to a few hundred microamps, up from several tens of microamps. This seems counter-intuitive. I have confirmed with a DMM that external rails to peripherals are at ground state. So I question:
(3) with pin set GPIO_OUTPUT_LOW, or GPIO_INPUT with weak pull-down, and all external nets at GND potential, is there yet current bleeding from one or more GPIOs?
The nRF9160 in our design has an always present VDD and VDD_GPIO. In our design we cannot turn these off.
Any insights or share-able experience from Devzone Community welcome!
- Ted