主题中讨论的其他器件: PCF8575
您好!
我之所以撰写本文、是因为我开发了一个板、该板具有一个 Atmega1284p 处理器、通过 I2C 与两个 TCA9535RTWR 通信。
通过100nF 电容器提供5V 的电源。
在一个端口上、扩展器 A0、A1和 A2设置为 GND、以便 I2C 地址为0x20、而在另一个端口上、设置为 A0=5V、A1和 A2设置 为 GND、以便 I2C 地址为0x21。
SCL 和 SDA 被正确上拉并被连接至 Atmega 处理器。
我正在使用 Arduino 软件对其进行编程。 硬件似乎工作正常。
实际上、如果我使用以下代码对 P17-P10进行编程、它看起来可以正常工作:
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();
实际上、我可以看到 LED 正确闪烁。
当我尝试使用端口 P07-P00配置和设置输出时、会出现此问题、因为我无法将它们设置为高电平和低电平、如 P17-P10:
Wire.write(byte(0x06));//to configure the ports Wire.write(byte(0x02));//to set the outputs
另一个问题是、如果我尝试使用以下代码读取配置寄存器(或从0x02到最后一个寄存器的任何其他寄存器)、我始终只能看到输入寄存器的内容:
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();
读指令看起来运行良好、但"Wire.write (byte (0x06));"指令不起作用、它从开头(reg 0x00 ->输入)
我在其他端口扩展器(0x21)和其他电路板上遇到了完全相同的问题。
我曾尝试 Analog Devices Inc./Maxim Integrated 的 MAX7311ATG+、所有操作均按预期进行。
非常感谢。
此致
Luca Riva