I'm building a teensy 4.1-based drum machine. It's got quite a few buttons and LEDs so I'm using a few i2c MCP23017 to offload the I/O. It took me WAAAAY too long to get the Teensy 4.1 working with the MCP23017 using interrupts. I had a really hard time finding code examples, especially working out the magic sequence of code that makes the MCP23017 interrupt reset after triggered/processed. There was a bit of discussion on these pjrc forums about it, but nothing that "just worked". Now that I've got it working with and without interrupts I figured I'd make a quick post here. Maybe it will save a future googler the hours I spent figuring out what surely has already been figured out.
Here are my example projects:
Without interrupts: https://github.com/nshaver/teensy_mcp23017_no_interrupts
Using interrupts: https://github.com/nshaver/teensy_mcp23017_interrupts
If anyone notices that my "using interrupts" version has any bugs or sees things that coule be improved - feel free to reply here so I'll know. As far as I can tell, it runs very fast and stable. I haven't finished this project yet though. I'll have more confidence in it after the drum machine runs for 24 hours without getting glitchy.
Here are my example projects:
Without interrupts: https://github.com/nshaver/teensy_mcp23017_no_interrupts
Using interrupts: https://github.com/nshaver/teensy_mcp23017_interrupts
If anyone notices that my "using interrupts" version has any bugs or sees things that coule be improved - feel free to reply here so I'll know. As far as I can tell, it runs very fast and stable. I haven't finished this project yet though. I'll have more confidence in it after the drum machine runs for 24 hours without getting glitchy.