• Nice pic of the schematics!

    I assume you are not connecting A0..A2 to anything and are thus setting HAEN - Hardware Address Enable - bit to 0 in control byte. (This feature allows you to address 8 PortExpanders (hard-wired, and even more, 'soft-wired').

    setup the expander's interrupt pin... by writing via I2C?

    That's correct. You write to the control/config registers of the PortExpander. They are listed on p12 of the datasheet: TABLE 3-1: REGISTER ADDRESSES.

    This is for creating in interrupt when ever the value changes on an input pin:

    • 3.5.1 I/O DIRECTION REGISTER (p18): declare 4 pins as output, 4 as input (register address 0, value 7)
    • 3.5.3 INTERRUPT-ON-CHANGE CONTROL REGISTER (p19): declare 'interrupt on change' for the input pins (register address 2, value 7)
    • 3.5.5 INTERRUPT CONTROL REGISTER (p20): declare '*interrupt on change compared with previous value' for the input pins (register address 4, value 0)
    • 3.5.6 CONFIGURATION REGISTER (p20): (register 5). I would start with value 0. Since this resets bit 1, the watch has to be on falling edge.
    • 3.5.7 PULL-UP RESISTOR CONFIGURATION REGISTER (p22): declare 'pull-up' for the input pins (register address 6, value 7). This means, that you have to write all 0 to the output pins. When a button is pressed, the input changes state to low. The scan has then to set only one after the other to low to figure out the pressed button's col.

    Have fun... (now you may understand why a generic module would be ginormous and practically just an unnecessary repetition of what a direct config already is).

About

Avatar for allObjects @allObjects started