3 Replies Latest reply on Jul 28, 2015 3:30 PM by PabloM_Intel

    Multiple MCU interrupt handlers on single GPIO?

    MSvaal

      Hello,

      I am trying to generate an interrupt on the Edison MCU whenever the state of a GPIO changes. The API seems to provide mode flags for an interrupt on a rising or falling edge, but not both. I tried testing registering two ISRs to the same pin, one with each mode flag, but it doesn't seem to work. When connecting a debug session, I receive the message:

       

      "E     invalid int mode for share irq: 128"

       

      Also, I only receive debug_print messages from the first of the two registered ISRs. Is it possible to handle a rising and falling interrupt on the same GPIO, or will I have to use two pins?

       

      Thanks,

      Matt

        • 1. Re: Multiple MCU interrupt handlers on single GPIO?
          szirin

          The MCU firmware currently supports setting either a rising-edge interrupt or a falling-edge interrupt for a given GPIO, but not both simultaneously.  Your 2nd call to gpio_register_interrupt() triggered the message "E    invalid int mode for share irq: 128" you saw in the debug error log and returned a non-zero error status that your application did not check.

           

          Detecting both rising and falling edges will require two GPIO inputs.

          • 2. Re: Multiple MCU interrupt handlers on single GPIO?
            MSvaal

            Thanks for the reply. The error message was from registering the second ISR on the same pin as you said.

             

            However, further testing shows that when configuring a falling-edge interrupt on a GPIO, that interrupt is in fact triggered on both rising and falling edges. I'm not sure if this is the intended functionality or not, but I have verified this behavior by putting the input signal on an oscilloscope.

             

            I have attached the code I am using. The external device is a 90 ppr quadrature encoder, so I am reading edges of two signals offset in phase by about 90 degrees. The ISRs are getting hit on both rising and falling edges.

             

            Also, it seems that this very simple program I am running is suffering from terrible interrupt performance. When I limit the number of interrupts to ~20-30 per second, none are missed, but I was hoping to track the encoder position at 500+ edges per second. I thought the 100 MHz MCU would have no trouble with this, but am I mistaken? Is there a more efficient way to handle this task?

             

            Thanks,

            Matt

            • 3. Re: Multiple MCU interrupt handlers on single GPIO?
              PabloM_Intel

              Hi MSvaal,

               

              Given that your original question about interrupt handlers on a single GPIO was already answered here, and your second question about the MCU interrupt performance has been answered in this other thread Edison MCU interrupt performance, we will continue with the support in your other thread. If you have any other question about the MCU interrupt performance, you can post it there.

               

              Regards,

              PabloM_Intel