nrf_drv_gpiote_in_event_enable causes event

Hey,

When I call fn nrf_drv_gpiote_in_event_enable, the event handler is immediately called.  Note that at the beginning of the fn I even read the pin to verify it's high.  I also know it's high because I'm scoping it.   Also, this code does work properly when the line transitions to low.

Is there a way to stop this erroneous event from happening when enabled???

    ret_code_t err_code;

    nrf_gpio_cfg_input(gp_board_config->irq, NRF_GPIO_PIN_PULLUP);

    {
        volatile uint32_t read = nrf_gpio_pin_read(gp_board_config->irq);

        // Setting break point here verifies this line is high.
        read++;
    }

    err_code = nrf_drv_gpiote_init();
    APP_ERROR_CHECK(err_code);

    /**
     * Sam will set the interrupt aka wakeup line low until nrf responds with Ack.
     */

    nrf_drv_gpiote_in_config_t irq_config = NRFX_GPIOTE_CONFIG_IN_SENSE_HITOLO(false);
    err_code = nrf_drv_gpiote_in_init(gp_board_config->irq, &irq_config, m_gpiote_evt_handler);
    APP_ERROR_CHECK(err_code);

    CRITICAL_REGION_ENTER();
    nrf_drv_gpiote_in_event_enable(gp_board_config->irq, true);

    {

        nrf_gpiote_events_t event   = nrfx_gpiote_in_event_addr_get(gp_board_config->irq);

        nrf_gpiote_event_clear(event);

        NVIC_ClearPendingIRQ(GPIOTE_IRQn);
    }

    CRITICAL_REGION_EXIT();

Note I even tried disabling ints, and then clearing the event and the interrupt - no success.

Related