PDA

View Full Version : troubles using more than one PCF8574



maus
- 25th July 2007, 20:17
I have a problem when i want to use I2CWRITE on 2 different adressed PCF8574 chips

here's a snippet of my code:

pic16F876a at 8 Mhz crystal

ADRESS1 con %01110000
ADRESS2 con %01111110
DEFINE I2C_HOLD 1
DEFINE I2C_SLOW 1
SCL var portc.3
SDA var portc.4
i2cwrite SDA,SCL,ADRESS1,[0]
pause 50
i2cwrite SDA,SCL,ADRESS2,[0]
pause 50

start:
'this is just a test !

if portb.6=1 then out0=2
if portb.7=1 then out1=4

i2cwrite SDA,SCL,ADRESS1,out0
pause 50
i2cwrite SDA,SCL,ADRESS2,out2
pause 50

goto start

this is what happens:


port 6 should set output 2 out PCF at addres 1 and port7 should set output 4 out PCF at addres 2, but when i do it like in the example, if i activate port 7
then output 4 of PCF at adress1 is activated instead of output 4 of PCF 2

What goes wrong here,

hardware (chips etc) have been replaced several times, adresses also

who encountered this problem also ?

Dave
- 26th July 2007, 14:05
maus, Make sure they are both the same suffix character ie. both have an "N" at the end or not. The parts have a different base address which allows 2 banks of 8 devices to be used in a system. Look at the data sheet.... I have used 16 devices in a couple of systems I have designed and had no problems....

Dave Purola,
N8NTA

Dave
- 26th July 2007, 14:09
maus, Also I noticed that you are sending it:i2cwrite SDA,SCL,ADRESS2,out2. Where is out2 being set? I beleive it should be out1?

Dave Purola,
N8NTA

maus
- 26th July 2007, 21:47
thank you for your replies dave,

Yes i used two "A" types, and indeed out2 should be out1, but this is just a short test program, so in my code it still doesn't work right, cause the out which should be sent to the second PCF is activating the first one,

So anybody any more ideas, let me know

thanx

Dave
- 28th July 2007, 19:37
maus, Without seeing the actual circuit I can't say anything else other than check with a multimeter that all 3 programmable address bits are in different strapped states. You have 1 IC strapped for an address of 0 and the other for an address of 7.

Dave Purola,
N8NTA