mcp23017 (i2c) example code?
mpark
Posts: 1,305
Does anyone have some mcp23017 code I can look at? It's getting late and the datasheet is becoming blurry.
Maybe tomorrow I'll wake up and find that some kind soul has posted some code to get me started.
Being inexperienced in the ways of i2c, I just need to be pointed in the right direction.
Maybe tomorrow I'll wake up and find that some kind soul has posted some code to get me started.
Being inexperienced in the ways of i2c, I just need to be pointed in the right direction.
Comments
A search in the Obex search for MCP23017 comes up blank, as does a number of other searches for chips like this (including the SPI variants).
Spin or Pasm or both would be fine. Searches on Google come up with Duane Johnson's Femtobasic driver but Spin/Pasm would be better!
mpark - did you end up getting some code working?
I'm not looking to use every feature on these chips - in fact all I really want to do is either output some bytes, or input some bytes. I'm intrigued by this chip as it can share the I2C bus which is already used by the eeprom, and hence effectively it can give you more I/O pins on the propeller without actually using any more propeller pins. Cunning!
Any help would be most appreciated.
Simple answer - use Jonny Mac's code which works perfectly. Is this one maybe for the Obex?
Addit - a little demo using two MCP23017 chips. These are $1.20 each at Futurlec, so for $2.40 you can have another 32 I/O pins for the propeller chip.
the object itself:
Here is my test code to run it with int on change.
The test code used a circuit with two MCP23017's on a PPDB. Each MCP23017 had port B set up as in input with port A set up as an output. I used a pushbutton switch on the board for the input, and a LED on the board for the output. I used the interrupt pin bussed off of both MCP23017's to trigger the reads and writes to the chips. This keeps from having to poll continuously and tie up the I2C port with messages. Finally, I just had an LED to turn on with the interrupt so that I could see that. This circuit is not really practical (although it may be), but I wanted to use all the features of the chips. It also may be handy to have each chip capable of 8 inputs and 8 outputs, versus having to have one chip as an input and one as an output.
Again, thanks for the object, this was a great help. Hopefully this code may help someone else use them as well.
I like the MCP23017, seems like it will be handy for reading switches and such.
Purchased from the 'OldBitCollector'( http://www.propellerpowered.us/) himself.
They are large, and do take some real estate investment...
Thanks for sharing your code fixmax,
MCP23017_Demo_MyWay - Archive [Date 2013.07.26 Time 09.34].zip
-Tommy