Cypress AN2034 - Manual

Cypress AN2034

Cypress AN2034 – Manual, read for free online in PDF format. We hope this helps you resolve any issues you may have. If you have further questions, please contact us through the contact form.

1 Page 1
2 Page 2
3 Page 3
4 Page 4
5 Page 5
Page: / 5

Table of Contents:

  • Page 2 – PSOC General Purpose IO; Figure 3; Figure 4; Read the port
  • Page 3 – combine them; Using the Output
  • Page 4 – Code 3. Keypad Project Implemented; Debouncing; Write an interrupt handler that calls; Summary
  • Page 5 – Document History; Document Title: User Interface – Keypad Scan, PSoC; OGNE
Loading the manual



User Interface - Keypad Scan, PSoC

®

Style

January 16, 2009

Document No. 001-40409 Rev. *A

1

AN2034

Author

: Dave Van Ess

Associated Project

: Yes

Associated Part Family

: CY8C20x34, CY8C21x23, CY8C21x34

CY8C23x33, CY8C24x23A, CY8C24x94

CY8C27x43, CY8C29x66

GET FREE SAMPLES HERE

Software Version

: PSoC Designer™ 5.0

Associated Application Notes

:

AN2354

Application Note Abstract

X–Y matrix keypads are an inexpensive interface enabling interaction with microcontroller-based products. This application
note shows how the PSoC® microcontroller’s unique I/O structure can build a keypad scan routine that is fast, uses minimal
RAM resources, and operates in a polled or interrupt mode. A function callable by either ‘C’ or assembly language is also
presented.

Introduction

An X-Y keypad enables use of N column lines and M row
lines to detect switch closures for N * M switches. For this
application note, a keypad is defined as an X-Y matrix
where only one key is pressed at a time, as opposed to a
keyboard where simultaneous key closures are the norm
([

Ctrl

] [

Shift

] [

Delete

]). This keypad definition is valid for

telephones, calculators, security entry kiosks, or other
products where only one key is pressed at a time.

This application relies on PSoC General Purpose Input
Output (GPIO).

Rows and Columns

This application note uses C columns and R rows.

Figure

1

shows an example of such a keypad:

Figure 1. 4-Column by 4-Row Keypad

C

0

C

1

C

2

C

3

R

0

R

1

R

2

R

3

[0,0]

[0,1]

[0,2]

[0,3]

[1,1]

[1,0]

[1,2]

[1,3]

[2,0]

[2,1]

[2,2]

[2,3]

[3,0]

[3,1]

[3,2]

[3,3]

Closure of switch [i, j]

(column i, row j)

enables current

flow from row j to column i. This keypad requires only eight
connections to the MCU. The 16 diodes can detect
multiple key closures. However, because PSoC
microcontroller reduces the cost of external components
such as op-amps, filters, and DACs, using 16 diodes is not
a good idea.

Well known techniques have been developed to detect
multiple key presses without diodes.

Figure 2

shows the

keypad without diodes.

Figure 2. The Keypad you can Afford

[0,0]

[0,1]

[0,2]

[0,3]

[1,1]

[1,0]

[1,2]

[1,3]

[2,0]

[2,1]

[2,2]

[2,3]

[3,0]

[3,1]

[3,2]

[3,3]

C

0

C

1

C

2

C

3

R

0

R

1

R

2

R

3

The standard algorithm for reading a keypad is to
individually drive each row and sample the status of all
columns. Correctly combining all this information enables
detection of at least two simultaneous switch closures.
The hardware cost is less but there is software overhead
required to scan all four rows, read column status, and
condense this information into an answer.

To develop a keypad scan that is low in both hardware
and software resources, limit its operation to single-key
presses.

[+] Feedback

[+] Feedback

"Loading the manual" means you need to wait until the file loads and becomes available for online reading. Some manuals are very large, and the time they take to appear depends on your internet speed.

Summary

Page 2 - PSOC General Purpose IO; Figure 3; Figure 4; Read the port

AN2034 January 16, 2009 Document No. 001-40409 Rev. *A 2 PSOC General Purpose IO To detect single-switch closures, use the following algorithm: ƒ Drive all rows simultaneously and read the columns. ƒ Drive all columns simultaneously and read the rows. ƒ Condense this data to determine switch-closure...

Page 3 - combine them; Using the Output

AN2034 January 16, 2009 Document No. 001-40409 Rev. *A 3 Code 1: Subroutine for Reading Keypad ;----------------------------------------- ; Keypad.asm ; ; This routine reads a 4 column by 4 row ; keypad on port1. The status of key ; closures is returned in A. ; ; P1.4 P1.5 P1.6 P1.7 ; C0 C1 C2 C3 ; ...

Page 4 - Code 3. Keypad Project Implemented; Debouncing; Write an interrupt handler that calls; Summary

AN2034 January 16, 2009 Document No. 001-40409 Rev. *A 4 Example Code 3 is the main function that implements the design in Figure 5 on page 3. Code 3. Keypad Project Implemented ;----------------------------------------- ; This program reads the keypad ; at port 1 and control the LEDs ; on port0. ; ...

Other Cypress Models

All Cypress Other