5 Replies Latest reply on Jan 24, 2019 2:48 AM by BragadeeshV_41

    GPIO interrupt on any edge


      I know that this question has been asked previously, but the answers I've seen either don't quite apply to my problem.  I have a design with three switches. Each switch has an individual Pin component in my design.


      I would prefer to not have to rewrite the code to handle with these switches connected to multiple digital inputs in a single Pin component.


      The documentation for the Pin component talks about how I can use the dedicated interrupt checkbox to get a single interrupt for the entire port.  I don't want that, since I want one interrupt per pin, so I uncheck that.  I then set the Interrupt dropdown to "Both edges":


      I then connect an Interrupt component to each of the pins with InterruptType set to "Derived".

      Based on the (incomplete) documentation, I would expect these settings to generate an interrupt on both rising and falling edges of the input signals.  However, I only get interrupts on rising edges.  Does the Interrupt setting on the Input tab in the Pins component not actually work if the Dedicated interrupt checkbox is not checked?  I would expect it to still work since unchecking the checkbox doesn't disable the Interrupt dropdown.


      So, how can I make this work?

        • 1. Re: GPIO interrupt on any edge



          There are two possible ways an GPIO interrupt can be routed:

          1. Fixed function route

          2. DSI route


          To use the fixed function route, you to need use the dedicated port interrupt check box (in the input tab of the pins component). The fixed function route has a Edge detect circuit that can detect both the rising and falling. But this will generate only one interrupt per port. To find out which pin caused the interrupt, you need to use the return value of Pin_ClearInterrupt(). This will return you the exact pin that caused the interrupt.


          Note: Usually the fixed function route is always level triggered. But the GPIO has additional circuitry that includes a Edge detect circuit.


          When you use the DSI route (the one you have used), there are two ways:

          1. Bypass the Edge trigger block via DSI - So only level trigger

          2. Through the “GPIO Edge Detect” block and to the interrupt source multiplexer via DSI 


          Note: The 2nd option only has rising edge option. That is why you were only able to detect the rising edges.


          Therefore to detect both the edges:

          1. You need to check the dedicated port interrupt check box

          2. Select the interrupt types as both edges

          3. Connect the ISR component to this dedicated path

          4. Choose derived option in the interrupt type


          We have added the schematic image of the DSI path and Fixed function path below:



          Please let us know in case you need further clarifications.




          • 2. Re: GPIO interrupt on any edge

            So what does it mean when the Interrupt dropdown is set to "Both" and the "Dedicated interrupt" checkbox is unchecked?

            • 3. Re: GPIO interrupt on any edge



              When the DSI channel is selected, it can have only level or rising edge interrupt. (ie) when the Interrupt drop down is set to "Both" and the "Dedicated interrupt" checkbox is unchecked, it configures as only rising edge since the route has only rising edge detect circuit, it can't detect falling edges.


              Please let us know in case of further clarifications.




              • 4. Re: GPIO interrupt on any edge

                So the configuration page incorrectly allows the user to select "both" when it is not, in fact both?  Sounds like the dropdown should be disabled and set to "rising" any time the "dedicated" checkbox is unchecked?

                • 5. Re: GPIO interrupt on any edge



                  There is one more way to generate port interrupts (Fixed function interrupts with trigger on both edges) using the Combined port interrupt option in the Global Signal Reference.


                  To do this, follow these steps:


                  1. Set the interrupt type in the Input tab of pins component.

                  Note: Dedicated interrupt is not checked


                  2.  Choose combined port interrupt option in the Global signal name in Global signal component. This will trigger whenever any pin or port triggers an interrupt.


                  3. Connect an ISR component to the global signal component and configure the type as derived.


                  This settings will lead to a dedicated port interrupt that can generate interrupts on both edges of the signal.


                  Note: PSoC 4 Combined port interrupt signal will trigger an interrupt whenever there is a trigger in any pin of any port. We need to find the exact pin that caused the interrupt in the interrupt handler.


                  We kindly request you to refer the I/o subsystems chapter  - Interuppt sections and the interrupts chapter in the device architecture TRM for your reference.


                  Please let us know if you have any further clarifications.