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!

Parents
  • Sigurd,

    Thanks for the response. However, I believe my code is already doing what you suggested. Unless I'm missing something, can you please elaborate?

    John

  • Hi,

    Did you connect GPIOTE_0 IRQ to nrfx_gpiote_irq_handler ?

    You could take a look at how it's done in the Zephyr nrfx sample. See this link. To test this sample, build the nrfx sample for the nrf5340pdk_nrf5340_cpunet. And for the app core, you could e.g. use the NCS empty_app_core sample, and build that for nrf5340pdk_nrf5340_cpuapp. See this link.

  • 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?

  • I created a new public ticket with the FORCEOFF question. I suppose this ticket with button interrupts is now resolved. Thanks for your help!

Reply Children
No Data
Related