Pcf8574
crgwbr
Posts: 614
I am trying to write a driver for the PCF8574 I2C 8 bit I/O expander. Since this is the first (non-eeprom) I2C device I've used, I was trying to base it off of this article. But I'm having a few problems translating the BS2p's I2CIN I2COUT commands into something usable for Mike's Basic I2C Driver.
BS2p Constants:
The BS2p I2C command structure is like this:
How would this translate into the needed parameters for Mike's driver? I'm thinking that I can do something like this:
Thanks,
Craig
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
My system: 1.6 GHz AMD Turion64 X2, 4GB DDR2, 256MB ATI Radeon Graphics card, 15.4" Widescreen HD Screen
I have a duel boot of Ubuntu Linux and Windows Vista. Vista, because it came with the PC, Ubuntu because I like software that works.
"Failure is not an option -- it comes bundled with Windows."
Use The Best...
Linux for Servers
Mac for Graphics
Palm for Mobility
Windows for Solitaire
Post Edited (crgwbr) : 2/21/2008 9:39:12 PM GMT
BS2p Constants:
DevType CON %0100 << 4 ' Device type DevAddr CON %000 << 1 ' address = %000 -> %111 Wr8574 CON DevType | DevAddr ' write to PCF8574 Rd8574 CON Wr8574 | 1 ' read from PCF8574 MixDDR CON %00001111 ' 1 = input, 0 = output
The BS2p I2C command structure is like this:
I2CIN I2Cpin, Rd8574, (MixDDR | ~cntr), [noparse][[/noparse]ioByte] I2COUT I2Cpin, Wr8574, MixDDR, [noparse][[/noparse]~cntr]
How would this translate into the needed parameters for Mike's driver? I'm thinking that I can do something like this:
VAR byte Read byte Write CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 DevType %01000000 ' Device type (A0-A2 tied to GND) MixDDR %00001111 ' 1 = input, 0 = output OBJ I2C : "Basic_I2C_Driver" PUB Main 'ReadPage(SCL, devSel, addrReg, dataPtr, count) : ackbit 'WritePage(SCL, devSel, addrReg, dataPtr, count) : ackbit write := %11110000 I2C.ReadPage(0, DevType, MixDDR, @Read, 1) I2C.WritePage(0, DevType, MixDDR, @Write, 1)
Thanks,
Craig
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
My system: 1.6 GHz AMD Turion64 X2, 4GB DDR2, 256MB ATI Radeon Graphics card, 15.4" Widescreen HD Screen
I have a duel boot of Ubuntu Linux and Windows Vista. Vista, because it came with the PC, Ubuntu because I like software that works.
"Failure is not an option -- it comes bundled with Windows."
Use The Best...
Linux for Servers
Mac for Graphics
Palm for Mobility
Windows for Solitaire
Post Edited (crgwbr) : 2/21/2008 9:39:12 PM GMT
Comments
I am using the PCF8574 with a modified version of Mike Greens minimal_i2c_driver .. it works well
currently I am using it for reading inputs only .. with an address of '32' .. A0,A1,A2 all pulled low.
just did a 'search.parallax.com' and found these links .. should get you going
www.rayslogic.com/Propeller/Programming/I2C/i2c.htm
http://forums.parallax.com/showthread.php?p=692852
Regards,
John
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
'Necessity is the mother of invention'
http://forums.parallax.com/showthread.php?p=703283
There is also a piece of code near this thread using the PCF8591 as an example
That just what I was looking for. One more quick question though, I'll be using several PCF8574's on the same bus, therefore they can't all be addressed as %100000 (32). Which 3 bit's do A0, A1, and A2 effect? Does A0,A1,A2 all pulled high create %100111?
Thanks,
Craig
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
My system: 1.6 GHz AMD Turion64 X2, 4GB DDR2, 256MB ATI Radeon Graphics card, 15.4" Widescreen HD Screen
I have a duel boot of Ubuntu Linux and Windows Vista. Vista, because it came with the PC, Ubuntu because I like software that works.
"Failure is not an option -- it comes bundled with Windows."
Use The Best...
Linux for Servers
Mac for Graphics
Palm for Mobility
Windows for Solitaire
Attached please find an image outlining settings and addresses for A2,A1,A0 .. please note that the address range varies in different flavours of the IC .. i.e PCF8574A etc..
Regards,
John
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
'Necessity is the mother of invention'