4 Replies Latest reply on Apr 22, 2016 4:40 AM by arfoll

    Interrupt Priority

    lyfkyle

      Hi,

       

      Can Intel Edison handle multiple interrupts at the same time? if yes, how do I set the priorities?

      For example, I have:

      mraa_gpio_isr(gpio1, MRAA_GPIO_EDGE_RISING, &interruptHandler1, p1);

      mraa_gpio_isr(gpio2, MRAA_GPIO_EDGE_RISING, &interruptHandler2, p2);

      mraa_gpio_isr(gpio3, MRAA_GPIO_EDGE_RISING, &interruptHandler3, p3);

      What will happen if interrupt2 occurs when InterruptHandler1 is executing?

      Thank you very much in advance. I am quite new to Intel Edison and embedded systems, so forgive me if the answer is obvious.

       

      Best Regards

      lyfkyle

        • 1. Re: Interrupt Priority
          Intel Corporation
          This message was posted on behalf of Intel Corporation

          Hello lyfkyle,

          I have tested scripts that used more than one interrupt, however I would not recommend to activate them at the same time to avoid issues on the code. However, the documentation found in http://iotdk.intel.com/docs/master/mraa/classmraa_1_1_gpio.html does not mention if Edison can set priority for an interrupt above another.

          arfoll, what do you think? Am I missing something?

          Peter.

          • 2. Re: Interrupt Priority
            Vincenze

            The Linux kernel can handle multiple parallel interrupts coming from different GPIOs.

            I don't know about mraa. I think it launches multiple threads that listen to interrupts independently.

             

            There are usually two other problems if you connect a button and handle interrupts when the button is pushed.

            1. You want to quickly handle multiple subsequent button pushes. Then the interrupt handler must be very short. It should set a flag and exit, then the main program should do something when the flag is set.

            2. Button debouncing. One button push can trigger multiple interrupts. After the first interrupt, other interrupts should be ignored for the predefined amount of time like 50ms.

            • 3. Re: Interrupt Priority
              lyfkyle

              Hi Peter:

               

              Thank you for your input.

              However, I am afraid it is not a choice for me to activate only one interrupt at a time in my application because I have no idea which interrupt will come first. For Arduino, I believe that it can handle only one interrupt at a time meaning other interrupts will be ignored when one is executing. This is fine for me actually. I am just concerned whether some unexpected behaviour will happen on Intel Edison if such an incident happens.

              Thank you very much.

               

              lyfkyle

              • 4. Re: Interrupt Priority
                arfoll

                lyfkyle a 'real' arduino will behave as you say. Mraa is capable of calling your interrupt handlers at the same time, there's no blocking there unless you're in a high level language like node.js or python where each interrupt will be executed whilst the main interpreter thread is locked. There's no issue with interrupt2 occurring when InterruptHandler1 and you even be executing your ISRs at the same time.

                 

                Vincenze kernel does support this but there's no userspace API to do it (at least I haven't found a good way), multiple threads works well and costs very little since they essentially get woken by the interrupt.

                1. Subsequent pushes of the same button/gpio then yes you need to get in/out of ISR fast. For multiple GPIOs no, you can be slow. But remember userspace Linux cannot give guarantees on how fast we will treat the ISR so performance can be v.variable.

                2. We're way too slow to notice that. Kernel drivers typically have denouncing protection anyways and if you're really worried just hog the ISR thread with a sleep.

                1 of 1 people found this helpful