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
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 exter
nal interrupts pins (P2.8 - 11).
Figure 1. Multiplexing matrixed keypad with four 7-segment displays
4 x 7-segment displays
P1.0 P1.1 P1.2 P1.3 P1.4 P1.5 P1.6 P1.7
a b c d e
g
DP
LED Module
f
-
P1.8
P1.9 P1.10 P1.11
STR710
P2.8
P2.9
P2.10
P2.11
1.2K
1.2K
1.2K
1.2K
1 4
7 E
0.33K
0.33K
0.33K
NPN
BC 547C
NPN
BC 547C
NPN
BC 547C
23A 5
8 0
4x4 KEYPAD
6 9
F
B C
D
0.33K
NPN
BC 547C
0.12K
0.12K
0.12K
0.12K
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 config ured 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 inter rupt.
-
3/7
Loading...
+ 4 hidden pages