ST AN1799 Application note

AN1799

APPLICATION NOTE

STR71x GPIO

SCANNING A 4x4 MATRIX KEYPAD

INTRODUCTION

The aim of this application note is to show how to scan the 4x4 matrix keypad multiplexed with a four 7-segment display. The software attached to this application note scans the pressed key and displays it on the multiplexed 7- segment LEDs.

This application note describes how the interrupt capability of the STR710 device is used to offer a better key scan.

Rev. 2

AN1799/0205

1/7

1

ST AN1799 Application note

STR71x GPIO SCANNING A 4x4 MATRIX KEYPAD

1 HARDWARE LAYOUT

A 4x4 keypad can be very easily interfaced to the STR710’s PORT1 & PORT2 (Figure 1). Eight lines (P1.0 - 7) are assigned to LED segments. Four lines (P1.8 - 11) are used to drive and select the 7-segment displays through sink transistors. The same lines are used for pressed key checking. Keypad rows are connected with pull-down resistors to the four external interrupts pins (P2.8 - 11).

Figure 1. Multiplexing matrixed keypad with four 7-segment displays

 

 

 

4 x 7-segment displays

 

P1.0

a

 

 

 

 

 

b

 

 

 

 

 

P1.1

 

 

 

 

 

c

 

 

 

 

 

P1.2

 

 

 

 

 

d

 

 

 

 

 

P1.3

 

 

 

LED Module

 

e

 

 

 

 

P1.4

 

 

 

 

f

 

 

 

 

 

P1.5

 

 

 

 

 

g

 

 

 

 

 

P1.6

 

 

 

 

 

DP

 

 

 

 

 

P1.7

 

 

 

 

 

 

 

 

 

 

 

 

1.2K

0.33K

0.33K

0.33K

0.33K

 

P1.8

NPN

 

 

 

 

1.2K

 

 

 

 

P1.9

BC 547C

NPN

 

 

 

1.2K

 

 

 

P1.10

 

BC 547C

NPN

 

 

1.2K

 

 

 

STR710

P1.11

 

 

BC 547C

NPN

 

 

 

 

 

 

 

 

 

BC 547C

 

 

 

 

 

 

 

P2.8

 

 

 

 

0.12K

 

1

2

3

A

0.12K

 

P2.9

 

4

5

6

B

 

 

P2.10

0.12K

 

7

8

9

C

0.12K

 

P2.11

 

E

0

F

D

 

 

 

 

 

 

 

4x4 KEYPAD

 

 

2/7

2

STR71x GPIO SCANNING A 4x4 MATRIX KEYPAD

2 STR710 CONFIGURATION

This part is dedicated to show the STR710 Microcontroller configuration. The STR710 is used since it offers the possibility to use external interrupts.

2.1 GPIO PORT CONFIGURATION

Rows are connected to P2.8-11 pins configured as Input Pull Up /Pull Down Weak Push-Pull mode. For the columns, the sink transistors base pins are connected to P1.8-11 pins configured as Output Push-Pull. External interrupts are triggered by a high level applied to a pin of P2.8-11 (caused by a pressed key), they generate an interrupt on the external interrupt (XTI) channel and can wakeup the system from STOP mode.

P1.0-7 configured as Output Push-Pull to send the value of the pressed key to the desired 7 segment display.

2.2 XTI CONFIGURATION

The External Interrupts Unit (XTI) manages 14 external interrupt lines.

In this aplication the XTI is configured to generate interrupts when a rising edge is detected on line 2-5; any transition from low to high level on the P2.8-11 pins will trigger an external interrupt.

3/7

Loading...
+ 4 hidden pages