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

Fatal error having called nrfx_gpiote_in_init

I'm new to the nrf5 GPIO functionality and having a little difficulty getting started. Upon having called `nrfx_gpiote_in_init`, my app reports a fatal error and the device resets. 'hoping that the following code sheds some light on this:

```

/**@brief Handle GPIO input sensing events
*/
static void on_gpio_in_evt(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{
  NRF_LOG_INFO("Pin changed!");
}

/**@brief Set up our actual sensors
*/
static void gpio_init()
{
  ret_code_t err_code;
  nrfx_gpiote_pin_t pir_pin1 = NRF_GPIO_PIN_MAP(1, 1);
  nrfx_gpiote_in_config_t config = NRFX_GPIOTE_CONFIG_IN_SENSE_TOGGLE(false);

  if (!nrfx_gpiote_is_init())
  {
    err_code = nrfx_gpiote_init();
    APP_ERROR_CHECK(err_code);
  }

  err_code = nrfx_gpiote_in_init(pir_pin1, &config, on_gpio_in_evt);
  APP_ERROR_CHECK(err_code);

  nrfx_gpiote_in_event_enable(pir_pin1, true);
}

```

My `sdk_config.h` enables GPIOTE (I don't think I've changed the config from the BLE peripheral template).

Here's my console output:

```

<info> app_timer: RTC: initialized.
<error> app: Fatal error
<warning> app: System reset

```

Related: I've interpreted the doc to read that it is ok to perform app functionality in the input event handler i.e. we are out of the world of interrupts. Not that it makes any difference here though, the failure occurs as a consequence of `APP_ERROR_CHECK` following the `nrfx_gpiote_in_init` call.

Thanks for any pointers.

Parents Reply
  • Christopher Hunt said:
    Thank you Karl.

    No problem at all, Christopher!

    Christopher Hunt said:
    This yields the following very interesting snippet:

    Yes, this is much easier to work with.
    NRF_ERROR_NO_MEM is often returned by a function when it has insufficient allocated memory to be executed.
    Which function is being called at line 698 of your main.c?
    When we know the exact function generating the error code, we can look it up in the API Reference, to see how we should proceed with the error.

    Best regards,
    Karl

Children
Related