configure INTA and INTB on MCP23017 using cmd call i2cset

OP #6606972
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
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

A question of your own? This thread is over 5 years old. Ask it in a thread of its own – more people read along there, and it gets answered more often and sooner.

Start a new thread

A fix, an addition or feedback on this thread? Then reply here.

Formatting
  • [c]C-Code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.