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

  • Hi Philip,

    You need to first identify which specific GPIO is the source of the power increase first rather than trying to disconnect all pins. Just try probing each GPIO pin with a multimeter or equivalent, while the chip is in SystemOFF mode. It should be easy to see which pin is logical high and is still driving current. We can turn our attention to that specific GPIO to see if that is a firmware or a hardware issue.

    GPIO disconnect will not help if there are pull-up configured as these pull ups will continue to driver the output pin.

  • right now i am not really sure where the current is coming from.

    how would i turn off the pullup/downs.

    would 

       gpio_pin_configure_dt( &shut_adc_ain0_, GPIO_INPUT);
    turn off the pullups ?
  • Did you check with the multimeter as suggested by Susheel?

    weightwatcherphil said:

    would 

       gpio_pin_configure_dt( &shut_adc_ain0_, GPIO_INPUT);
    turn off the pullups ?

    As you have said, the pin is configured as output, and now you want to disconnect. Please have a look at GPIO port and pin details as in the product specification:

    For each pin, we have direction (telling whether it is configured as input or output), input (connected or not), drive strength and pull configurations. Please refer to GPIO registers where you can read the status of configuration by reading the appropriate registers.

    Below, I am reading P0.23 configuration using nrfjprog (a command line tool from Nordic)

    //NRFJPROG command to read P0.23 (that is Button0 on the DK) configuration
    nrfjprog --memrd 0x5084275C

    Also, I suggest to use "gpio_pin_configure()" rather than the gpio_pin_configure_dt(), as the later does the OR operation of new flags with previous flags, while the other sets the new flags.

    Below, I am reading all gpio port0 pin configurations before and after using gpio_pin_configure() function, and I can see that the correct configuration is taking place for that specific pin:

    Regards,

    Naeem

  • this is extremely helpful.  especially the part about the OR.

    i will run some more test when i get back from vacation.

    thanks

Related