I could get the MCP23016 to work reliably only by removing the timing capacitor (33pF) all together.
I could get the MCP23016 to work reliably only by removing the timing capacitor (33pF) all together.
Thanks Eggman!
When I removed that capacitor the program goes to the error-label, so that does not solve my problem![]()
I soldered a new 33pF on the PCB and got rid of the error label jump but the original problem remains...
I'm puzzled, I do not know what I should try next!
Any other suggestions?
Since you are using an 18F4550, it means you are using MPASM as the assembler.
So, DEFINE i2c_hold 1 needs to be Uppercase.
Not sure what you mean here. The INTCAP? registers are read-only.You can read back every register except one (INTCAP). I do not know what fails, read or write
Also not sure what you are trying to do with the port.
You write all 1's to the output latch OLAT1, then set all but 1 pin to input IODIR1, then write to GP1 which actually writes to OLAT1 again. Doesn't make sense.
What is it you're trying to do, and what's not working.
DT
Thank you Darrel!
I changed it, so now I have DEFINE I2C_HOLD 1...
but that did not change anything.
With INTCAP I just wanted to say that it is the only register that is read-only, besides it was kind of irrelevant from me to mention that in the first place
The final goal is to use the device as an input extender, that is only inputs. However, one should also be able to read and write all registers, except one. Nothing seems to work, as earlier told, I can't tell if it is the write or read that fails. I have tried all kind of values and also changing the sequence of those three initializing lines but without any sign of life. Well, of course maybe some kind of quiet life when not the error label is activated.
What values would you suggest to use in the initialization section and what sequence would you use for those three init lines?
I think it's probably working, but you don't realize it.
In your code, the only thing you're reading is GP1, and prior to that it writes to GP1, so you're thinking you should read the same value back.
But when you write to GP1, the value is actually written to OLAT1.
Reading GP1 reads the state of the pins, not what was written to GP1.
<br>
DT
Thanks, I really hoped you were right, but sorry...
I tested it with the following code:
Loop:
I2Creg = OLAT1 : I2Cbyte = $ff : gosub writeioextender: pause 20
I2Creg = IODIR1 : I2Cbyte = $ff : gosub writeioextender: pause 20
I2Creg = olat1 : gosub readioextender: pause 20
LCDOUT hex2 ioebyte, " "
I2Creg = gp1 : gosub readioextender: pause 20
LCDOUT hex2 ioebyte, cmd,home1
if onoffpressed = 1 then powerout = 0
goto Loop
I have a button on GP1.0 (pin 2) that is pressed or not, on the LCD one can only see 00 00, nothing else. I think this demonstrates that you can not write OLAT1 or read it, it also shows that a button press does not come through, or perhaps the GP1 is not initialized correctly. Tested also to write IODIR1 first but with the same result...
How should one initialize the chip with all pins as inputs?![]()
When you get all 0's, it usually means one of two things.
1) The SDA,SCL pins still have the analog mode enabled.
2) There aren't any pull-ups, or they pull-down.
If you have a voltmeter, check the voltage on the SDA,SCL pins.
They should be above 4V when no data is being transfered.
But I'm betting on analog mode.
<br>
DT
Bookmarks