| The Datasheet Archive - 100 Million Datasheets from 7500 Manufacturers. |
DragonBall Operation Application Note Minimum Matrix Keyboard wit
Top Searches for this datasheetOrder this document DragonBall Operation Application Note Minimum Matrix Keyboard with DragonBallEZ328 INTRODUCTION Freescale Semiconductor, Inc. This note describes method interfacing matrix keyboard EZ328 using minimum number ports. matrix keypad example. requires only five ports. general, takes ports interface matrix keyboard). cost solution. logic used. components mainly used interfacing circuitry include only diodes resistors which greatly reduce system cost size product. following sections, both hardware software will discussed detail. HARDWARE Figure shows functional block diagram keyboard interface. seen this diagram, there major parts. Interrupt interfacing Circuity generates interrupt EZ328 when there pressed provides connection EZ328's ports Keyboard matrix matrix keypad Figure illustrates detailed circuity matrix keyboard interface. This document contains information product under development. Motorola reserves right change discontinue this product without notice. SEMICONDUCTOR PRODUCT INFORMATION 1996 Motorola, Inc. Rights Reserved. More Information This Product, www.freescale.com Freescale Semiconductor, Inc. Interrupt interfacing Circuit PD7/IRQ EZ328 Matrix keyboard Figure Block diagram keyboard interface DragonBallMC68328 Application Notes MOTOROLA More Information This Product, www.freescale.com Freescale Semiconductor, Inc. Figure Schematic Drawing keyboard interface MOTOROLA DragonBallMC68328 Application Notes More Information This Product, www.freescale.com Interrupt interfacing Circuit interrupt interfacing circuit includes some diodes, resistors, pull-up resistors transistor. transistor part designed inverter generating interrupt signal EZ328 when there pressed. There groups diodes mainly restricting signal flow single direction enable this circuitry identify pressed uniquely. these groups diodes have been wired together provide "OR" function which turn allows pressed each column keypad signal transistor part generating interrupt. Parallel Ports Interface Freescale Semiconductor, Inc. This solution demonstrates simple mechanism build keyboard with minimum port used. this application, matrix keypad example. requires only five ports interfacing. them used generating interrupt signal beginning used port scanning operation afterwards. Detail method scanning identifying pressed will discussed section "SCAN KEYOperation". should also noted that this design, EZ328 uses five ports interfacing only them requires interrupt capability. SCAN OPERATION Five ports used scanning function this system. them (PD7) used interrupt before pressed. Before scanning process starts, ports except with interrupt capability configured output high. Then, when there pressed, columns keypad changes state from high. columns keypad wired together form "OR" logic base transistor, will generate active interrupt signal EZ328 initiates interrupt handler scan pressed key. When scanning process begins, five ports will configured output high while other ports configured input. states ports then read compared with pattern recorded predefined lookup table order locate which pressed. found, another port will configured output high instead read states again. This process repeated until ports have been configured once output high found. Since circuitry provides feedback paths, input port will change state from high output high port states obtained identify uniquely which being pressed. example scanning procedure illustrated follows: DragonBallMC68328 Application Notes MOTOROLA More Information This Product, www.freescale.com example scanning keyboard PD7(IR DESCRIPTION port programmed output High. configured interrupt port interrupt only when there active-low level interrupt. Assume pressed. E.g. "8". base transistor will change state from default High. will change accordingly from High Low. interrupt generated scanning process starts. first port configured output high while other ports changed input When reading data register, 10001 obtained that pattern does match with key. pressed still found. Proceed next step. second port configured output high while other ports changed input. port connecting key"8", both ports state high. that time, pattern "00110" read from data register identifies uniquely key"8" Freescale Semiconductor, Inc. Output Input Level High Level Special case There some keys with both ends connecting same port. This still detected. this case, interrupt goes together with other ports reading low. (i.e. PB3-6=0) Software software part written language used Standard Library. Fputc.c used implement input output which interacts with user through debugger. flowcharts shown Figure show flow initalization interrupt service rountine respectively. initialization part initialize Port Direction Register, Data Register, Select Register, Interrupt Pending Register, Interrupt Mask Register that receive interrupt from keyboard. interrupt service routine, ports output rest ports input detect which keys pressed. Value Port Data Register read compare with expected value each character lookup table that found which pressed. MOTOROLA DragonBallMC68328 Application Notes More Information This Product, www.freescale.com Start Initialize port PD3-6 port. This done setting bits Port Select Register high. Freescale Semiconductor, Inc. Initialize interrupt (IRQ6). This done setting Port Select Register low. Initialize PD3-6 output ports while input ports. This done initializing Port Direction Register. PD3-6 high help interrupt generation keypad. This done setting bits3-6 Port Data Register high. Clear Interrupt Pending Register unmask IRQ6 Interrupt Mask Register. interrupt table perform while loop wait interrupt from keypad. Figure Keyboard interface configuration flowchart DragonBallMC68328 Application Notes MOTOROLA More Information This Product, www.freescale.com Start Disable interrupt Check whether interrupt made keyboard. Select PD3-7 port output PD4-7 input Back main Freescale Semiconductor, Inc. Check Port Data Register matches keys row? output PD3,5-7 input Check Port Data Register matches Print keys row? character output PD3,4,6,7 input Check Port Data Register matches keys row? output PD4-7 input Check Port Data Register matches keys row? Reset interrupt PD3-6 output high Enable interrupt return while loop wait interrupt again Figure Flowchart Interrupt Service Routine MOTOROLA DragonBallMC68328 Application Notes Print character Print character Print character More Information This Product, www.freescale.com SOURCE CODE #include <stdio.h> typedef unsigned char typedef unsigned U32; typedef *P_U8; typedef *P_U32; unsigned data unsigned data unsigned data unsigned data #define M328_IVR 0xfff300 0xfff304 0xfff30C 0xfff310 Interrupt Vector Interrupt Mask Interrupt Status Interrupt Pending Port Direction Port Data Port Pullup Enable Port Select Port Enable Postion Vector Level Freescale Semiconductor, Inc. #define M328_IMR #define M328_ISR #define M328_IPR #define M328_PDDIR 0xfff418 #define M328_PDDATA 0xfff419 #define M328_PDPUEN 0xfff41A #define M328_PDSEL 0xfff41B #defin M328_PDIRQEN 0xfff41D #define LEVEL6V ((volatile long 0x118) data; tmp, pendReg, count=12000; void delay(U32 time) while(time-); DELAY loop*/ #pragma interrupt() void KeyIRQ(void) asm(" ORI.W #$0700,SR"); Disable Interrupt pendReg=*(P_U32)M328_IPR; pendReg ~(0x00f7ffff); Mask other bits except IRQ6 DragonBallMC68328 Application Notes MOTOROLA More Information This Product, www.freescale.com if(pendReg==0x80000) Check whether interrupt from keyboard *(P_U8)M328_PDDIR 0x08; delay(count); *(P_U8)M328_PDSEL 0xf8; *(P_U8)M328_PDDATA 0x08; Select output PD4-7 input delay Select PD3-7 Select high Freescale Semiconductor, Inc. switch(*(P_U8)M328_PDDATA) case 0x0d: printf("9\n"); break; case 0x1d: printf("A\n"); break; case 0x2d: printf("B\n"); break; case 0x4d: printf("C\n"); break; /*Check whether matches with keys row*/ *(P_U8)M328_PDDIR 0x10; delay(count); *(P_U8)M328_PDDATA 0x10; Select output PD3,5-7 input delay Select high switch(*(P_U8)M328_PDDATA) case 0x1d: printf("6\n"); break; case 0x15: /*Check whether matches with keys row*/ MOTOROLA DragonBallMC68328 Application Notes More Information This Product, www.freescale.com printf("7\n"); break; case 0x35: printf("8\n"); break; case 0x55: printf("D\n"); break; Freescale Semiconductor, Inc. *(P_U8)M328_PDDIR 0x20; delay(count); *(P_U8)M328_PDDATA 0x20; Select output PD3,4,6,7 input delay Select high switch(*(P_U8)M328_PDDATA) case 0x2d: printf("3\n"); break; case 0x35: printf("4\n"); break; case 0x25: printf("5\n"); break; case 0x65: printf("E\n"); break; /*Check whether matches with keys row*/ *(P_U8)M328_PDDIR 0x40; delay(count); *(P_U8)M328_PDDATA 0x40; Select output PD3-5,7 input delay Select high DragonBallMC68328 Application Notes MOTOROLA More Information This Product, www.freescale.com switch(*(P_U8)M328_PDDATA) case 0x4d: printf("0\n"); break; case 0x55: printf("1\n"); break; /*Check whether matches with keys row*/ Freescale Semiconductor, Inc. case 0x65: printf("2\n"); break; case 0x45: printf("F\n"); break; *(P_U8)M328_PDSEL ~(0x80); *(P_U8)M328_PDDIR 0x78; *(P_U8)M328_PDDIR ~(0x80); *(P_U8)M328_PDDATA 0x78; Select interrupt PD3-6 output input PD3-6 high asm(" ANDI.W #$F0FF,SR"); Enable Interrupt void KeyIRQInit(void) asm(" ORI.W #$0700,SR"); *(P_U8)M328_IVR=0x40; *(P_U32)M328_ISR ~(0x00080000); *(P_U8)M328_PDSEL 0x78; *(P_U8)M328_PDSEL ~(0x80); *(P_U8)M328_PDPUEN 0xff; Disable Interrupt Setup Interrupt Vector Reset Select PD3-6 Select interrupt Enable Pullup MOTOROLA DragonBallMC68328 Application Notes More Information This Product, www.freescale.com *(P_U8)M328_PDIRQEN 0x80; *(P_U8)M328_PDDIR 0x78; *(P_U8)M328_PDDIR ~(0x80); *(P_U8)M328_PDDATA 0x78; *(P_U32)M328_IPR ~(0x00080000); *(P_U32)M328_IMR ~(0x00080000); *LEVEL6V (U32)KeyIRQ; Disable INT3 PD3-6 output input PD3-6 high Clear Pending Register UnMask IRQ6 Setup Interrupt Table asm(" ANDI.W #$F0FF,SR"); Enable Interrupt Freescale Semiconductor, Inc. KeyTest(void) printf("\nKeypad Test\n"); printf("================\n"); printf("\n.Pls press Keypad.\n"); KeyIRQInit(); while(1); asm(" ORI.W #$0700,SR"); Disable Interrupt void main(void) KeyTest(); DragonBallMC68328 Application Notes MOTOROLA More Information This Product, www.freescale.com Other recent searchesXYN2LUY11D - XYN2LUY11D XYN2LUY11D Datasheet TLV271 - TLV271 TLV271 Datasheet TLV272 - TLV272 TLV272 Datasheet TLV274 - TLV274 TLV274 Datasheet SN74ALVCHG162280 - SN74ALVCHG162280 SN74ALVCHG162280 Datasheet SM75570 - SM75570 SM75570 Datasheet UL1950 - UL1950 UL1950 Datasheet EN60950 - EN60950 EN60950 Datasheet NX8045GB - NX8045GB NX8045GB Datasheet NJM41035 - NJM41035 NJM41035 Datasheet NJM41035RB1T - NJM41035RB1T NJM41035RB1T Datasheet KGA4165 - KGA4165 KGA4165 Datasheet DFM1200FXM18-A000 - DFM1200FXM18-A000 DFM1200FXM18-A000 Datasheet 2SC2712 - 2SC2712 2SC2712 Datasheet 2SA1162 - 2SA1162 2SA1162 Datasheet
Privacy Policy | Disclaimer |