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
Bookmarks