Best nRF9160 Zephyr way to configure high impedance pin state?

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

Parents
  • Hello Ted,

    I'm not quite sure what you are asking for. Do you need pin configuration for three different scenarios?


    It has this form, but I find that _FLAGS by default gets assigned a value of zero:

    Yes, this seems correct base don the response of the DT_GPIO_FLAGS API

    In regards to setting the pin to high-impedance, the following call should be used: 

    gpio_pin_configure(led.port, led.pin, GPIO_DISCONNECTED);

    Kind regards,
    Øyvind

  • Hello Øyvind,

    With my question I meant to ask whether in Zephyr 2.6.0 GPIO framework, need I a different pin configuration for pins which in normal, active powered mode are inputs, versus other pins which are outputs.  I am sorry for the poorly worded question!

    I will re-run a couple tests using GPIO_DISCONNECTED.  I recently discovered that symbol in Zephyr documentation, but when I apply it to just a few pins (which were not explicitly configured yet) I see current increase, not decrease.  If the pin configuration GPIO_DISCONNECTED is physically disconnecting the I/O pins of the nRF9160, I would expect overall board current to remain the same or decrease.  My observations however are counter-intuitive.

    There are a couple of tests I will set up and observe.  But it sounds like for both "active time" input and output lines to the nRF9160, the highest impedance setting is GPIO_DISCONNECTED, correct?

    One more question:  is it a valid design choice to call Zephyr RTOS gpio configuration API periodically during firmware run time?  In other words, when electrically safe does the nRF9160 support Zephyr or other code changing GPIO configuration dynamically?

    - Ted

Reply
  • Hello Øyvind,

    With my question I meant to ask whether in Zephyr 2.6.0 GPIO framework, need I a different pin configuration for pins which in normal, active powered mode are inputs, versus other pins which are outputs.  I am sorry for the poorly worded question!

    I will re-run a couple tests using GPIO_DISCONNECTED.  I recently discovered that symbol in Zephyr documentation, but when I apply it to just a few pins (which were not explicitly configured yet) I see current increase, not decrease.  If the pin configuration GPIO_DISCONNECTED is physically disconnecting the I/O pins of the nRF9160, I would expect overall board current to remain the same or decrease.  My observations however are counter-intuitive.

    There are a couple of tests I will set up and observe.  But it sounds like for both "active time" input and output lines to the nRF9160, the highest impedance setting is GPIO_DISCONNECTED, correct?

    One more question:  is it a valid design choice to call Zephyr RTOS gpio configuration API periodically during firmware run time?  In other words, when electrically safe does the nRF9160 support Zephyr or other code changing GPIO configuration dynamically?

    - Ted

Children
No Data
Related