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

Error 3735928559 on Multiple Pin Change Interrupt enable

Hi,

   I have to control 16 pin output pins based on the 16 pin interrupt.

Is it possible to have 16 pins interrupt in nrf52840 . Pin change interrupt

when i config

void statuspinenable() {
  uint32_t err_code;
  nrf_drv_gpiote_init();
  nrf_drv_gpiote_in_config_t config =
      {
          .sense = NRF_GPIOTE_POLARITY_TOGGLE,
          .pull = NRF_GPIO_PIN_PULLUP,
          .is_watcher = false,
          .hi_accuracy = true,
          .skip_gpio_setup = false};
  nrf_drv_gpiote_in_init(sbut1, &config, int_evt_handler);
  nrf_drv_gpiote_in_init(sbut2, &config, int_evt_handler);
  nrf_drv_gpiote_in_init(sbut3, &config, int_evt_handler);
  nrf_drv_gpiote_in_init(Status1, &config, int_evt_handler);
  nrf_drv_gpiote_in_init(Status2, &config, int_evt_handler);
  nrf_drv_gpiote_in_init(Status3, &config, int_evt_handler);
  nrf_drv_gpiote_in_init(Status4, &config, int_evt_handler);
  nrf_drv_gpiote_in_init(Status5, &config, int_evt_handler);
  nrf_drv_gpiote_in_init(Status6, &config, int_evt_handler);
  nrf_drv_gpiote_in_init(Status7, &config, int_evt_handler);
  nrf_drv_gpiote_in_init(Status8, &config, int_evt_handler);
  nrf_drv_gpiote_in_init(Status9, &config, int_evt_handler);
  nrf_drv_gpiote_in_init(Status10, &config, int_evt_handler);
  nrf_drv_gpiote_in_init(Status11, &config, int_evt_handler);
  nrf_drv_gpiote_in_init(Status12, &config, int_evt_handler);
  nrf_drv_gpiote_in_init(Status13, &config, int_evt_handler);
  nrf_drv_gpiote_in_event_enable(sbut1, true);
  nrf_drv_gpiote_in_event_enable(sbut2, true);
  nrf_drv_gpiote_in_event_enable(sbut3, true);
  nrf_drv_gpiote_in_event_enable(Status1, true);
  nrf_drv_gpiote_in_event_enable(Status2, true);
  nrf_drv_gpiote_in_event_enable(Status3, true);
  nrf_drv_gpiote_in_event_enable(Status4, true);
  nrf_drv_gpiote_in_event_enable(Status5, true);
  nrf_drv_gpiote_in_event_enable(Status6, true);
  nrf_drv_gpiote_in_event_enable(Status7, true);
  nrf_drv_gpiote_in_event_enable(Status8, true);
  nrf_drv_gpiote_in_event_enable(Status9, true);
  nrf_drv_gpiote_in_event_enable(Status10, true);
  nrf_drv_gpiote_in_event_enable(Status11, true);
  nrf_drv_gpiote_in_event_enable(Status12, true);
  nrf_drv_gpiote_in_event_enable(Status13, true);
}

it return me the error as

<info> app_timer: RTC: initialized.
<error> app: ERROR 3735928559 [Unknown error code] at D:\nRF5xx\1.SDK_17.0.2\modules\nrfx\drivers\src\nrfx_gpiote.c:609
PC at: 0x00032007
<error> app: End of error report

and i check the 609 line in the nrfx_gpiote.c

marking the line : NRFX_ASSERT(pin_in_use_by_gpiote(pin));

under the function

void nrfx_gpiote_in_event_enable(nrfx_gpiote_pin_t pin, bool int_enable)
{
    NRFX_ASSERT(nrf_gpio_pin_present_check(pin));
    NRFX_ASSERT(pin_in_use_by_gpiote(pin));
    if (pin_in_use_by_port(pin))
    {
        nrf_gpiote_polarity_t polarity =
            port_handler_polarity_get(channel_port_get(pin) - GPIOTE_CH_NUM);
        nrf_gpio_pin_sense_t sense;
        if (polarity == NRF_GPIOTE_POLARITY_TOGGLE)
        {
            /* read current pin state and set for next sense to oposit */
            sense = (nrf_gpio_pin_read(pin)) ?
                    NRF_GPIO_PIN_SENSE_LOW : NRF_GPIO_PIN_SENSE_HIGH;
        }
        else
        {
            sense = (polarity == NRF_GPIOTE_POLARITY_LOTOHI) ?
                    NRF_GPIO_PIN_SENSE_HIGH : NRF_GPIO_PIN_SENSE_LOW;
        }
        nrf_gpio_cfg_sense_set(pin, sense);
    }
    else if (pin_in_use_by_te(pin))
    {
        int32_t             channel = (int32_t)channel_port_get(pin);
        nrf_gpiote_events_t event   = TE_IDX_TO_EVENT_ADDR((uint32_t)channel);

        nrf_gpiote_event_enable((uint32_t)channel);

        nrf_gpiote_event_clear(event);
        if (int_enable)
        {
            nrfx_gpiote_evt_handler_t handler = channel_handler_get((uint32_t)channel_port_get(pin));
            // Enable the interrupt only if event handler was provided.
            if (handler)
            {
                nrf_gpiote_int_enable(1 << channel);
            }
        }
    }
}

When i use breakpoints and check.

after enabling 8 pins then the error is thrown

Parents Reply Children
  • Hello,

    Sunil vignesh said:
    I found the Port event in gpiote. How it is working

    The port event is a low-power, low-accuracy equivalent of the GPIOTE IN_EVENT. It works in the same way hardware wise, the difference is that IN_EVENTs are dedicated to a single channel, so you will always know immediately which pin generated the interrupt. The PORT event however is a general event, which basically says 'something has/is happening on this PORT', and you then have to go in and check each pin state to gather which pin triggered the PORT event.
    The PORT event is perfect for signals that persists over some time, such as a button or general pin state change.

    Sunil vignesh said:
    example for port event interrupt working.

    The GPIOTE example from the SDK shows how you can setup PORT events. The difference in configuration between high accuracy IN_EVENT and a PORT event is the argument given to GPIOTE_CONFIG_OUT_TASK_TOGGLE() in combination with the GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS define.

    Best regards,
    Karl

  • Hi Karl , Can you provide me the main.c (edited ) for Assign port1 of nrf52840 to be interrupt

  • #include <stdbool.h>
    #include <stdint.h>
    #include "nrf.h"
    #include "nrf_gpiote.h"
    #include "nrf_gpio.h"
    #include "boards.h"
    #include "nrf_drv_gpiote.h"
    #include "app_error.h"
    
    #define GPIO_INPUT_PIN_NUMBER_1 NRF_GPIO_PIN_MAP(0, 3)  /**< Pin number for input on PORT0. */
    #define GPIO_INPUT_PIN_NUMBER_2 NRF_GPIO_PIN_MAP(1, 3)  /**< Pin number for input on PORT1. */
    
    static void gpiote_event_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
    {
        if(pin == GPIO_INPUT_PIN_NUMBER_1)
        {
            nrf_gpio_pin_toggle(LED_1);
        }
        else if (pin == GPIO_INPUT_PIN_NUMBER_2)
        {
            nrf_gpio_pin_toggle(LED_2);
        }
    }
    
    static void gpiote_init()
    {
        ret_code_t err_code;
    
        err_code = nrf_drv_gpiote_init();
        APP_ERROR_CHECK(err_code);
        nrf_drv_gpiote_in_config_t config = GPIOTE_CONFIG_IN_SENSE_TOGGLE(false);
    
        err_code = nrf_drv_gpiote_in_init(GPIO_INPUT_PIN_NUMBER_1, &config, gpiote_event_handler);
        APP_ERROR_CHECK(err_code);
    
        err_code = nrf_drv_gpiote_in_init(GPIO_INPUT_PIN_NUMBER_2, &config, gpiote_event_handler);
        APP_ERROR_CHECK(err_code);
    
        nrf_drv_gpiote_in_event_enable(GPIO_INPUT_PIN_NUMBER_1, true);
        nrf_drv_gpiote_in_event_enable(GPIO_INPUT_PIN_NUMBER_2, true);
    }
    
    static void leds_init()
    {
        nrf_gpio_cfg_output(LED_1);
        nrf_gpio_cfg_output(LED_2);
        
        nrf_gpio_pin_set(LED_1);
        nrf_gpio_pin_set(LED_2);
    }
    
    
    /**
     * @brief Function for application main entry.
     */
    int main(void)
    {
        leds_init();
        gpiote_init();
    
        while (true)
        {
            // Do Nothing - GPIO can be toggled without software intervention.
            __WFE();
            __SEV();
            __WFE();
        }
    }

    Take a look at the included code, it configures two pins to be monitored by the low-accuracy PORT event.

    Sunil vignesh said:
    Assign port1 of nrf52840 to be interrupt

    This is not completely accurate to say, since you do not configure a whole port 'to be interrupt', but rather you set a GPIOTE channel to monitor multiple pins, combining them into a PORT event.
     
    Basically, setting up a PORT event means that you use a single GPIOTE channel to monitor multiple pins. You will still need to setup these pins for monitoration by initializing them as low-accuracy input pins in the GPIOTE driver.

    Best regards,
    Karl

  • Hi Karl,

    The above shown main.c is seems to be like Pin change interrupt. As like this i can't able to configure all the pins of P1.00 to P1.15 in nrf52840. Is it right?

  • Hello again,

    Sunil vignesh said:
    As like this i can't able to configure all the pins of P1.00 to P1.15 in nrf52840. Is it right?

    I am not sure I understand you question here correctly, but if you are asking if you can enable multiple pins on the same PORT event that is correct. The PORT event is the same event for all the pins that are enabled and configured to low-accuracy. Please see my earlier description of the PORT event for more information.
    You will also need to increase the GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS define to match the number of low-accuracy enabled pins.

    Best regards,
    Karl

Related