This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Button via GPIO?

Anonymous
Anonymous


Hi All,

I would like to ask an elementary question relates to GPIO.

  1. How does the software handle button clicks? Should buttons be routed to GPIO, and then the software responds to GPIO triggered interrupts?
  2. If GPIO interrupts are needed, then do I have to configure the edge detection logic
  3. Or is it possible to use polling?

 

Sincerely,

Zheng

  • Zheng,

    Buttons is actually a fairly complex issue in general and depends very much on what your actual abjective is.

    What I mean here is that if response time is critical then you should use interrupts. This would then require you to add de-bouncing code to your interrupt routine.

    If response time is not critical then you can poll the GPIO. This has the advantage that de-bouncing is not as critical since it is effectively deon by the delay in reading the GPIO. This method does, however, give non-periodic checking times since it is dependent on how often your code checks the GPIOs.

    One method which is a mix of the two is to have a periodic interrupt to read the GPIO. This will both de-bounce and give truly periodic checking. With this you could then either simply report the measured button states to your application through a variable or trigger an additional processing interrupt routine to act on your buttons.

    Hope this helps a little.

    BR,

    Steve

  • Anonymous
    0 Anonymous in reply to Steve Clynes

    Dear Steve,

    Many thanks for the answer. I shall study this.

     

    Zheng