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
  • Digging through the code as @awneil suggested, I found that nrf_gpio_pin_set() simply updates the OUTSET register, so the pin does not need to be configured as output first. Calling this before configuring the pin as output results in the behavior I was looking for. 

    nrf_gpio_pin_set(pin);
    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);

Reply
  • Digging through the code as @awneil suggested, I found that nrf_gpio_pin_set() simply updates the OUTSET register, so the pin does not need to be configured as output first. Calling this before configuring the pin as output results in the behavior I was looking for. 

    nrf_gpio_pin_set(pin);
    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);

Children
No Data
Related