Problem with 500 Hz signal detection with interrupt



  • Hi guys, this is Carlo.
    I'm developing a java application with pi4j 1.1 and raspberry pi zero w. I have external hardware that sends to a raspberry a square signal at 500Hz.
    My problem is that with interrupt I don't detect any pin edge event variation. Instead, if I read a signal in a loop cycle I can read that the signal is low and then high.
    My interrupt code is this:

       InputOutputManager.getInstance().getSpi_cs().addListener(new GpioPinListenerDigital() {
            @Override
            public void handleGpioPinDigitalStateChangeEvent(GpioPinDigitalStateChangeEvent event) {
                  if(event.getEdge().equals(PinEdge.FALLING) )    {  
                      System.out.println("F");
                  }
            }
        });
        
        InputOutputManager.getInstance().getSpi_cs().addListener(new GpioPinListenerDigital() {
            @Override
            public void handleGpioPinDigitalStateChangeEvent(GpioPinDigitalStateChangeEvent event) {
                  if(event.getEdge().equals(PinEdge.RISING) )    {  
                      System.out.println("R");
                  }
            }
        });
    

    My loop code instead is this:

     if(InputOutputManager.getInstance().getSpi_cs().getState().isHigh())    {
           System.out.println("H");
      }
      else    {     
          System.out.println("L");
      }
    

    If I physically connect the interrupt input with ground I read "F", when I physically connect the interrupt input with 3,3V I read "R". So the interrupt works good.
    So my question is: why with interrupt I can't detect FALLING and RISING events from the 500Hz signal?

    thanks to everyone


  • Contributor

    @carlucio24

    Sorry for the delayed response. Did you find a solution to this?


Log in to reply