GPIO Expander Keypad and LCD Demo Board User’s Guide © 2006 Microchip Technology Inc.
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.
GPIO EXPANDER KEYPAD AND LCD DEMO BOARD USER’S GUIDE Table of Contents Preface ........................................................................................................................... 1 Introduction............................................................................................................ 1 Document Layout .................................................................................................. 1 Conventions Used in this Guide ....................................
GPIO Expander Keypad and LCD Demo Board User’s Guide NOTES: DS51636A-page iv © 2006 Microchip Technology Inc.
GPIO EXPANDER KEYPAD AND LCD DEMO BOARD USER’S GUIDE Preface NOTICE TO CUSTOMERS 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.
GPIO Expander Keypad and LCD Demo Board User’s Guide CONVENTIONS USED IN THIS GUIDE This manual uses the following documentation conventions: DOCUMENTATION CONVENTIONS Description Arial font: Italic characters Initial caps Quotes Underlined, italic text with right angle bracket Bold characters N‘Rnnnn Text in angle brackets < > Courier New font: Plain Courier New Represents Examples Referenced books Emphasized text A window A dialog A menu selection A field name in a window or dialog A menu path MPLAB
Preface THE MICROCHIP WEB SITE 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.
GPIO Expander Keypad and LCD Demo Board User’s Guide NOTES: DS51636A-page 4 © 2006 Microchip Technology Inc.
GPIO EXPANDER KEYPAD AND LCD DEMO BOARD USER’S GUIDE Chapter 1. Product Overview 1.1 INTRODUCTION 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.
GPIO Expander Keypad and LCD Demo Board User’s Guide NOTES: DS51636A-page 6 © 2006 Microchip Technology Inc.
GPIO EXPANDER KEYPAD AND LCD DEMO BOARD USER’S GUIDE Chapter 2. Installation and Operation 2.1 INTRODUCTION 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.
GPIO Expander Keypad and LCD Demo Board User’s Guide 2.3 GETTING STARTED The GPIO Expander Keypad and LCD Demo Board is a fully functional, assembled and tested board for demonstrating the MCP23008 and MCP23017 (I2C 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 VDD and GND test points. 2.
Installation and Operation 2.4 GPIO EXPANDER KEYPAD AND LCD DEMO BOARD DESCRIPTION 2.4.1 Major Board Components The functional block diagram is shown in Figure 2-2. FIGURE 2-2: FUNCTIONAL BLOCK DIAGRAM Header Input Output IN GPIO OUT 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.
GPIO Expander Keypad and LCD Demo Board User’s Guide 2.5 FIRMWARE 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. I2C Devices are 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.
Installation and Operation FIGURE 2-3: MAIN FIRMWARE FLOW Start Init_MCU Init_MCP Splash NO The MCP23X08 is configured to interrupt on falling edge for the columns (4 inputs) GPIO INT Flag Set? YES Scan_Buttons After the interrupt, the column location of the button is known and is contained in INTCAP. Need to read GPIO to get the Row location. Buttons: 0-9, #, * : Copied to the LCD M: Toggle mode (SPI and I2C™) B: Backspace R: Carriage Return S: Space Update_LCD © 2006 Microchip Technology Inc.
GPIO Expander Keypad and LCD Demo Board User’s Guide FIGURE 2-4: KEYPAD SCAN Scan_Buttons Read INTCAP One nibble is set to input and the other nibble is output (to read the columns) (already configured before entering function). Read INTCAP and place in a variable. To read the rows. Swap inputs and outputs Merge with variable containing INTCAP value. The result can be looked up in a table (switch statement) to determine which key was pressed.
Installation and Operation FIGURE 2-5: LCD UPDATE Update_LCD The pressed button result comes from the variable in the Scan_Buttons function 1-9 # Button Press? M B S * R Display Backspace Toggle Serial Mode (I2C or SPI) Space Carriage Return Display # Display * END © 2006 Microchip Technology Inc.
GPIO Expander Keypad and LCD Demo Board User’s Guide NOTES: DS51636A-page 14 © 2006 Microchip Technology Inc.
GPIO EXPANDER KEYPAD AND LCD DEMO BOARD USER’S GUIDE Appendix A. Schematics and Board Layouts A.1 INTRODUCTION This appendix contains the schematic and PCB layout for the GPIO Expander Keypad and LCD Demo Board. Diagrams included: • Board Schematics - Pages 1 - 3. • Board - Top Layer (with silk screen) • Board - Bottom Layer © 2006 Microchip Technology Inc.
GPIO Expander Keypad and LCD Demo Board User’s Guide BOARD SCHEMATIC - PAGE 1 M A.2 DS51636A-page 16 © 2006 Microchip Technology Inc.
Schematics and Board Layouts BOARD SCHEMATIC - PAGE 2 M A.3 © 2006 Microchip Technology Inc.
GPIO Expander Keypad and LCD Demo Board User’s Guide BOARD SCHEMATIC - PAGE 3 M A.4 DS51636A-page 18 © 2006 Microchip Technology Inc.
Schematics and Board Layouts A.5 BOARD - TOP LAYER (WITH SILK SCREEN) A.6 BOARD - BOTTOM LAYER © 2006 Microchip Technology Inc.
GPIO Expander Keypad and LCD Demo Board User’s Guide NOTES: DS51636A-page 20 © 2006 Microchip Technology Inc.
GPIO EXPANDER KEYPAD AND LCD DEMO BOARD USER’S GUIDE Appendix B. Bill Of Materials (BOM) TABLE B-1: BILL OF MATERIALS Reference Designator Qty Description Manufacturer Part Number 23 C1, C5, C6 CAP 1UF 16V CERAMIC Y5V 0805 C15, C25, C30, C31, C32, C33, C34, C35, C36, C37, C38, C39, C40, C41, C42, C43, C44, C45, C46, C47, C48 Panasonic® - ECG ECJ-2VF1C105Z 1 C3 CAP CER .
GPIO Expander Keypad and LCD Demo Board User’s Guide TABLE B-1: BILL OF MATERIALS (CONTINUED) Reference Designator Qty Description Manufacturer Part Number 16 R32, R33, R34, RES 100 OHM 1/10W 3900PPM R36, R37, R38, 5%0805 R39, R40, R41, R42, R43, R44, R45, R46, R47, R48 Panasonic - ECG 1 R49 RES 33.
Bill Of Materials (BOM) NOTES: © 2006 Microchip Technology Inc.
WORLDWIDE SALES AND SERVICE AMERICAS ASIA/PACIFIC ASIA/PACIFIC EUROPE Corporate Office 2355 West Chandler Blvd. Chandler, AZ 85224-6199 Tel: 480-792-7200 Fax: 480-792-7277 Technical Support: http://support.microchip.com Web Address: www.microchip.