Hardware Reference
In-Depth Information
to poll each peripheral to determine whi ch device is causing the interrupt. Alternatively,
each slave could provide a separate INT signal, with a corresponding increase in
signal lines.
Each MCP23017 chip has two interrupt lines, named INT A and INT B . There is
the option of separate interrupt notifications for the A group or the B group of GPIO pins.
For remote operation, it is desirable to tak e ad vantage of MCP23017's ability to configure
these to work in tandem, so that only one INT line is re quired.
On the Raspberry Pi end, the GPIO pin used for the RESET line would be configured
as an output and held high, until a reset is required. When activating a reset, the line must
be held low for at least 1 microsecond, plus 1 more microsecond to allow for the chip reset
operation itse lf (and possibly longer, if non-MCP23017 slaves are connected to the bus).
The INT line should be connected to a GPIO input on the Pi. This GPIO input
either needs to be polled by the application, or to have the GPIO configured to trigger
on changes. Then the select(2) or poll(2) system calls can be used to detect when an
interrupt is raised by one or more peripherals.
The interrupt line, when used, should have a pull-up resistor configured (see
Chapter 10 of Raspberry Pi Hardware Reference [Apress, 2014] for information about
internal pull-up resistors). It may be best to use an external pull-up resistor, especially for
longer cable runs. To keep the sink current at 2 mA or less, the pull-up resistance used
should be no lower than the following:
pullup = +
=
33
2
1650
V
mA
.
R
W
A 2 . 2 k Ω 10% resistor will do nicely.
The +3.3 V line should be powered separately from the Raspberry Pi, unless the
slaves expect to drive very low currents. The main concern here is to not overload the
remaining 50 mA capacity of the Pi's +3.3 V regulated supply. See Chapter 10 of Raspberry
Pi Hardware Reference (Apress, 2014) about budgeting +3.3 V power.
I2C Bus
Throughout this chapter, we are assuming a Rev 2.0 or later Raspberry Pi. This matters for
the I2C bus because the early versions wired I2C bus 0 to P1-03 and P1-05 (GPIO 0 and 1).
Later this was changed to use bus 1. See Chapter 12 of Raspberry Pi Hardware Reference
(Apress, 2014) for more information about identifying your Pi and which I2C bus to use.
If you are using an early Raspberry Pi revision, you'll need to substitute 0 for bus number
1, in commands and in the C source code that follows.
 
 
Search WWH ::




Custom Search