@@ -16,8 +16,6 @@ Arduino library for PCF8574 - 8 channel I2C IO expander.
16
16
17
17
## Description
18
18
19
- Related to the PCF8575 16 channel IO expander library https://github.com/RobTillaart/PCF8575
20
-
21
19
This library gives easy control over the 8 pins of a PCF8574 and PCF8574A chip.
22
20
These chips are identical in behaviour although there are two distinct address ranges.
23
21
@@ -36,7 +34,7 @@ The library allows to read and write both single pins or 8 pins at once.
36
34
Furthermore some additional functions are implemented that are playful and useful.
37
35
38
36
39
- #### Interrupts intro
37
+ ### Interrupts intro
40
38
41
39
The PCF8574 has an interrupt output line (INT) to notify an MCU that one of the input lines has changed.
42
40
This can be used to prevent active polling of the PCF8574, which can be more efficient.
@@ -61,7 +59,7 @@ In practice if you have faster polling than your signals changes this would not
61
59
be a problem. E.g. tactile switches and a polling frequency > 100 Hz will work.
62
60
63
61
64
- #### Interrupts library
62
+ ### Interrupts library
65
63
66
64
The library cannot handle the PCF8574 interrupts as it has no code for it.
67
65
The user should catch the interrupt in his own code to set a flag and can use
@@ -84,7 +82,7 @@ A minimal example that shows catching missed interrupts:
84
82
- ** PCF8574_interrupt_advanced.ino**
85
83
86
84
87
- #### 0.4.0 Breaking change
85
+ ### 0.4.0 Breaking change
88
86
89
87
Version 0.4.0 introduced a breaking change.
90
88
You cannot set the pins in ** begin()** any more.
@@ -93,24 +91,27 @@ The user has to call **Wire.begin()** and can optionally set the Wire pins
93
91
before calling ** begin()** .
94
92
95
93
96
- #### Related
94
+ ### Related
97
95
98
96
16 bit port expanders
99
97
100
- - https://github.com/RobTillaart/MCP23017_RT
101
- - https://github.com/RobTillaart/MCP23S17
102
- - https://github.com/RobTillaart/PCA9671
103
- - https://github.com/RobTillaart/PCF8575
98
+ - https://github.com/RobTillaart/MCP23017_RT I2C 16 IO lines.
99
+ - https://github.com/RobTillaart/MCP23S17 SPI 16 IO lines.
100
+ - https://github.com/RobTillaart/PCF8575 I2C 16 IO lines.
101
+ - https://github.com/RobTillaart/PCA9671 I2C 16 IO lines. - successor PCF8575
104
102
105
103
106
104
8 bit port expanders
107
105
108
- - https://github.com/RobTillaart/MCP23008
109
- - https://github.com/RobTillaart/MCP23S08
110
- - https://github.com/RobTillaart/PCF8574
106
+ - https://github.com/RobTillaart/MCP23008 I2C 8 IO lines.
107
+ - https://github.com/RobTillaart/MCP23S08 SPI 8 IO lines.
108
+ - https://github.com/RobTillaart/PCF8574 I2C 8 IO lines.
109
+
111
110
111
+ ## I2C
112
112
113
- ## I2C Clock
113
+
114
+ ### Performance
114
115
115
116
Tested on UNO with ** PCF8574_performance** showed that the PCF8574 still works at 500 KHz and failed at 600 KHz.
116
117
These values are outside the specs of the datasheet so they are not recommended.
@@ -126,6 +127,24 @@ However when performance is needed you can try to overclock the chip.
126
127
| 600000 | crash | crash |
127
128
128
129
130
+ ### I2C multiplexing
131
+
132
+ Sometimes you need to control more devices than possible with the default
133
+ address range the device provides.
134
+ This is possible with an I2C multiplexer e.g. TCA9548 which creates up
135
+ to eight channels (think of it as I2C subnets) which can use the complete
136
+ address range of the device.
137
+
138
+ Drawback of using a multiplexer is that it takes more administration in
139
+ your code e.g. which device is on which channel.
140
+ This will slow down the access, which must be taken into account when
141
+ deciding which devices are on which channel.
142
+ Also note that switching between channels will slow down other devices
143
+ too if they are behind the multiplexer.
144
+
145
+ - https://github.com/RobTillaart/TCA9548
146
+
147
+
129
148
## Interface
130
149
131
150
``` cpp
@@ -136,7 +155,7 @@ However when performance is needed you can try to overclock the chip.
136
155
the include of "pcf8574.h" to overrule the default value used with the ** begin()** call.
137
156
138
157
139
- #### Constructor
158
+ ### Constructor
140
159
141
160
- ** PCF8574(uint8_t deviceAddress = 0x20, TwoWire \* wire = &Wire)** Constructor with optional address, default 0x20,
142
161
and the optional Wire interface as parameter.
@@ -148,7 +167,7 @@ so one might need to call **read8()** and/or **write8()**. Returns true if addre
148
167
- ** uint8_t getAddress()** Returns the device address.
149
168
150
169
151
- #### Read and Write
170
+ ### Read and Write
152
171
153
172
- ** uint8_t read8()** reads all 8 pins at once. This one does the actual reading.
154
173
- ** uint8_t read(uint8_t pin)** reads a single pin; pin = 0..7
@@ -160,7 +179,7 @@ value is HIGH(1) or LOW (0)
160
179
- ** uint8_t valueOut()** returns the last written data.
161
180
162
181
163
- #### Button
182
+ ### Button
164
183
165
184
The ** "button"** functions are to be used when you mix input and output on one IC.
166
185
It does not change / affect the pins used for output by masking these.
@@ -177,7 +196,7 @@ Note this can be a subset of the pins set with **setButtonMask()** if one wants
177
196
Background - https://github.com/RobTillaart/Arduino/issues/38
178
197
179
198
180
- #### Special
199
+ ### Special
181
200
182
201
- ** void toggle(const uint8_t pin)** toggles a single pin
183
202
- ** void toggleMask(const uint8_t mask = 0xFF)** toggles a selection of pins,
@@ -191,7 +210,7 @@ Fills the lower lines with zero's.
191
210
- ** void reverse()** reverse the "bit pattern" of the lines, swapping pin 7 with 0, 6 with 1, 5 with 2 etc.
192
211
193
212
194
- #### Select
213
+ ### Select
195
214
196
215
Some convenience wrappers.
197
216
@@ -205,7 +224,7 @@ This can typical be used to implement a VU meter.
205
224
- ** void selectAll()** sets all pins to HIGH.
206
225
207
226
208
- #### Miscellaneous
227
+ ### Miscellaneous
209
228
210
229
- ** int lastError()** returns the last error from the lib. (see .h file).
211
230
0 commit comments