MCP2221 Breakout Module User’s Guide
DS50002282A-page 22 2014 Microchip Technology Inc.
3.4 EXAMPLE FOR INTERFACING WITH THE MCP23008 (8-BIT I/O EXPANDER)
1. If multiple MCP2221 devices are connected, choose the one to be used from the
Select Device drop-down menu. Also, select the desired communication speed
from the Speed list, as shown in Figure 3-7.
FIGURE 3-7: DEVICE SETTINGS
2. With A0, A1, A2 pins on the board tied to a 0 logic level, select the protocol,
address length, slave address and whether the operation is a read or a write
(Figure 3-8). Set the slave address to 40. These settings need to be made for
every new command.
FIGURE 3-8: COMMAND SETTINGS
3. For the Write sequence, first configure the pins as outputs. The IODIR register
has a 0h address, so writing 0h to this register will set all the port pins as outputs.
To set all the pins high, write FF(hex) to the OLAT register (address 0A(hex)), as
shown in Figure 3-9. The first data byte represents the register address, while the
second data byte represents the value that will be written.
The commands can be sent individually, by pressing the Send button, or
consecutively, by pressing the Send All button.
Verify whether the settings have been applied by reading back the port value
from the GPIO register (address 09(hex)). Send a write command to specify the
register address. Then, send a read command specifying the number of bytes
that will be read.
FIGURE 3-9: WRITE SEQUENCE