I2C question w/ MCP23017 Port Expanders
i am working on a project w/ 5 ea MCP23017 16 bit I2C port expanders
the expander chips are spread across 4 different pcbs and are reading switches and driving status leds
i have things working pretty well but there is a mystery which i hope someone can help me chase down
conditions:
PBP is v2.60, PM is 4.08
PIC is 16F819
20MHz ext cer res (running fine)
using the I2CREAD and I2CWRITE commands
pins chosen are the SDA and SCL hardware pins just in case i want to use the hardware I2C some day
very weak pullups are at each port chip, 100K, the primary 10K pullups are at the source (not ideal i know but the runs are short)
the mystery:
('3' and '4' below refer to the I2C address in decimal, 'A' & 'B' refer to the two 8 bit ports on the chip)
PORT3B & 3A (expander port chip) is on pcb1, PIC is on pcb1 also
PORT4B & 4A (expander port chip) is on pcb2
when i read and write to 3A and/or 3B pcb1 everything is happy,
when i add a line to write to 4B then the data on 3A gets scrambled, the added line is directly after the 3A Write and simply mimics the action on 3A on another port on another board with different bit polarities and bit positions
if i REM the 4B I2CWRITE line all is well again
i beat my head on this for quite a while (no I2C monitor at hand) and then FINALLY connected pcb2 (it had been disconnected prior) and then suddenly both 3 & 4 worked correctly !
it has been my prior experience that with I2CREAD and I2CWRITE that you could do this 'open loop', i.e. if no slave chip was present the program would march on it's merry way without issues
although it is working once connected i am not comfortable proceeding without getting to the bottom of this
any thoughts or tips much appreciated, i hope this was clear
Re: I2C question w/ MCP23017 Port Expanders
your pull-up are far to be correct... at slow speed they need to be 4.7K or so... around 1.8k at higher speed.
Begin with it.
Re: I2C question w/ MCP23017 Port Expanders
thanks mister_e,
i will give that a try but i have never had much sensitivity to their value on other projects, will report back
my suspicion is that when pcb2 is not connected the lack of response after writing to it has something to do with the issue
Re: I2C question w/ MCP23017 Port Expanders
The I2C protocol shouldn't work open loop. The slave must send an ACK after each byte that is written. I would be very surprised if the PBP routines for I2C were written in a way that did not wait for the slave ACK.
Re: I2C question w/ MCP23017 Port Expanders
Hi Steve
my understanding is that if there is an error with the ACK the program can jump to a location specified by an optional LABEL, if the optional LABEL is not given then the error is ignored
are there examples here somewhere how to use the on chip hardware for I2C ?
Re: I2C question w/ MCP23017 Port Expanders