Hi there.
I have a really nasty problem with using a 4x4 matrix keypad with the
mcp23008 GPIO expander, using the specific
AN1081 application note, and I feel like an idiot.
I build the circuit as suggested, ie I have 4 pullups (2.2k) on the row pins (which are gpio 7 to 4) and no pullups to the 0-3 pins which are connected to the columns of the matrix.
Using the scope I found out that the configuraiton bits are set fine by the MCU and the custom library works fine.
Basically what happens is this:
I start with the exact values for the mcp23008 registers as the one shown in table 1, page 4 of the AN. This means having set the row pins as inputs and the column input as outputs, as well as the interrupt registers. One thing that confuses me a bit is that the GPPU register, which represents the internal pullups of the component is set for the columns but they nevertheless read 0 as value (probably because they're outputs).
Anyway, then I press the key. The interrupt gets correctly raised and I'm able, from the arduino, to read back the GPIO values. I am thus able to read which row has a pressed key inside of it.
Now comes the tricky part. As per page 9 of the application note, I need to switch the values of some registers: IO DIRection, and the interrupt ones. The situation
should look like as table 3 on page 6
but probing columns and rows I was able to determine that, as soon as I send the write command for the IODIR register, with flipped bits, both of the row and column pins are set back to 1, instead of being both 0. So I am not able to detect to which column the pressed key belongs.
I tried this many times, with different keys and the same result. I actually probed the connections (checking for continuity when a key was pressed) and had no luck there.
Is there anything I am missing? Is there anyway I can help you help me.
Thanks a lot for anyone reading this.
Cheers