0
\$\begingroup\$

trying to enable INT on MCP23017 so that, in case of a state change on any PIN from Port A (e.g from low to high) an interrupt should be triggered on INTA.

Unfortunately the INTA pin remains high as long the pin on port A is high. So I can not clear the INTA pin

What I have done so far. Requirement is to use pure CMD and no framework for it. I took i2cset and i2cget tools from raspberry pi 4. wrote a simple script for configuration and added an oscilloscope to INTA.

#!/bin/bash
i2cset -y 1 0x20 0x00 0xff # all ports bank A to inputs
sleep 0.5
i2cset -y 1 0x20 0x0a 0x02 # set Bit 1(INTPOL) to HIGH
sleep 0.5
i2cset -y 1 0x20 0x08 0xff # set Bit 1(INTCONA) to HIGH
sleep 0.5
i2cset -y 1 0x20 0x04 0xff # High on all pins to enable all pins to interrupt on a change of polarity (i.e switch change)

After executing the code, the level on INTA is low. Adding a high level via cable (so connecting +3.3V to any pin of the port A ==> all pins are wired via 10k to GND) to a pin of PORT A triggers a high level signal on INTA. It goes back to low if also the high level on the pin from PORT A disapears. No way of resetting (clearing) the interrupt via CMD like i2cget -y 1 0x20 0x10 # ==> this is always showing the pin who was triggering the INT or i2cget -y 1 0x20 0x12 # ==> this is always showing the right state of the inputs (so which pin is high and which is low... )

Any ideas what's wrong?


I am using IOCON.BANK = 0 therefore IOCON Register for Port A should be according to table 3-5 IOCON Address=0x0a. According to datasheet the bit 1 should be set to 1 or 0.

In my top post I think I must have a bug.

i2cset -y 1 0x20 0x0a 0x02 # set Bit 1(INTPOL) to HIGH

I must set it instead of 0x02 to 0x01 but how can I define to set exactly the bit 1 to value 1?

i2cset -y 1 0x20 0x0a 0x01 1 # ????? that does not work :-(
\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

Have you setup the IOCON register (address 0x05)?

The default is that the interrupt output is active low - INT being high means it is already cleared.

MCP23017 daatsheet

\$\endgroup\$
2
  • 1
    \$\begingroup\$ see my answer (new posting) below \$\endgroup\$
    – D.S
    Mar 3, 2021 at 22:27
  • 1
    \$\begingroup\$ @D.S - Hi, Your "answer" (which wasn't an answer to your original question, and therefore should not have been posted in the "Your Answer" box) has been added to the question as an edit i.e. an update. Unless you are writing the full answer to your own question (i.e. you have solved the problem yourself, with no further help needed), please don't use the "Your Answer" box below. Thanks! \$\endgroup\$
    – SamGibson
    Mar 4, 2021 at 1:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.