Configuration Pin in open-drain output - Low State unexpected

Hi,

I would like to declare my pin in output open-drain, so i use this configuration 

static void gpio_cfg_output_open_collector(uint32_t pin_number)
{
    nrf_gpio_cfg(
    pin_number,
    NRF_GPIO_PIN_DIR_OUTPUT,
    NRF_GPIO_PIN_INPUT_DISCONNECT,
    NRF_GPIO_PIN_NOPULL,
    NRF_GPIO_PIN_S0D1,							               // Standard '0', disconnect '1'.
    NRF_GPIO_PIN_NOSENSE);
}

My issue is when i declare my pin, I have an unexpected low state that occur, is this normal?

I tried to configure with pullup, but same behavior.

    gpio_cfg_output_open_collector(PIN_1); // pin goes high to down 
    gpio_cfg_output_open_collector(PIN_2); // pin goes high to down 
    
    nrf_gpio_pin_set(PIN_1); 					
    nrf_gpio_pin_set(PIN_2);

Are my configuration correct ? 

I would like to keep the high state during the configuration because a low state provoke a reset on a module not expected.

I'm using a NRF52840 and the S140 v6.1.0

Thanks and best regards,

Julien

Parents
  • Hello Julien,

    Please try to 'set' the pin before you configure it. Like this:

        nrf_gpio_pin_set(PIN_1);   // define pin state first to avoid glitch during configuration                 
        nrf_gpio_pin_set(PIN_2);

        gpio_cfg_output_open_collector(PIN_1); // pin goes high to down
        gpio_cfg_output_open_collector(PIN_2); // pin goes high to down
        
    Best regards,

    Vidar

    Edit: Forgot to add that this is expected behavior because the OUT register reset value is 0x0:

Reply
  • Hello Julien,

    Please try to 'set' the pin before you configure it. Like this:

        nrf_gpio_pin_set(PIN_1);   // define pin state first to avoid glitch during configuration                 
        nrf_gpio_pin_set(PIN_2);

        gpio_cfg_output_open_collector(PIN_1); // pin goes high to down
        gpio_cfg_output_open_collector(PIN_2); // pin goes high to down
        
    Best regards,

    Vidar

    Edit: Forgot to add that this is expected behavior because the OUT register reset value is 0x0:

Children
Related