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

nrfx_gpiote interrupt causing hard fault

Hi

Using the nrf52840-dk with SD S140 and nrfx_gpiote, everything runs fund (BLE, TWI etc) but interrup on pin 0,28 causes a Hard Fault. I can not get any sensible logs to diagnose the issue (I'm using VSC and not familiar with Debug).

//IMU Interrup PIN Handler
    nrfx_gpiote_in_config_t in_config = NRFX_GPIOTE_CONFIG_IN_SENSE_HITOLO(true);
    in_config.pull = NRF_GPIO_PIN_PULLDOWN; //NRF_GPIO_PIN_NOPULL;
    in_config.hi_accuracy = true;
    err_code = nrfx_gpiote_in_init(MPU_INT_PIN, &in_config, in_pin_handler);
    APP_ERROR_CHECK(err_code);
    nrfx_gpiote_in_event_enable(MPU_INT_PIN, true);

Any ideas?

Thanks

  • Hi Andrew,

     

    Is the device always stuck in this function? What is printed on the UART?

    It seems that you are printing UART strings directly from the GPIOTE interrupt, which isn't recommended as you're blocking other processes in your firmware. Interrupts should be as short as possible in terms of processing. The GPIOTE interrupt seems to occur when you are communicating with the BNO080-sensor. Do these two functions share any status variables or similar?

     

    Kind regards,

    Håkon

  • Hi Hakon

    I noticed that too, that the interrupt function was printing to the UART so I offloaded that to a secondary function (see below).

    //IMU Interrup PIn Handler
        nrfx_gpiote_in_config_t in_config = NRFX_GPIOTE_CONFIG_IN_SENSE_HITOLO(true);
        in_config.pull = NRF_GPIO_PIN_PULLDOWN; //NRF_GPIO_PIN_NOPULL;
        in_config.hi_accuracy = true;
        err_code = nrfx_gpiote_in_init(MPU_INT_PIN, &in_config, in_pin_handler);
        APP_ERROR_CHECK(err_code);
        nrfx_gpiote_in_event_enable(MPU_INT_PIN, true);
    
    
    //Interrup Handling
    
    void inpinoffload() {
        NRF_LOG_INFO("inpinoffload");
        NRF_LOG_FLUSH();
    }
    void in_pin_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
    {
        inpinoffload();
    }

    Re the interrupt itself, it is from the BNO080 itself. The interrupt indicates that :

    1. Host asserts WAKE signal, requesting hub to become ready for a transfer.

    2. Hub asserts HINT signal, indicating that it is ready for a transfer.

    3. Hub deasserts HINT when transfer begins.

    All this is over TWI.

    Thanks

    Andrew

  • Hi,

     

    You still execute the NRF_LOG_ function in the interrupt.

    try setting a boolean flag in the in_pin_handler(), like this:

    static volatile bool pin_int_has_occurred;
    
    void in_pin_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
    {
      if (pin == MPU_INT_PIN) 
      {
        pin_int_has_occurred = true;
      }
    }
    
    ...
    
    in main:
    
    if (pin_int_has_occurred == true)
    {
      pin_int_has_occurred = false;
      /* Do rest of processing */
    }

     

    Kind regards,

    Håkon

  • Hi

    Looks to be the issue, didn't realise how impactful the NRF_LOG_INFO command is. The blocking it was causing certainly was the issue.

    Thanks for helping on this one.

Related