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

GPIOTE interrupt not working with softdevice S140?

Hello,

From the ble_app_uart example I created a version where instead of the UART the incoming data over BLE is processed using the scheduler.

Processing is not much more then echoing the incoming strings back over BLE in the scheduler_event_handler. This works fine on a nrf52840 (android nano 33 ble).

But when I try to create an interrupt via GPIOTE, then the code stops working.

  ret_code_t err_code;
  if(!nrf_drv_gpiote_is_init())
    {
      err_code = nrf_drv_gpiote_init();
      APP_ERROR_CHECK(err_code);
      nrf_gpio_pin_set(LED_DL2);
    }
  nrf_gpio_pin_clear(LED_DL3_RED);

  nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_TOGGLE(true);
  in_config.pull = NRF_GPIO_PIN_PULLUP;

  err_code = nrf_drv_gpiote_in_init(BUTTON_1, &in_config, in_pin_handler);
  APP_ERROR_CHECK(err_code);
  nrf_gpio_pin_set(LED_DL1);
  return;

  nrf_drv_gpiote_in_event_enable(BUTTON_1, true);

This is the init code for gpiote, the only change to the code. Note that I use LEDs to show to where the code gets.

We can see that nrf_drv_gpiote_is_init() holds: the softdevice does that. The strange thing is that nrf_drv_gpiote_in_init() does not return as shown by the LED_DL2 led NOT lighting up.

There is a return statement here to make sure the event is not enabled, to make for a simpler scenario.

The same init code works ok when not using a softdevice, so why is the init-function not returning when using a  softdevice? Thanks in advance.

Parents
  • Hello,

    Does the arduino (I assume it is not "android") nano 33 ble have a debugger? If not, have you tried to use a DK?

     

    We can see that nrf_drv_gpiote_is_init() holds: the softdevice does that.

     The function nrf_drv_gpiote_is_init() can't hold anything. Are you basing this on the assumption that nrf_gpio_pin_clear(LED_DL3_RED); is not reached? If so, you should check what the APP_ERROR_CHECK(err_code) does, and what err_code is after nrf_drv_gpiote_init(); If APP_ERROR_CHECK(err_code) receives an err_code != 0, then the error handler will kick in, and either halt the application, or reset the application. In either case nrf_gpiote_pin_clear() will not be reached. 

    So does it have a debugger? Do you have any way to either step in the application, or monitor a log from the device?

    Best regards,

    Edvin

Reply
  • Hello,

    Does the arduino (I assume it is not "android") nano 33 ble have a debugger? If not, have you tried to use a DK?

     

    We can see that nrf_drv_gpiote_is_init() holds: the softdevice does that.

     The function nrf_drv_gpiote_is_init() can't hold anything. Are you basing this on the assumption that nrf_gpio_pin_clear(LED_DL3_RED); is not reached? If so, you should check what the APP_ERROR_CHECK(err_code) does, and what err_code is after nrf_drv_gpiote_init(); If APP_ERROR_CHECK(err_code) receives an err_code != 0, then the error handler will kick in, and either halt the application, or reset the application. In either case nrf_gpiote_pin_clear() will not be reached. 

    So does it have a debugger? Do you have any way to either step in the application, or monitor a log from the device?

    Best regards,

    Edvin

Children
Related