how to disconnect a GPIO pin

i have a custom board that uses a nrf5340 that has been hardware modified so i can work again on getting my board to draw the mimimum power from the battery.

i have a PPK2 kit to measure the power i am drawing.

right now in SYSTEM_OFF state I am drawing about 600 ua..

i have several chips on the board that  use  a GPIO configured as an output pin to turn off a mosfet that controls their power.

when the chip does not have power it looks like it is getting power via other GPIO pins coming through the ESD diodes.

so I want to set all my GPIO pins that might be supply power to the unpowered IC on my board to be disconnected.

I am using zephyr and think I should use GPIO_DISCONNECTED.

I want the input buffer amplifier off

the output pin off

and any pullups off.

I do not want it to be detected by any interrupt.

I have one pin configured to work for wake on interrupt so I can press a button to wake my board up.

I worked on reducing my power months ago but gave up becuase teh hardware was pulling power beyond my control

now the hardware has been fixed but i still am drawing a lot of power due to i think the ESD diodes on unpowered chips.

thanks

phil

  • Which pins you are using for the I2C?

    What error / problem you are getting for the updated code that you wrote?

  • we use these pins for I2c

    // pins used by I2c
    // I2C_SCL P1.03
    // I2C_SDA P1.02

    we are using PPK2 kit to measure current drawn from our battery.

    we measure about 132 ua in we are in system OFF state.

    most ot that power is due to other chips on our board such as a battery charger, etc. and we are addressing those issues by changing the electronics.

    we just want to make sure the processor is drawing the smallest amount of power possible.

    we used nrfx library calls to get us there.

    now I would like to use Zephyr code to put the pins in the same state as we did with nrfx library calls.

    we were told that using 

    gpio_pin_configure_dt  ORs the flags with what is present we would like to know how to set the flags.

    so two questions:

    1 -what is the call i should make in zephyr to replace

    gpio_pin_configure_dt( &shut_adc_ain1_, GPIO_INPUT); //AIN1 - unused pin

    with something that will set the flags and not or them.

    2 what call should i make in zephyr to replace 

      nrf_gpio_cfg_default(NRF_GPIO_PIN_MAP(1,k));

    3 what reason might this cause us to draw less power on the I2C pins.

      nrf_gpio_cfg(NRF_GPIO_PIN_MAP(1,k),NRF_GPIO_PIN_DIR_INPUT, NRF_GPIO_PIN_INPUT_DISCONNECT, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_S0D1, NRF_GPIO_PIN_NOSENSE);  //not sure why this is needed, but seems to be required for the I2C pins

    the chips the I2C pins are connected have had there VCC power turned off by a mosfet switch.

    so the power pin is more or less floating.  maybe that is an issue and we are feeding power through some protection diodes in the processor ?

    if we "disconnect a GPIO pin does it still have ESD diodes ?

    sorry i cannot share the full schematic and i know that makes a full answer difficult so i will take all teh help and ideas i can get.

    thanks

    phil

  • weightwatcherphil said:

    1 -what is the call i should make in zephyr to replace

    gpio_pin_configure_dt( &shut_adc_ain1_, GPIO_INPUT); //AIN1 - unused pin

    Please use "gpio_pin_configure()" as suggested previously?

    weightwatcherphil said:

    2 what call should i make in zephyr to replace 

      nrf_gpio_cfg_default(NRF_GPIO_PIN_MAP(1,k));

    the nrf_gpio_cfg_default calls the nrf_gpio_cfg() function with the default values

    NRF_STATIC_INLINE void nrf_gpio_cfg_default(uint32_t pin_number)
    {
        nrf_gpio_cfg(
            pin_number,
            NRF_GPIO_PIN_DIR_INPUT,
            NRF_GPIO_PIN_INPUT_DISCONNECT,
            NRF_GPIO_PIN_NOPULL,
            NRF_GPIO_PIN_S0S1,
            NRF_GPIO_PIN_NOSENSE);
    }

    You can use the gpio_pin_configure() function to configure a single pin and provide flags for pin configuration:

    You can see that nrfx uses default pin direction as "input" and also by default "disconnected".

    Zephyr GPIO API also provides you with the flags, and you can use them

    weightwatcherphil said:

    3 what reason might this cause us to draw less power on the I2C pins.

      nrf_gpio_cfg(NRF_GPIO_PIN_MAP(1,k),NRF_GPIO_PIN_DIR_INPUT, NRF_GPIO_PIN_INPUT_DISCONNECT, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_S0D1, NRF_GPIO_PIN_NOSENSE); 

    The reason is that you have configured the pin with no sense mechanism, no pull, and also disconnected. That is low power config.

    weightwatcherphil said:
    if we "disconnect a GPIO pin does it still have ESD diodes ?

    ESD protection is there.

  • i have been very busy on another project.  thanks very much for this answer and you may close the ticket.

Related