Note the following details of the code protection feature on Microchip devices:
•Microchip products meet the specification contained in their particular Microchip Data Sheet.
•Microchip believes that its family of products is one of the most secure families of its kind on the market today, when used in the
intended manner and under normal conditions.
•There are dishonest and possibly illegal methods used to breach the code protection feature. All of these methods, to our
knowledge, require using the Microchip products in a manner outside the operating specifications contained in Microchip’s Data
Sheets. Most likely, the person doing so is engaged in theft of intellectual property.
•Microchip is willing to work with the customer who is concerned about the integrity of their code.
•Neither Microchip nor any other semiconductor manufacturer can guarantee the security of their code. Code protection does not
mean that we are guaranteeing the product as “unbreakable.”
Code protection is constantly evolving. We at Microchip are committed to continuously improving the code protection features of our
products. Attempts to break Microchip’s code protection feature may be a violation of the Digital Millennium Copyright Act. If such acts
allow unauthorized access to your software or other copyrighted work, you may have a right to sue for relief under that Act.
Information contained in this publication regarding device
applications and the like is provided only for your convenience
and may be superseded by updates. It is your responsibility to
ensure that your application meets with your specifications.
MICROCHIP MAKES NO REPRESENTATIONS OR
WARRANTIES OF ANY KIND WHETHER EXPRESS OR
IMPLIED, WRITTEN OR ORAL, STATUTORY OR
OTHERWISE, RELATED TO THE INFORMATION,
INCLUDING BUT NOT LIMITED TO ITS CONDITION,
QUALITY, PERFORMANCE, MERCHANTABILITY OR
FITNESS FOR PURPOSE. Microchip disclaims all liability
arising from this information and its use. Use of Microchip
devices in life support and/or safety applications is entirely at
the buyer’s risk, and the buyer agrees to defend, indemnify and
hold harmless Microchip from any and all damages, claims,
suits, or expenses resulting from such use. No licenses are
conveyed, implicitly or otherwise, under any Microchip
intellectual property rights.
Trademarks
The Microchip name and logo, the Microchip logo, Accuron,
dsPIC, K
EELOQ, microID, MPLAB, PIC, PICmicro, PICSTART,
PRO MATE, PowerSmart, rfPIC and SmartShunt are
registered trademarks of Microchip Technology Incorporated
in the U.S.A. and other countries.
AmpLab, FilterLab, Migratable Memory, MXDEV, MXLAB,
SEEVAL, SmartSensor and The Embedded Control Solutions
Company are registered trademarks of Microchip Technology
Incorporated in the U.S.A.
Analog-for-the-Digital Age, Application Maestro, CodeGuard,
dsPICDEM, dsPICDEM.net, dsPICworks, ECAN,
ECONOMONITOR, FanSense, FlexROM, fuzzyLAB,
In-Circuit Serial Programming, ICSP, ICEPIC, Linear Active
Thermistor, Mindi, MiWi, MPASM, MPLIB, MPLINK, PICkit,
PICDEM, PICDEM.net, PICLAB, PICtail, PowerCal,
PowerInfo, PowerMate, PowerTool, REAL ICE, rfLAB,
rfPICDEM, Select Mode, Smart Serial, SmartTel, Total
Endurance, UNI/O, WiperLock and ZENA are trademarks of
Microchip Technology Incorporated in the U.S.A. and other
countries.
SQTP is a service mark of Microchip Technology Incorporated
in the U.S.A.
All other trademarks mentioned herein are property of their
respective companies.
Microchip received ISO/TS-16949:2002 certification for its worldwide
headquarters, design and wafer fabrication facilities in Chandler and
Tempe, Arizona, Gresham, Oregon and Mountain View, California. The
Company’s quality system processes and procedures are for its PIC
8-bit MCUs, KEELOQ
microperipherals, no nvolatile memory and analog products. In addition,
Microchip’s quality system for the design and manufacture of
development systems is ISO 9001:2000 certified.
All documentation becomes dated, and this manual is no exception. Microchip tools and
documentation are constantly evolving to meet customer needs, so some actual dialogs
and/or tool descriptions may differ from those in this document. Please refer to our web site
(www.microchip.com) to obtain the latest documentation available.
Documents are identified with a “DS” number. This number is located on the bottom of each
page, in front of the page number. The numbering convention for the DS number is
“DSXXXXXA”, where “XXXXX” is the document number and “A” is the revision level of the
document.
INTRODUCTION
This chapter contains general information that will be useful to know before using the
GPIO Expander Keypad and LCD Demo Board. Items discussed in this chapter
include:
• Document Layout
• Conventions Used in this Guide
• Recommended Reading
• The Microchip Web Site
• Customer Support
• Document Revision History
DOCUMENT LAYOUT
This document describes how to use the GPIO Expander Keypad and LCD Demo
Board as a development tool. The manual layout is as follows:
• Chapter 1. “Product Overview” – Important information about the GPIO
Expander Keypad and LCD Demo Board.
• Chapter 2. “Installation and Operation” – Includes instructions on how to get
started with this evaluation board.
• Appendix A. “Schematics and Board Layouts” – Shows the schematic and
layout diagrams for the GPIO Expander Keypad and LCD Demo Board.
• Appendix B. “Bill Of Materials (BOM)” – Lists the parts used to build the GPIO
Expander Keypad and LCD Demo Board.
Choice of mutually exclusive
arguments; an OR selection
“Save project before build”
4‘b0010, 2‘hF1
any valid filename
[options]
errorlevel {0|1}
®
IDE User’s Guide
RECOMMENDED READING
For more information regarding the Stand-Alone CAN controller, CAN I/O Expander,
and CAN transceiver devices, refer to the appropriate data sheet. Table 1 shows the
device and associated Data Sheet literature number. These documents can be found
at Microchip’s web site at: www.microchip.com.
TABLE 1: DEVICES AND DATA SHEET LITERATURE NUMBERS
Microchip provides online support via our web site at www.microchip.com. This web
site is used as a means to make files and information easily available to customers.
Accessible by using your favorite Internet browser, the web site contains the following
information:
• Product Support – Data sheets and errata, application notes and sample
programs, design resources, user’s guides and hardware support documents,
latest software releases and archived software
• General Technical Support – Frequently Asked Questions (FAQs), technical
support requests, online discussion groups, Microchip consultant program
member listing
• Business of Microchip – Product selector and ordering guides, latest Microchip
press releases, listing of seminars and events, listings of Microchip sales offices,
distributors and factory representatives
CUSTOMER SUPPORT
Users of Microchip products can receive assistance through several channels:
• Distributor or Representative
• Local Sales Office
• Field Application Engineer (FAE)
• Technical Support
• Development Systems Information Line
Customers should contact their distributor, representative or field application engineer
for support. Local sales offices are also available to help customers. A listing of sales
offices and locations is included in the back of this document.
Technical support is available through the web site at: http://support.microchip.com
This chapter provides an overview of the GPIO Expander Keypad and LCD Demo
Board and covers the following topics:
• What is the GPIO Expander Keypad and LCD Demo Board?
• What the GPIO Expander Keypad and LCD Demo Board Kit includes
1.2WHAT IS THE GPIO EXPANDER KEYPAD AND LCD DEMO BOARD?
The GPIO Expander Keypad and LCD Demo Board allows the system designer to
evaluate the operation of the MCP23X17 and MCP23X08 General Purpose I/O (GPIO)
Expanders. The board demonstrates the GPIO Expanders’ performance in a keypad
and LCD example.
1.3WHAT THE GPIO EXPANDER KEYPAD AND LCD DEMO BOARD KIT
INCLUDES
This GPIO Expander Keypad and LCD Demo Board Kit includes:
• One GPIO Expander Keypad and LCD Demo Board (102-00116)
- MCP23008 GPIO Expander with I
- MCP23S08 GPIO Expander with SPI interface (installed)
- MCP23017 GPIO Expander with I
- MCP23S17 GPIO Expander with SPI interface (installed)
• Analog and Interface Products Demonstration Boards CD-ROM (DS21912)
This chapter discusses the setup and operation of the GPIO Expander Keypad and
LCD Demo Board.
The GPIO Expander Keypad and LCD Demo Board is designed to demonstrate using
GPIO expanders in a keypad and LCD example. The MCP23X17 interfaces to a 2x16
LCD module and the MCP23X08 interfaces to a 4x4 keyed matrix.
Both the I
interfaces.
2.2FEATURES
The GPIO Expander Keypad and LCD Demo Board has the following features:
• Two (2) 8-bit GPIO Expanders
- MCP23008 with I
- MCP23S08 with SPI interface
• Two (2) 16-bit GPIO Expanders
- MCP23017 with I
- MCP23S17 with SPI interface
• 4X4 keypad layout (16 momentary buttons)
- Numbers 0 - 9
- Six special function buttons
• A 2X16 LCD module
• Headers for the MCP23X08 and MCP23X17 pins
• Header for programming the PIC18F4550
GPIO EXPANDER KEYPAD
AND LCD DEMO BOARD
USER’S GUIDE
2
C™ and SPI versions are included on the board to demonstrate both serial
GPIO Expander Keypad and LCD Demo Board User’s Guide
2.3GETTING STARTED
The GPIO Expander Keypad and LCD Demo Board is a fully functional, assembled and
tested board for demonstrating the MCP23008 and MCP23017 (I
2
C interface) and
MCP23S08 and MCP23S17 (SPI interface) general purpose I/O expanders. The
following describes the basic setup and operation (see Figure 2-1):
1. Either connect a 9V power supply into the power jack (J2) or connect a 5 V power
supply to the V
and GND test points.
DD
2. The green power LED will illuminate.
3. The LCD will display the startup splash screen.
4. The appropriate LEDs (I
2
C or SPI) will illuminate to indicate the current serial
mode.
5. Pressing buttons:
- 0 - 9, #, *: will be reflected on the LCD
- M: switches modes (I
2
C and SPI) to communicate with the MCP23X17 and
MCP23X08; B: backspace; R: carriage return, and screen clear (2nd
press); S: space
2.4GPIO EXPANDER KEYPAD AND LCD DEMO BOARD DESCRIPTION
2.4.1Major Board Components
The functional block diagram is shown in Figure 2-2.
FIGURE 2-2:FUNCTIONAL BLOCK DIAGRAM
Header
InputOutput
GPIO
OUTIN
2 X 16 LCD
Control
Power
Programming
1. The GPIO BLOCK contains the MCP23X17 and MCP23X08 GPIO Expanders.
Two (2) MCP23X17 devices are connected to the LCD module and two (2)
MCP23X08 devices are connected to the keypad matrix.
A button on the keypad toggles between I
2
C and SPI mode. When in I2C mode,
the MCP23017 and MCP23008 are controlled by the PIC MCU. When in SPI mode, the MCP23S17 and MCP23S08 are controlled. Only one (1) MCP23X08
and one (1) MCP23X17 is on the bus at a time.
2. The CONTROL BLOCK contains the PIC18F4550 and is the main intelligence
in the system.
3. The INPUT BLOCK contains the 4x4 keypad matrix. The MCP23X08 devices
are used to scan the keys.
4. The OUTPUT BLOCK contains the 2x16 LCD. The MCP23X17 devices control
the display.
5. The MCP23X17 and MCP23X08 I/O and serial lines are routed to the HEADER BLOCK to allow the pins to be probed.
6. The PROGRAMMING BLOCK contains the ICSP™ header for programming/debugging the PIC18F4550.
7. The POWER BLOCK contains the MCP1702 5V voltage regulator. The board
can be powered by a 9V supply (connected through the power jack) or by
applying 5V directly to the power points.
GPIO Expander Keypad and LCD Demo Board User’s Guide
2.5FIRMWARE DESCRIPTION
See Figure 2-3 for the main firmware flow diagram.
Main Function:
1. The firmware first configures the PIC MCU.
2. The MCP23X08 and MCP23X17 devices are configured. I
selected first by default. The SPI devices I/O are held in reset.
3. The LCD splash screen is shown.
4. Wait for an interrupt from the MCP23X08. An interrupt will occur when a button
is pressed. Four (4) inputs are configured to interrupt on falling edge. These
inputs are for the “columns” of the keypad matrix.
5. After the interrupt occurs, the firmware calls the Scan_Buttons routine.
6. Then the Update_LCD routine.
Scan_Buttons Function:
1. Read INTCAP register. This register contains a snapshot of the port condition
when the interrupt occurred.
2. Swap inputs and outputs so the rows can be read.
3. Read GPIO register and merge with variable containing INTCAP value.
4. The pressed key is determined by looking up the result in a lookup table.
2
C Devices are
Update_LCD Function:
1. The LCD is updated based on which button was pressed.