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

How to configure default state of GPIO ouput

Working with NRF5 SDK 15.0.x, if I configure an GPIO as output, its initial state is low. I can set it high after configuration, but it is briefly low. Is there anyway to configure the initial state to be high/set before the pin is connected as ouput using the SDK?

Thanks

Parents Reply Children
  • It does have an external pullup, I am configuring the pin in an open drain configuration using NRF_GPIO_PIN_S0D1 as the drive type as follows"

        nrf_gpio_cfg(pin,
            NRF_GPIO_PIN_DIR_OUTPUT,
            NRF_GPIO_PIN_INPUT_DISCONNECT,
            NRF_GPIO_PIN_NOPULL,
            NRF_GPIO_PIN_S0D1,
            NRF_GPIO_PIN_NOSENSE);

    When this function is called, the pin is pulled low as the default state for the output pin is cleared. What I am looking for is a way for the value associated with the pin to be set to 1 (i.e. disconnected) at configuration time so that the pin is not pulled low.

  • You can see the source of nrf_gpio_cfg() - it just writes to the PIN_CNF register.

    Check the Product Specification for register descriptions & to see if there's an option to do what you want...

Related