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
  • Hello,

    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.

    Could you make sure that DEBUG is defined in your preprocessor defines? It should look like the included image:


    Please make sure this is the case, and run the program again - you should then see a complete error message printed to the log, with which we may begin the debugging.

    Best regards,
    Karl

Reply
  • Hello,

    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.

    Could you make sure that DEBUG is defined in your preprocessor defines? It should look like the included image:


    Please make sure this is the case, and run the program again - you should then see a complete error message printed to the log, with which we may begin the debugging.

    Best regards,
    Karl

Children
Related