MCP23017 Library Port

I have tested around with the MCP23017 and like to share my experiences.

I figured out that the MCP Interrupt Register must be read to recognize interrupts correct. That means after the initialisation of the MCP and after the interrupt occured it must be cleared with mcp.readGPIOAB().
I added a functional example here (thank you @peekay123 for the inspiration) .

The corresponding description is in the datasheet:

The interrupt will remain active until the INTCAP or GPIO register is read. Writing to these registers will not affect the interrupt. The interrupt condition will be cleared after the LSb of the data is clocked out during a read command of GPIO or INTCAP.
The first interrupt event will cause the port contents to be copied into the INTCAP register. Subsequent interrupt conditions on the port will not cause an interrupt to occur as long as the interrupt is not cleared by a read of INTCAP or GPIO.

2 Likes