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

Cannot get button/gpio interrupt on NET CPU using nRF5340DK

Using just the nRF Connect SDK, I cannot get a push button to interrupt the NET CPU on the nRF5340DK.

I have the following code on the APP CPU:

  nrf_gpio_pin_mcu_select(23, NRF_GPIO_PIN_MCUSEL_NETWORK);

The following code runs on the NET CPU:

  nrfx_gpiote_init(NRFX_GPIOTE_DEFAULT_CONFIG_IRQ_PRIORITY);
  nrfx_gpiote_in_config_t cfg = NRFX_GPIOTE_CONFIG_IN_SENSE_TOGGLE(false);
  cfg.pull = NRF_GPIO_PIN_PULLUP;
  nrfx_gpiote_in_init(NRF_GPIO_PIN_MAP(0, 23), &cfg, MyEventHandler);
  nrfx_gpiote_in_event_enable(NRF_GPIO_PIN_MAP(0, 23), true);

Please help identify what I'm missing. Thank you in advance!

  • Sigurd,

    Thank you for trying this and confirming the code works. The difference in my setup is that I'm not using zephyr. 

    I did try using the empty_app_core on the APP CPU. And I tried using your NET CPU example code (removing the zephyr code) and I'm still not getting interrupts.

    My issue must have something to do with the code prior to main(). I will keep trying to see if I can resolve. But if you can point me to the zephyr startup code (e.g. Reset Handler) and/or if the ncs has a non-zephyr startup example, that would help.

    Appreciate your effort to help me on this issue.

    Thanks.

    John

  • If you set a breakpoint in nrfx_gpiote_irq_handler(), and press the button, do you hit the breakpoint ?

    If not, make sure that you have something like this defined,

    // GPIOTE0_IRQn
    #define nrfx_gpiote_irq_handler     GPIOTE_IRQHandler

    Still not working, then you might need something like this,

    #define NRF_GPIOTE        NRF_GPIOTE0
    #define GPIOTE_IRQHandler GPIOTE0_IRQHandler

  • These are useful links. But did not solve my problem.

    I think the issue is even more fundamental. I tried a VTOR with every entry pointing to a default handler/trap, I never break on any ISR. I am setting the global interrupt __enable_irq(). I call NVIC_EnableIRQ(GPIOTE_IRQn). And I'm relying on the nrfx drivers to enable IRQs. Missing anything else?

  • I'm tried something extremely basic in the reset handler. I expected to trap in the SystemDefaultHandler() upon a button press but instead remains looping in the Reset_Handler(). I'm missing something basic.

    static void SystemDefaultHandler(void)
    {
      while(1);
    }
    
    SECTION(".isr_vector")
    void (* const systemVectors[256])(void) =
    {
      (void (*)(void))(&__stack_top__),
      Reset_Handler,
      SystemDefaultHandler,
      SystemDefaultHandler,
      SystemDefaultHandler,
      SystemDefaultHandler,
      SystemDefaultHandler,
      SystemDefaultHandler,
      SystemDefaultHandler,
      SystemDefaultHandler,
      SystemDefaultHandler,
      SystemDefaultHandler,
      SystemDefaultHandler,
      SystemDefaultHandler,
      SystemDefaultHandler,
      SystemDefaultHandler,
    
      /* External interrupts */
      SystemDefaultHandler,
      SystemDefaultHandler,
      SystemDefaultHandler,
      SystemDefaultHandler,
      SystemDefaultHandler,
      SystemDefaultHandler,
      SystemDefaultHandler,
      SystemDefaultHandler,
      SystemDefaultHandler,
      SystemDefaultHandler,
      SystemDefaultHandler,
      SystemDefaultHandler,
      SystemDefaultHandler,
      SystemDefaultHandler,
      SystemDefaultHandler,
      SystemDefaultHandler,
      SystemDefaultHandler,
      SystemDefaultHandler,
      SystemDefaultHandler,
      SystemDefaultHandler,
      SystemDefaultHandler,
      SystemDefaultHandler,
      SystemDefaultHandler,
      SystemDefaultHandler,
      SystemDefaultHandler,
      SystemDefaultHandler,
      SystemDefaultHandler,
      SystemDefaultHandler,
      SystemDefaultHandler,
      SystemDefaultHandler
    
    };
    
    #include <nrfx_gpiote.h>
    
    static void button_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
    {
      while(1);
    }
    
    void Reset_Handler(void)
    {
      /* Use linker defined location for ROM vector tables. */
      SCB->VTOR = (uint32_t)systemVectors;
    
      /* Core initialization. */
      SystemInit();
    
      nrfx_gpiote_init(NRFX_GPIOTE_DEFAULT_CONFIG_IRQ_PRIORITY);
      nrfx_gpiote_in_config_t cfg = NRFX_GPIOTE_CONFIG_IN_SENSE_TOGGLE(false);
      cfg.pull = NRF_GPIO_PIN_PULLUP;
      nrfx_gpiote_in_init(NRF_GPIO_PIN_MAP(0, 23), &cfg, button_handler);
      nrfx_gpiote_in_event_enable(NRF_GPIO_PIN_MAP(0, 23), true);
    
      NVIC_EnableIRQ(GPIOTE_IRQn);
      __enable_irq();
    
      while(1);
    }
    

  • Alright, I am able to get interrupts now. The above code is fine. The issue is the NET CPU startup is not always reliable. Using the empty_app_core project, I do not see my NET CPU startup. 

    When I reset the NET CPU using "nrfjprog -f NRF53 --coprocessor CP_NETWORK --reset", then I see the NET CPU execute my binary. And buttons presses reliably generate interrupt.

    Any idea how to make the empty_app_core reliably start my application?

Related