GeoJoe, Where is your I2CREAD statement?
GeoJoe, Where is your I2CREAD statement?
My mistake. I've been changing the code and trying all kinds of different stuff. I had tried the write command just to see what happened and didn't change it back when I posted that reply. However I have the write command in there now. I don't think the clock is correct. It isn't idling high. I am still working on this so if anyone has any wisdom to share please do. This is a really sweet chip set, the pic has a bunch of i/o's, on board USB and huge instruction memory space of 128k; the i/o expanders add an extra 16 gpio's each. I have 3 on my board. This left the other pic pins open for things like wireless modem, a maxstream zigbee module, LCD, and left many of the ATOD's open.
Any advice on this???????????
read command that is.
Thanks Jeff.............
An email to melabs support got me the answer. Here it is:
I2Cread portc.4, portc.3, %01000000, command, [insin], noitwoc
Where command is what register you want to read 0 or 1. Now I get the value of the I/O expansion chip into the variable insin. Just missed the brackets around the variable name!
Now I'm trying to figure out the write command. Some difficulties, I'll post my results. Hope this helps someone. This is a nice chip set. The I/O's on pics go fast. Faster and faster the deeper I get into designing with them.
Joe
i2cwrite portc.4, portc.3, %01000010, %00000111, [%00000000] ' SET U9 PORT 1 TO OUTPUTS
i2cwrite portc.4, portc.3, %01000010, %00000011, [acout] ' WRITE VARIABL ACout TO U9 PORT 1 LATCH REGISTER
insin = 0
i2cread portc.4, portc.3, %01000000,[insin]', noitwoc ' READ U8 PORT 0 AND 1 PIN STATES
i2cread portc.4, portc.3, %01000010, %00000000, [inson] ' READ U9 PORT 0 PIN STATES
Here are the write and read lines I've found to be successful with the MCP23016 I/O expander chip.
Use in good health.
Bookmarks