PCA9555 IO Expander Driver
dfletch
Posts: 165
Hi all.
A while back deSilva talked me into getting a few IO expanders to play with. I picked the PCA9555 because there was one with a DIP format and it's pretty low cost.
So finally I hooked one up and wrote a nice driver for it. It's based on deSilva's original "Small I2C Driver" thread: http://forums.parallax.com/showthread.php?p=703283
Features:
- Spin
- Driver is only 101 longs
- zero cogs
- 16 pins of expansion per PCA9555
- up to 8 PCA9555 on one bus
API:
Thanks so much deSilva for introducing me to this type of chip. Very fun controlling so many pins using so few Prop resources.
Enjoy!
Cheers,
--fletch
UPDATE: Post edited for correctness and clarity.
UPDATE2: Updated archive with a couple of corrections.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Join us in the Un-Official Propeller IRC channel: irc.freenode.net #propeller
Newbies, oldies, programmers, math professors, and everyone in-between welcome!
Propeller IRC howto
spinc - open source Spin compiler
Post Edited (dfletch) : 3/31/2008 7:10:29 PM GMT
A while back deSilva talked me into getting a few IO expanders to play with. I picked the PCA9555 because there was one with a DIP format and it's pretty low cost.
So finally I hooked one up and wrote a nice driver for it. It's based on deSilva's original "Small I2C Driver" thread: http://forums.parallax.com/showthread.php?p=703283
Features:
- Spin
- Driver is only 101 longs
- zero cogs
- 16 pins of expansion per PCA9555
- up to 8 PCA9555 on one bus
API:
OBJ io : "pca9555" PUB start io.start(sda, scl) io.setDir(addr, dirval) io.getDir(addr) io.setOut(addr, outval) io.getOut(addr) io.getIn(addr) ' output of this should be ANDed with the specified direction value io.setPolInv(addr, polval) io.getPolInv(addr)
Thanks so much deSilva for introducing me to this type of chip. Very fun controlling so many pins using so few Prop resources.
Enjoy!
Cheers,
--fletch
UPDATE: Post edited for correctness and clarity.
UPDATE2: Updated archive with a couple of corrections.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Join us in the Un-Official Propeller IRC channel: irc.freenode.net #propeller
Newbies, oldies, programmers, math professors, and everyone in-between welcome!
Propeller IRC howto
spinc - open source Spin compiler
Post Edited (dfletch) : 3/31/2008 7:10:29 PM GMT
Comments
This RadioShack kit turns out to be handy for prototyping. Pushbuttons and plenty of breadboard space.
Enjoy!
Cheers,
--fletch
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Join us in the Un-Official Propeller IRC channel: irc.freenode.net #propeller
Newbies, oldies, programmers, math professors, and everyone in-between welcome!
Propeller IRC howto
spinc - open source Spin compiler
I like the PCA9555 too for a couple reasons. One of them being that the·I/O·is 5V tolerant and another reason is that the I/O pins include a pullup resistor. I am using the PCA9555 in the uOLED-IOC, an I/O expansion for the 4D Systems uOLED-96-PROP. the uOLED-IOC could also be used for other Prop or microcontroller system because one can easily attach to the I2C SDA/SCL lines. You can find out more with the link below to Brilldea.· Of course using the DIP chip you are using is cheaper if just adding I/O to a system.
Right now I have a SPIN driver, but I use a different I2C package from the Object Exchange. In the future I hope to add an ASM I2C driver for those that want to push the communicaiton limits.
Do you have any particular plans for your use of the chip?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Timothy D. Swieter
www.brilldea.com·- check out the uOLED-IOC, an I/O expansion for the uOLED-96-PROP
www.tdswieter.com
One little spark of imagination is all it takes for an idea to explode
The slow speed of this driver in Spin is a bit interesting. There's not much of a need for special debounce hardware or software when using this with my joysticks and pushbuttons because the chance that the button will be intermittently contacting when the driver asks for the state of input is very low. Just doing io.getIn() twice in a row would handle all debounce cases I think.
On the other hand, the slow speed of Spin makes it impossible to use the driver as-is for any sort of reasonable speed communications. I was looking last night at hooking up an uMFPU which looks very easy to hook up, but the slow comms destroys some of the benefit of the chip. An ASM driver would help a bit in this case (though really, an ASM SPI driver would really be nice).
So I'll probably use it in some form for the inputs of my console, but what really interests me here is learning what I can attach to my Propeller [noparse]:)[/noparse] Well there's that, plus the fact that I bought 25 of them so it was probably good just to figure out how they work [noparse];)[/noparse]
Cheers,
--fletch
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Join us in the Un-Official Propeller IRC channel: irc.freenode.net #propeller
Newbies, oldies, programmers, math professors, and everyone in-between welcome!
Propeller IRC howto
spinc - open source Spin compiler