This application note describes a simple interfac e for keyboard entry to the SA253x fam ily via a Microcontroller. It
also includes hardware description , flowchart and a software example based on the 80Cxx - family of
Microcontrollers.
2 Key Features
•
only 5 outputs and 1 input required from µC for handshake to access all keys in the SA253x keyboard matrix
•
universal interface, not restricted to specific Microcontrollers
•
supports both 3V- and 5V- µCs
•
same hardware for all single chip telephones : SA2531/2
•
same software for all single chip telephones, only key labels must be replaced
3 OTHER APPLICABLE DOCUMENTS AND PAPERS......................................................................................................................................1
4 REVISION STATUS .........................................................................................................................................................................................2
5 GENERAL DESCRIPTION ...............................................................................................................................................................................2
14 LIABILITY AND COPYRIGHT STATEMENT................................................................................................................................................13
3 Other applicable documents and papers
1. Data Sheet SA2531, SA2532
2. Pin-out Comparison SA2531/2
3. Product Presentation
4. Single Chip Telephone Evolution (Apr. 16, 1996)
The interface m ust be capable of forcing the keyboard rows (hereafter indicated as R1...R4) both low (Vss) and
high (V
is forced at the sam e time while the remaining rows/columns m ust be high ohmic (her eafter indicated as Hi Z).
Since only one row/column must be driven at the same tim e, a decoder (IC5 = 74138) was implem ented to save
pin count of the µC. 3 output ports were used for row/colum n selection, 1 output port to disable all rows/columns
and 1 output port for the 3-state buffer inputs to select forcing high or low .
One µC pin must be configured as input for handshake.
If 9 output + 1 input pins are available from the µC (8 row/column selectors, 1 force hi/lo selector , 1 handshake
input) , IC5 = 74138 can be omitted.
IC3 & 4 (=74HC125) are separately addressable 3-state buffers.
A simple discrete NOR gate (Q1,D2,D3,R9..11) is used for synchronization.
) and forcing the keyboard columns (hereafter indicated as C1...C4) to high (VDD). Only one row or column
DD
6 Hardware configuration
The SA253x Single Chip Telephone can be connected to a µC for key entry when the following conditions are met:
Supply voltage: The SA253x works at 4V V
, its high/low input levels are 30/70% VDD.
DD
If the µC is supplied with >4V a current limiter (serial resistor) must be added to the row/column pins of the
SA253x.
If the µC supply is <4V it must provide adequate high level (> 70%V
of SA253x = >2.8V)
DD
Row driver : 4 Tristate output pins, each separ ately adjustable as either output (H i/Lo) or tris tate . Only one row is
driven at the same time, all other rows/columns are high ohmic.
Column driver: Tris tate output pins, each s eparately adjustable as either output (H i) or tris tate. Only one colum n is
driven at the same time, all other rows/columns are high ohmic.
Synchronization: The SA253x is intentionally designed for low standby power, so no oscillator is running as long as
no key is pressed. All the external row/column driving is done asynchronously. The scanning sequence is
synchronized by triggering a rising edge on specific columns (see table 1).
Therefore a 1-bit input must be provided for the synchronization.
7 Application schematic:
See also: Appendix A:
One solution which only requires 5 output pins and 1 input pin is shown in the attached schem atic. A comm on µC
(80C51-family) is used. This controller is widely known, so both hardware and software description in this
application note should be easily understood which simplifies adaption to any other controller.
The rows/columns are driven by 8 separately selectable tristate buffers (e.g. 74HC125). Power supply is 5V,
therefore resistors R2...R8 are necessary to provide adaption to the 4V-logic of the SA253x.
R1 is always connected by a 5kOhms resistor to prevent c ollis ion of two outputs when it initiates the key entry in an
unsynchronous state.
2/13
same s
same s
same ssame s
Page 3
SAN3010
Since only one row/column is forced high or low at the sam e tim e the num ber of µC output port pins c an be lim ited
by using a 1-of-8 decoder (74HC138). The 3 bits (A,B,C, respectively Port1 pins 0..2) select the appropriate
row/column, Port 1.4 disables all outputs.
The selected row/column is forced high or low depending on the state of Port1.5 .
Port 1.7 is used as input to detect the acknowledge of the SA253x during the sc anning phase. Acknowledge is
done by the rising edge of either C1,C2,C3 or C4.
The detection logic can be simplified by just monitoring C1 and C2, because one of both can always be used for
detection (see table 1, ColY).
Diode D1 is necessary to prevent collision of two outputs when Port1 is in output mode. Since Port1 of the 80C31 is
an open-drain output a diode can be used. For other controllers, using standard I/O , a resistor must be used in
place of the diode.
8 Scanning table/flowchart
See also: Appendix B:
The interfacing procedure is shown in the attached flowchart, additional information is given below:
1) Key entry can only occur, when the SA253x has been off-hook for >20ms.
2) Internal key scanning of the SA253x is started when any Row (in our case: R1) has been forced low, then the
acknowledge by the SA253x is done by moving specific col-pins high.
3) When this Lo/Hi transition is detected by the µC the asynchronous timing must be started.
4) SCAN1 and SCAN 2 are the time slots at which a certain row must be forced high (SCAN1) and f orced low
(SCAN 2 ) , at time slot SCAN3 a certain column must be forced high. The key entry corresponding Row and
Column is shown in table 1. Between the SCAN1..3 time slots all rows and columns must be high ohmic (see
flowchart).
5) a valid key entry is accepted, when the SCAN1..3 procedure has been repeated 9 times.
6) a certain constant delay must be added between key entries. The only exception is, when memory keys are
cascaded. In this special cas e, entering a subsequent memory key is only accepted, when the previous m emory
has been fully dialed out.
9 Sample software
See also: Appendix C:
Attached is a sample software program, written in 8051 Assem bler language which incorporates all the nec essary
timing and correct row/column selection. The only entry is to load the accumulator with a key code and then make a
subroutine call.
See Table 1 for appropriate key codes when using either SA2531-2
The assembler command lines are well described, so it should be easily understood.
Again, adaption to other controllers based upon this software should be no problem.
Care must be taken when using a different system clock speed. In this case the delay blocks must be recalculated
based on the number of machine cycles used.
PAGE 6
LOC OBJ LINE SOURCE
40BB 07
40BC 88 224 db disable,Row3,Col1 ; keycode= 24
40BD 02
40BE 04
40BF 88 225 db disable,Row3,Col2 ; keycode= 25
40C0 02
40C1 05
40C2 88 226 db disable,Row3,Col3 ; keycode= 26
40C3 02
40C4 06
40C5 88 227 db disable,Row3,Col4 ; keycode= 27
40C6 02
40C7 07
40C8 88 228 db disable,Row4,Col1 ; keycode= 28
40C9 03
40CA 04
40CB 88 229 db disable,Row4,Col2 ; keycode= 29
40CC 03
40CD 05
40CE 88 230 db disable,Row4,Col3 ; keycode= 30
40CF 03
40D0 06
40D1 88 231 db disable,Row4,Col4 ; keycode= 31
40D2 03
40D3 07
232
233
234 end
REGISTER BANK(S) USED: 0
ASSEMBLY COMPLETE, NO ERRORS FOUND
12/13
same s
same s
same ssame s
Page 13
SAN3010
14 Liability and Copyright Statement
Disclaimer:
Micro-Electronic Systems (Pty) Ltd ("SAMES”) and may not be copied or disclosed to a third party, in whole or in
part, without the express written consent of SAMES. T he information c ontained herein is current as of the date of
publication; however, delivery of this document shall not under any circum stances cr eate any implication that the
information contained herein is correct as of any time subsequent to such date. SAMES does not undertake to
inform any recipient of this docum ent of any changes in the information contained herein, and SAMES express ly
reserves the right to make changes in such inform ation, without notification,even if such changes would render
information contained herein inaccurate or incomplete. SAMES makes no representation or warranty that any
circuit designed by reference to the inform ation contained her ein, will func tion without error s and as intended by the
designer
.
The information contained in this document is confidential and proprietary to South African
South African Micro-Electronic Systems (Pty) Ltd
P O Box 15888,33 Eland Street,
Lynn East,Koedoespoort Industrial Area,
0039Pretoria,
Republic of South Africa,Republic of South Africa