Quote Originally Posted by Darrel Taylor View Post
The configs look OK.

The PORTB.0 read looks OK.

In my test, I did not have an MCP23016 connected, I was just testing the clk frequency with I2CWRITE at 48mhz. The MCP23016 is a 400khz device, so 250khz should not be a problem.

The i2cdevice and I2Creg variables weren't shown. Are they both BYTEs?
I assume they are, just asking.

The only other possibility I can see is that the registers are configured as "Pairs", and all examples in the datasheet show reading or writing 2-bytes of data at a time. I don't see anything that says you can't read only 1-byte at a time, but then there's nothing that says you can either.

So this is my last best guess...
Try doing everything with 2 data bytes.
Code:
I2CWrite SDA,SCL,i2cdevice,I2Creg,[i2cbyte1, i2cbyte2],error
If the address is for GP0 ($0), then i2cbyte1 should have GP0 and i2cbyte2 should have GP1.

If the address is for GP1 ($1), then they will be reversed. GP1 in i2cbyte1 and GP0 in i2cbyte2.

Both write and reads would need 2-bytes.
And be sure to cycle power after changing it, in case it's still locked up.

hth
Thank you Darrel, thank you indeed
You are a real and great PIC wizard!

You have made me extremely happy...

...have been struggling with this problem too long, I'm very happy that it is solved "so easily", meaning that the error here was almost close to a syntax error.

Who could have guessed in the first place that you need to read/write both data registers to get it working. Is this said somewhere in the data sheet? If so, it has not caught my eye.

This does slightly complicate the code for me, it would have been very handy if one could read the ports separately, but no big deal, not a real problem...

THANK YOU again for helping me out of my desperate situation with this "strange" MCP23016 behavior...