-
Notifications
You must be signed in to change notification settings - Fork 205
Interrupt example is bad #58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Yah, the MCP really only supports LOW/HIGH and not RISING/FALLING, since you can't clear the interrupt in that mode. It's a simple assert-if-comparison-true logic: The changes in #64 include switching to LOW/HIGH. |
Please checkout the new 2.0.0 release: |
Thank you for the announcement. The interrupt example is different, but is now good? |
What would you suggest? The example can be updated. Idea with current one is it's very simple - just shows how to generally configure the INTA/B pin to fire. |
Closing due to lack of response. Can reopen if needed. Not really a library issue, just commentary about existing example. |
The example can be updated with an interrupt service routine so that it is more useful to general folks. |
I have spend the day with the interrupt example and now i finally know whats the problem is.
In the example the commando is used:
mcp.setupInterruptPin(pin,FALLEN);
This is really bad. The correct mode in this example is "CHANGE".
FALLING or RISING modes will not work with this code without instabilities.
What i see, is that with CHANGE a interrupt goes active with a change of the pin and the interrupt can be reset with readGPIOAB();
With FALLING it is different, The interrupt goes aktive when the pin goes LOW AND the interrupt STAYS active as long as the pin is low.
While the pin is low the interrupt signal can't be reset !!!.
This solved in the code by looping until the pin (or button) is released.
This has as consequent that the code will hang ( no loop () ) until the user releases the button.
It would be nice that the examples have a standard that they always loop().
The text was updated successfully, but these errors were encountered: