hi,
could someone please advice me how to setup the mcp230217 correctly?
i do have multiple MCPs connected in a row. if i use the code below, i can switch all pins/banks to inputs, and it works great.
this part is mostly from nick gammon, it sets all bank as input
// expander configuration register
ic2_mcp_write_both (MCPAdr, Mcp_Reg_IOCON, 0b01100000); // mirror interrupts, disable sequential mode
// enable pull-up on switches
ic2_mcp_write_both (MCPAdr, Mcp_Reg_GPPUA, 0xFF); // pull-up resistor for switch - both ports
// invert polarity
ic2_mcp_write_both (MCPAdr, Mcp_Reg_IOPOLA, 0xFF); // invert polarity of signal - both ports
// enable all interrupts
ic2_mcp_write_both (MCPAdr, Mcp_Reg_GPINTENA, 0xFF); // enable interrupts - both ports
but what i want is i.e.
-
mcp1 ->
-
bank A = output,
-
bank B = output
-
mcp2 ->
-
bank A = input,
-
bank B = input
-
mcp3 ->
-
bank A = output,
-
bank B = input
-
mcp4 ->
-
bank A 0-3 = output 4-7 = input,
-
bank B 0-3 = input 4-7 = output
All interrupts should be mirrored. and set to open-drain (ODR=1)
i think 'sequential mode' has to be disabled.
all inputs should be active-low.
i want to access the banks and ports via "one-side-reading or -writing", the code above shows "write_both" but i want to write to i.e. only bank A and set a Pin to 1 or 0.
the values to the above functions for the registers should be in decimal, not hex or binary - only the values.
second questions, how do i manipulate later on the single pin for an output to set them to 1 or 0?
best regards.