How to configure pin pull-up/down or disable it in the sdk

Hi there,
I'm new to the nrf/zephyr sdk and while using the nRF5340dk board, I've found that the pin1.01 is pulled high right after the board powers up. My assumption is that it should be high, only after the pin is configured as output and set to ACTIVE_HIGH in config. I've tried the below changes in the device tree overlay, but the pin remains high even before it's configured in the code by, 

gpio_pin_configure_dt(&pmic_control, GPIO_OUTPUT_ACTIVE);
The pin is defined in the overlay file as,

/{
    
mp5611_en_avdd_pin: mp5611_en_avdd_pin {
            gpios = <&gpio1 1 (GPIO_ACTIVE_HIGH)>;  // mp5611 pmic en avdd pin
            label = "mp5611 pmic en avdd pin";
        };
     
aliases {        
        mp5611-en-avdd = &mp5611_en_avdd_pin;
    }
};

Is there anything that I'm missing out that is causing this issue, I've noticed similar behaviour in the pin P0.00 also. There are other pins that i've configured in similar way, and they are in floating state when the board powers up. They reaches their required state only after we use the gpio_pin_configure_dt().

  • Hi,

    In your device tree overlay file (e.g., your_board.overlay), you can use the bias-pull-up or bias-pull-down property within the pin configuration group. For example:

    &pinctrl {
        uart0_default: uart0_default {
            group1 {
                psels = <NRF_PSEL(UART_TX, 0, 20)>,
                        <NRF_PSEL(UART_RX, 0, 22)>;
                bias-pull-up;
            };
        };
    };

    this is pull-up resistors for the UART TX and RX pins.
    If you want to disable the pull-up/pull-down, you can use the bias-disable property:
    &pinctrl {
        uart0_default: uart0_default {
            group2 {
                psels = <NRF_PSEL(UART_RX, 0, 22)>,
                        <NRF_PSEL(UART_CTS, 0, 21)>;
                bias-disable;
            };
        };
    };
    For pull-down configuration, you would use bias-pull-down instead of bias-pull-up.


    Some pins do extra things like NFC and 32kHz external crystal. So this will need to comply with how it is connected. P0.00 and P0.01 is external crystal. P0.02 and P0.03 are NFC. 
     https://docs.nordicsemi.com/bundle/ps_nrf5340/page/chapters/pin.html 

    Regards,
    Jonathan

Related