Hi, guys! I'm attempt to work with arduino2009 connected to IOexpander 8 I/O PCF8574 via i2cbus, using the easy-to-use wire library
I follow all the examples found on the net but my 8574 doens't answer
So, I keep the scope and I see this : arduino STOP che clock trasmission immediatly after sending the one-byte request.
My component address is 0x38 (as per the datasheet, with 3 address component pin to ground)
I tried shifting address to left but the arduino performs always the strange behaviour. After sending the wire request, it stops the clock trasmission to slave!!! Why this?
In this way the slave cannot sent a answer .. =( adn the wire library cannot be wrong
What is my error??
I post my simple code here! If you see the scope, arduino stop sending the clock after first byte trasmission
I have a Ti PCF8574A, and the data sheet reports the address from 0x38 to 0x3F
this 8 bit expander havent' register (It seems so from DSh..) and it respond simply with a byte (8 pin status port) if you send adress plus Read request on the last bit R/W...I cannot find any sequence (first send a register and so on the data sheet..) have you already tried to interface this component? And do you sent a register number before request a data byte??
I could try 0x20 or a 1-bit left shift byte.. but
My doubt is : why does arduino stop to sent the clock SCL after first byte..?? It could be a problem, the slave cannot send anything :*
Wire.begin(); should be done only once in the setup function.
These are the routines I read and write that chip:-
void gpio_write(int address, int data) {
// Send device address
Wire.beginTransmission(address);
Wire.send(data ); // send byte
Wire.endTransmission();
}
int gpio_read(int address) {
int data = 0;
// Connect to device and request one bytes
Wire.requestFrom(address, 1);
while(Wire.available()) // slave may send less than requested
{
data = Wire.receive(); // receive a byte as character
}
return data;
}
thank you again and sorry for my mistake writing the component reference.
Today afternoon I'll try again following your code. A tip: must I write the address directly (0x38) or it is necessary a shift due to 7 bit i2cbus first byte format? It is not reported on the library reference, so I think to put it directly without any shift.
On this page, about half-way down, I have an I2C scanner:
Run that to find your slave address. If you don't get anything at all, stop right there and check your wiring. If you get an address, that is the one to use.
If that doesn't help, post your code, not just (retyped) snippets of it. Put it inside [ code ] tags using the "#" button.