EmbDev.net

Forum: µC & Digital Electronics configure INTA and INTB on MCP23017 using cmd call i2cset


von Tbd (ids2001)


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

von wendelsberg (Guest)



Rate this post
useful
not useful
Dieter S. wrote:
> Device has an I2C address like: 0x20

The base address (opcode) of the MCP23017 is 0x40, not 0x20.

wendelsberg

von Tbd (ids2001)


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

von Dr. MCU (Guest)


Rate this post
useful
not useful
wendelsberg wrote:
> Dieter S. wrote:
>> Device has an I2C address like: 0x20
>
> The base address (opcode) of the MCP23017 is 0x40, not 0x20.
>
> wendelsberg

Bullshit, as you can see in your image. The address is 0x20-0x27.

von Tbd (ids2001)


Rate this post
useful
not useful
oh little boy dont be like a diva :)

von Veit D. (devil-elec)


Attached files:

Rate this post
useful
not useful
Hello,

you surely want the pin change interrupt. I can't see any difference to 
my code for now.

delete INTCON
set INTEN

Does your I2C code for the bus work at all?

An excerpt of my lib. I do not do it differently.

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.