configure INTA and INTB on MCP23017 using cmd call i2cset

OP #6606972
Rate this post
useful
not useful
I am struggling to configure my MCP23017 with pure cmd line calls from 
i2cset and i2cget on the lastest Raspberry Pi 4.

Since this is an requirement to use pure cmd line calls, neither C or 
Python or whatever API is allowed.

What I have done so far:

Device has an I2C address like: 0x20
1
i2cset -y 1 0x20 0x00 0xff
2
Set all pins from PORT A to inputs. 
3
i2cset -y 1 0x20 0x02 0xff     
4
enabled it for all pins
5
i2cset -y 1 0x20 0x03 0x00     
6
set the default compare register to 0 because I want to trigger an INT if value changes to 1 on input pins
7
i2cset -y 1 0x20 0x04 0x00     
8
mhmm I am bit lost already - would think that this must also bei 0x00 for all pins?!

BUT if I change the logical level on the pins from PORT A (all pins are 
set to active low by external resistor) from LOW to HIGH (and vice 
versa) nothing is happening.

I don't know why - has anyone an idea what I am doing wrong here?

Many thanks
Cheers Dieter
OP #6635757
Rate this post
useful
not useful
I got it working couple of hours after I wrote the first thread.
1
#!/bin/bash
2
deviceAddr=0x20 #I2C device address
3
GPINTENA=0x04   # Port A interrupt register.
4
DEFVALA=0x06    # Port A default values.
5
INTCONA=0x08    # Port A interrupt control.
6

7
i2cset -y 1 $deviceAddr $DEFVALA 0x00 
8
sleep 0.5
9
i2cset -y 1 $deviceAddr $INTCONA 0x00 
10
sleep 0.5
11
i2cset -y 1 $deviceAddr $GPINTENA 0xff  
12
sleep 0.5

Reply

Please log in before posting.

or

Log in with Google account

Registration is free and takes only a minute.

Register now