@@ -99,21 +99,29 @@ before calling **begin()**.
9999- https://github.com/RobTillaart/MCP23S17 SPI 16 IO lines.
100100- https://github.com/RobTillaart/PCF8575 I2C 16 IO lines.
101101- https://github.com/RobTillaart/PCA9671 I2C 16 IO lines. - successor PCF8575
102-
102+ - https://github.com/RobTillaart/TCA9555 I2C 16 IO lines.
103103
1041048 bit port expanders
105105
106106- https://github.com/RobTillaart/MCP23008 I2C 8 IO lines.
107107- https://github.com/RobTillaart/MCP23S08 SPI 8 IO lines.
108108- https://github.com/RobTillaart/PCF8574 I2C 8 IO lines.
109+ - https://github.com/RobTillaart/TCA9554 I2C 8 IO lines.
110+
111+ Other libs based upon PCF8574
112+
113+ - https://github.com/RobTillaart/I2CKeyPad
114+ - https://github.com/RobTillaart/rotaryDecoder
115+ - https://github.com/RobTillaart/rotaryDecoderSwitch
109116
110117
111118## I2C
112119
113120
114121### Performance
115122
116- Tested on UNO with ** PCF8574_performance** showed that the PCF8574 still works at 500 KHz and failed at 600 KHz.
123+ Tested on UNO with ** PCF8574_performance** showed that the PCF8574 still works
124+ at 500 kHz and failed at 600 kHz.
117125These values are outside the specs of the datasheet so they are not recommended.
118126However when performance is needed you can try to overclock the chip.
119127
@@ -122,7 +130,7 @@ However when performance is needed you can try to overclock the chip.
122130| 100000 | 236 | 240 | spec datasheet |
123131| 200000 | 132 | 140 |
124132| 300000 | 104 | 108 |
125- | 400000 | 96 | 96 | max advised speed |
133+ | 400000 | 96 | 96 | max speed advised |
126134| 500000 | 92 | 92 | not recommended |
127135| 600000 | crash | crash |
128136
@@ -179,6 +187,63 @@ value is HIGH(1) or LOW (0)
179187- ** uint8_t valueOut()** returns the last written data.
180188
181189
190+ ### ReadArray and WriteArray
191+
192+ ** Experimental (0.4.4)**
193+
194+ Needs testing and verification with scope.
195+ See issue #60 and datasheet, 7.4 Device Functional Modes
196+
197+ These array functions read / write up to 30 bytes in one I2C transaction.
198+ 30 bytes is the maximum length of an AVR I2C buffer.
199+ Other lengths are possible by patching the PCF8574.cpp file.
200+
201+ - ** bool writeArray(uint8_t \* array, uint8_t size)** writes size bytes in one ** blocking** call.
202+ Blocking time depends on the I2C bus speed.
203+ ValueOut() is set to the last byte send.
204+ - ** bool readArray(uint8_t \* array, uint8_t size)** reads size bytes in one ** blocking** call.
205+ Value() is set to the last byte received.
206+
207+ With ** writeArray()** one can implement short pulses on the output pins.
208+ The duration of those pulses are 9 I2C clock pulses.
209+ So the duration of the pulse depends on (1) in how many bytes the pin
210+ is HIGH, (2) the I2C clock speed, and (3) the precision of the I2C clock.
211+
212+ ``` cpp
213+ uint8_t arr[10 ] = { 0, 1, 0, 1, 1, 0, 1, 1, 1, 0 };
214+ Wire.setClock(300000);
215+ PCF.writeArray(arr, 10);
216+ Wire.setClock(100000);
217+ ```
218+
219+ Indicative pulse duration, depends also on the precision of the I2C clock.
220+ By varying the clock speed one can adjust pulse length.
221+ (e.g. a pulse of 50 us needs about 9000/50 = 180 kHz, with len = 1)
222+
223+ | I2C CLK | len = 1 | len = 2 | len = 3 | notes |
224+ |:---------:|:---------:|:----------:|:----------:|:--------|
225+ | 45 kHz | 200.0 us | 400.0 us | 600.0 us |
226+ | 90 kHz | 100.0 us | 200.0 us | 300.0 us |
227+ | 100 kHz | 90.0 us | 180.0 us | 270.0 us |
228+ | 200 kHz | 45.0 us | 90.0 us | 135.0 us |
229+ | 300 kHz | 30.0 us | 60.0 us | 90.0 us |
230+ | 400 kHz | 22.5 us | 45.0 us | 67.5 us | max speed advised
231+ | 450 kHz | 20.0 us | 40.0 us | 60.0 us | could work.
232+
233+ Note 1: that one writes to all pins so one might need a **read8()** to get the
234+ status of the pins that should not be affected.
235+
236+ Note 2: I2C clocks might not be able to be set to all possible frequencies.
237+
238+
239+ With **readArray()** one can implement a parallel sampling of up to
240+ 32 bytes of up to 8 input lines at a sub millisecond range.
241+ This is not enough data for a full logical analyser, however it
242+ might be useful in other applications.
243+
244+ As stated, these function needs testing, so feedback is welcome.
245+
246+
182247### Button
183248
184249The **"button"** functions are to be used when you mix input and output on one IC.
0 commit comments