Other Parts Discussed in Thread: PCF8575
Hi,
I am writing because I developed a board with an Atmega1284p processor communicating to two TCA9535RTWR via I2C.
The power supply is 5V through a 100nF capacitor.
On one port expander A0, A1 and A2 are set to GND so that the I2C address is 0x20, on the other one they are set as A0=5V and A1 and A2 are set to GND so that the I2C address is 0x21.
The SCL and SDA are pulled-up correctly and connected to the Atmega processor.
I am programming it with arduino SW. The hardware seems to work correctly.
In fact if I use the following code to program P17-P10 it seem work as expected:
Wire.beginTransmission(byte(0x20));
Wire.write(byte(0x07));
Wire.write(byte(0x17));//P17-P10 0001 0111 (set P17-P15 and P13 as output)
Wire.endTransmission();
Wire.beginTransmission(byte(0x20));
Wire.write(byte(0x03));
Wire.write(byte(0xFF));//P17-P10 1111 1111 (set output to HIGH)
Wire.endTransmission();
Wire.beginTransmission(byte(0x20));
Wire.write(byte(0x03));
Wire.write(byte(0x00));//P17-P10 0000 0000 (set output to LOW)
Wire.endTransmission();
In fact I can see the Led blinking correctly.
The problem appears when I try to configure and set the outputs with ports P07-P00 because I cannot set them HIGH and LOW as for P17-P10:
Wire.write(byte(0x06));//to configure the ports
Wire.write(byte(0x02));//to set the outputs
Another problem is that if I try to read the config registers (or any other register from 0x02 to the last one) with the following code, I always can see only the content of the input registers:
Wire.beginTransmission(byte(0x20));
Wire.write(byte(0x06));
Wire.requestFrom(byte(0x20), uint8_t(2));
IBuffer[0] = Wire.read();
Serial.print("Config 20 0: ");
Serial.println(IBuffer[0], BIN);
IBuffer[0] = Wire.read();
Serial.print("Config 20 1: ");
Serial.println(IBuffer[0], BIN);
Wire.endTransmission();
It seems that the reading instruction works well but the "Wire.write(byte(0x06));" instruction doesn't work and it read from the beginning (reg. 0x00 -> input)
I have the exact same issue with the other port expander (0x21) and also on other boards.
I tried with MAX7311ATG+ from Analog Devices Inc./Maxim Integrated and all work as expected.
Thank you very much.
Best regards
Luca Riva