I develop this MCP23017 Breakout Board to interface a 2×16 LCD display with any microcontroller using a standard I2C bus. Typical 2×16 displays needs at least 6 lines to work (when working in 4-byte mode); in some cases, this will be prohibited for some microcontrollers. With this board, you can control it with only two lines (I2C bus) and, by the same price, obtain a few more IO’s. I use the MCP23017 I2C expander as a bridge. This integrated circuit provides 16 IO’s over a standard I2C bus. All the pins can configure as inputs or outputs independently, and supports high speed I2C (up to 1,7MHz). Also, this device has three hardware address pins that allow connecting up to 8 devices in the same bus. The rest of the features can be seen in the datasheet.
- The hardware
The scheme of the board can be downloaded here. In the fist page, there’s the input and output connectors, two LC filters for power supply, a green led to indicate that the board is power and the blocks corresponding to the expander and the LCD connector. Also, you can see R1 and R2, this resistors are the pull-up for the I2C bus. If the bus where you connect it doesn’t have these resistors, you can populated here (1K5 – 4K are admisible values). If the bus already has this resistors (such is my case) then you don’t need to populate it. In the second page, there’s the scheme of the MCP23017 expander. About this page, some tips. Reset pin is at high level (I don’t use it), so the device is always working. Also, the INTA and INTB interrupts are not used, so these pins are not connected. The address direction of the device is configurable by three jumpers in the scheme. With this, you can connect up to eight expanders in the same bus (more about this soon…). In the PCB, I use 0 ohms resistors to configure the address. Port GPA is used as the data bus to the display. Two signals of the GPB port are used to control signals to the LCD, and three more signals (GPB2 – GPB4) are connected to a three general purpose leds that will be usefull in the debug stage. Also, both ports are connected to a general connectors in order to use it as general IO’s if you don’t want to control the LCD. Also, I include an external EEPROM over the same bus. I use the 24LC256 from Microchip, that has a capacity of 32 KBytes. This memory has also three pins to configure the address, so with the same address configuration of the expander, you can configure it, and again you can put up to 8 of these memories in the same bus. At the end, in the last page of the schematic, there’re the two connectors for the GPA and GPB ports, and a stage to control the backlight of the display, if you populated a model that has this feature. This part of the circuit is based on a PNP transistor (BC856) controlled by the GPB5 output of the expander. As I don’t use it, I don’t populate it, not the resistors asociated (R7 – R9).
- The board
I send the board to seedstudio. I make a panel of two units of this board, with a total dimension of 48×49.5 mm. Each board has a dimension of 48x24mm, so I can fit two of them in less than 50x50mm board. The quality of the boards is very high, at this time all I mounted works fine. The only disavantage of this is that you must separate the boards without any kind of help like scoring, holes, etc. But with some patience and a small saw, I can obtain my individual boards!!! Here you can download the gerber of the panel. If anyone wants the PCB project or the single board gerbers, please contact me.
Two boards per panel, ready to cut it!!
Components mounted on Top Layer (hand-mounted)
Components mounted on Bottom Layer (hand-mounted)
Board fully assembled and mounted over the 2×16 LCD
- The software
I just develop a small software to test the board works. It’s developed for an AT89C51RE2 microcontroller (DSETA CPU, coming soon). It’s write in C languaje under Keil C51 compiler. There’re three main files:
- I2C_EXT.c – File that has the I2C funtions. These functions implement a bit-banged I2c, using two general purpose pins. Basic functions for I2C communications are implemented:
C123456789void I2C_EXT_delay (unsigned char t_delay);void I2C_EXT_Start (void);void I2C_EXT_Stop (void);void I2C_EXT_txACK (void);void I2C_EXT_txNACK (void);void I2C_EXT_Write (unsigned char OUT_DATA);unsigned char I2C_EXT_Read (void);
- MCP23017.c – File that has the functions to communicate with the MCP23017 over the I2C bus previously implemented. It only has two functions: one for initialize the driver and other to send a value to an output port:
C12void Inicializa_MCP23017 (void);unsigned char MCP23017_Enviar_Dato (unsigned char puerto, unsigned char dato);
- LCD_2X16_I2C.c – File that has the functions to communicate with theLCD in 8 bit mode. It has the classic functions to initialize it, send a command or a data, or print a line:
C12345void LCD_delay_I2C (unsigned int t_delay);void LCD_cmd_I2C (unsigned char comando);void LCD_dato_I2C (unsigned char dato);void LCD_init_I2C (void);void LCD_print_I2C (unsigned char *cadena, unsigned char linea);
Here you can download these files with the implementation of all the functions: MCP23017_Files
And finally, a couple of inages of the board in action:
MCP23017 breakout board connected to the CPU
Display shows the system status, date, time and temperature!