0
\$\begingroup\$

I am having issues with interrupt setup on MCP23S17. Not able to set up the INTB line properly. I have an external 10K pull up resistor connected to the line and 3 input buttons connected to GPB0 - GPB2.

I tried setting the INT line as Open Drain. Still I read 0 on INTB. Also tried setting up the line as Push Pull with Active Low interrupt polarity. Still get a 0.

I am able to control GPA as an output port just fine.

Below is my code

#define MCP23S17_OPCODE_WRITE   0x40
#define MCP23S17_OPCODE_READ    0x41

#define MCP23S17_IOCONA     0x0A
#define MCP23S17_IOCONB     0x0B

#define MCP23S17_IODIRA     0x00
#define MCP23S17_IODIRB     0x01

#define MCP23S17_GPIOA      0x12
#define MCP23S17_GPIOB      0x13

#define MCP23S17_OLATA      0x14
#define MCP23S17_OLATB      0x15

#define MCP23S17_GPINTENB   0x05
#define MCP23S17_DEFVALB    0x07
#define MCP23S17_INTCONB    0x09
#define MCP23S17_INTFB      0x0f




void EXTERNAL_MCP23S17_Init(void)
{   
//IOCONA (DEFAULT)
//SET MIRROR = 0
s_external_mcp23s17_write_reg(MCP23S17_IOCONA, 0x00);

//IOCONB
//SET MIRROR = 0
//SET ODR = 1 (INTB PIN IN AS OPEN DRAIN MODE)
s_external_mcp23s17_write_reg(MCP23S17_IOCONB, 0x04);

//SET GPA AS OUTPUT
s_external_mcp23s17_write_reg(MCP23S17_IODIRA, 0x00);

//SET GPB AS INPUT (DEFAULT)
s_external_mcp23s17_write_reg(MCP23S17_IODIRB, 0x07);

//SET GPOA INITIAL VALUES
s_external_mcp23s17_write_reg(MCP23S17_GPIOA, 0x27);
s_external_mcp23s17_write_reg(MCP23S17_OLATA, 0x27);

//ENABLE INTERRUPT ON CHANGE FOR GPB0 - GPB2
s_external_mcp23s17_write_reg(MCP23S17_GPINTENB, 0x07);
//SET GPB DEFAULT COMPARE REGISTER FOR INTERRUPTS
s_external_mcp23s17_write_reg(MCP23S17_DEFVALB, 0xFF);
//SET GPB INTERRUPT CONTROL REGISTER
//COMPARE PIN VALUE AGAINST DEFAULT VALUE
s_external_mcp23s17_write_reg(MCP23S17_INTCONB, 0xFF);
SEGGER_RTT_printf(0, MODULE_NAME_EXTERNAL_MCP23S17"%s OK\n", __FUNCTION__);
}

Not sure what I am missing here. Have checked the datasheet and I don't think I've missed anything

\$\endgroup\$
0
\$\begingroup\$

Constant 0 on INTB pin means that the interrupt is active (in both configurations, active-low push-pull and open-drain).

It is not clear where do you have 10k resistor, on INTB pin or on GPB0 - GPB2 pins. If you don't have external pull-ups on GPB pins, you should enable internal pull-ups through GPPU register.

You should also clear the interrupt by reading INTCAP or GPIO register.

The interrupt remains active until the INTCAP or GPIO register is read.

3.6.4 INTERRUPT OPERATION

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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