I just got my Pyboard and have been putting it through some tests. I need to know the following:
1. Is it possible to tell the interrupt type (rising or falling) inside of an ISR that is set to trigger on both a rising and falling signal?
2. Or, is it possible to set up multiple callbacks for the same pin, one for a rising edge and another for a falling?
I need to do something different based upon if the interrupt occurs on a rising to falling signal.
Thanks!
David
detect interrupt type in ISR?
Re: detect interrupt type in ISR?
I'm not aware of anyway of detecting this. What I do is query the gpio value to figure that out (not perfect, but the best I've been able to figure out for now). See: https://github.com/dhylands/upy-example ... ic_test.pydwculp wrote:I just got my Pyboard and have been putting it through some tests. I need to know the following:
1. Is it possible to tell the interrupt type (rising or falling) inside of an ISR that is set to trigger on both a rising and falling signal?
That's not possible (at least not on the pyboard).dwculp wrote:2. Or, is it possible to set up multiple callbacks for the same pin, one for a rising edge and another for a falling?
If it's a clean signal, then reading the GPIO is probably the best way. If it's a push button, then you'll need to add debouncing as well.dwculp wrote:I need to do something different based upon if the interrupt occurs on a rising to falling signal.
Re: detect interrupt type in ISR?
Thanks for the reply! I was actually looking at the value of the pin inside the ISR but it was not working as expected. Essentially I wanted to set up a simple ISR that turned an LED on if the switch was down, and turn it off upon releasing the switch. It was not working as expected.
I finally figured it out....................I was looking at the wrong pin inside the ISR due to a typo
It works as expected now after a few hours of frustration and then changing one character
I finally figured it out....................I was looking at the wrong pin inside the ISR due to a typo
It works as expected now after a few hours of frustration and then changing one character
Re: detect interrupt type in ISR?
Also beware that a switch can have a very noisy signal, so pressing or releasing a switch can cause multiple edges.
http://www.ganssle.com/debouncing.htm
http://www.ganssle.com/debouncing-pt2.htm
The switch on the pyboard isn't too bad, and most of the time I'll just get 2 edges, but occasionally, I'll get several.
http://www.ganssle.com/debouncing.htm
http://www.ganssle.com/debouncing-pt2.htm
The switch on the pyboard isn't too bad, and most of the time I'll just get 2 edges, but occasionally, I'll get several.
Re: detect interrupt type in ISR?
Yep, I properly debounced it.
I have to say, this is one of the cooler little devices I have played with. I plan to turn it into a general purpose robotics controller for small mobile robots and let my students experiment with them.
I have to say, this is one of the cooler little devices I have played with. I plan to turn it into a general purpose robotics controller for small mobile robots and let my students experiment with them.