AN204826 F²MC-16FX Family MB96340 Key Matrix Interface using I/O Port.pdf

AN204826
F²MC-16FX Family, MB96340 Key Matrix Interface using I/O Port
This application note describes how to interface a 3x3 keyboard matrix to an MCU of 16FX Family and demonstrates
how to decode the key-press using the scanning technique.
Contents
1
Introduction ...............................................................1
1.1
Connection Diagram ........................................1
1.2
Key Matrix Functionality and Limitation ...........3
2
Operation ..................................................................3
2.1
Key Matrix (1-9) Scanning ...............................4
2.2
Key „0‟ ..............................................................7
2.3
Display Key ......................................................7
3
Resource Usage .......................................................7
3.1
Reload Timer ...................................................7
3.2
I/O Port ............................................................7
1
3.3
External Interrupt ............................................. 7
Example Code .......................................................... 8
4.1
Initialization Routines ....................................... 8
4.2
Functionality Routines ................................... 10
4.3
Main Function ................................................ 16
4.4
Interrupt Service Routines ............................. 18
4.5
Interrupt Vector .............................................. 20
5
Additional Information ............................................. 20
6
Document History ................................................... 21
4
Introduction
This application note describes how to interface a 3x3 keyboard matrix to an MCU of 16FX Family and demonstrates
how to decode the key-press using the scanning technique. The number corresponding to the pressed key would be
displayed on the 7-Segment Display. Other than the key matrix it also contains a separate key connected to external
interrupt pin INT0. The functionality of this key is similar to Power On button.
Such kind of arrangement can be used in the industrial or automotive application usually for numeric key entry.
1.1
Connection Diagram
The Figure 1 shows the connection diagram. The key „0‟ is connected to the external interrupt pin INT0. This key is
used to wake the microcontroller up from the STOP mode to RUN mode and also vice a versa. The pull up resistor
RPU is connected to limit the current when the key „0‟ is pressed. The capacitor is used to eliminate the bouncing of
the key „0‟.
www.cypress.com
Document No. 002-04826Rev.*A
1
F²MC-16FX Family, MB96340 Key Matrix Interface using I/O Port
Figure 1. Key Matrix Connection Diagram
Vcc
RPU
0
P07_0/INT0
C
P01_5
P01_4
P01_3
1
MB9634x
2
3
P01_2
4
5
6
7
8
9
RPD
RPD
P01_1
P00_0
P00_1
P00_2
P00_3
P00_4
P00_5
P00_6
P00_7
P01_0
RPD
Vcc
R
a
R
R
b
c
D
d
e
R
R
R
f
g
DP
R
R
A
A
7-Segment Display
www.cypress.com
Document No. 002-04826Rev.*A
2
F²MC-16FX Family, MB96340 Key Matrix Interface using I/O Port
The keyboard matrix containing keys „1‟ to „9‟ is connected to I/O port P01. This arrangement (as shown above)
results in significant resource saving with a little software overhead. The port pins P01_0 to P01_2 are scan lines
hence those are configured as digital outputs, whereas the port pins P01_3 to P01_5 are return lines hence those are
configured as digital inputs. The pull-down resistors RPD are connected to limit the current when any key within this
matrix is pressed.
The common anode 7-Segment display is interfaced to the Port 0 via current limiting resistors (R). It is used to display
the number of the pressed key.
1.2
Key Matrix Functionality and Limitation
The key matrix software is only able to detect a single key press at one instance. It is not capable of handling multiple
simultaneous key presses. However such functionality can be added later, if required.
2
Operation
The below block diagram depicts the peripheral operation and dependency.
Figure 2. Key Matrix Block Diagram
Scan Lines
Key Matrix
I/O Port
Return Lines
MB9634x
External
Interrupt
Falling Edge
I/O Port
www.cypress.com
Document No. 002-04826Rev.*A
7
Segment
Display
3
F²MC-16FX Family, MB96340 Key Matrix Interface using I/O Port
2.1
Key Matrix (1-9) Scanning
One scan (digital output - P01_0) line is set to HIGH at one instance while the other two scan lines are kept LOW and
the return (digital input) lines are checked; if any key is pressed then the corresponding return line would be HIGH.
Then after the scanning interval of 5 ms (which is configurable) the next scan line (P01_1) is set to HIGH while the
other two scan lines are kept LOW and the return lines are checked. Then the same process is repeated for the last
scan line (P01_2) after the scanning interval. After the last scan line the process would start all over again from the
first scan line (P01_0) after the scanning interval. The details about the key scan interval are discussed in section
2.1.1.
The following table shows the keys and the corresponding key code (data on the Port 01):
Table 1. Key Codes
Return Lines
Scan Lines
Key Pressed
Key Code
P01_5
P01_4
P01_3
P01_2
P01_1
P01_0
“1”
0
0
1
1
0
0
0x0C
“2”
0
1
0
1
0
0
0x14
“3”
1
0
0
1
0
0
0x24
“4”
0
0
1
0
1
0
0x0A
“5”
0
1
0
0
1
0
0x12
“6”
1
0
0
0
1
0
0x22
“7”
0
0
1
0
0
1
0x09
“8”
0
1
0
0
0
1
0x11
“9”
1
0
0
0
0
1
0x21
The PDR01 register needs to be read to get these key codes.
With reference to the above table, let us consider that key “3” is pressed. To detect this key press the scan line
P00_2 needs to be HIGH and the return line P00_5 would become HIGH, since the key connects these two lines
once it is pressed. Hence the key code “0x24”.
2.1.1
K e y- D e b o u n c e
The mechanical keys do not open or close cleanly. When a key is pressed it makes and breaks contacts several
times before settling into its final position. This causes several transitions or bounces to occur. The bounce
period/time varies from key to key. This behavior is described in the below figure:
Figure 3. Key Bounce
Contact Bounce
Period
1
0
Switch Activated
www.cypress.com
Document No. 002-04826Rev.*A
4
F²MC-16FX Family, MB96340 Key Matrix Interface using I/O Port
The above discussed phenomena can be taken care of by using software de-bouncing technique as described below.
Below steps explain the de-bouncing and the decision making logic involved in order to determine the key-press or
key-release:
1.
The key scanning interval is dependent on and needs to be less than the bounce time/debounce delay of the
key/switch. Here the scanning interval is chosen such that the debounce delay is always multiple of the scanning
interval i.e. the scanning interval in this case is 5 ms and the debounce delay is considered as 20 ms.
2.
The return lines are polled / checked just once while a particular scan line is selected. If any of the return line is
found HIGH, while a particular scan line is selected (HIGH), the corresponding key code is stored.
3.
After the de-bounce delay of 20 ms if the same return line is found HIGH (while same scan line is selected
(HIGH)), then the corresponding key is declared to be pressed (i.e. the corresponding key-code would be
reflected in the variable validkey). Within this de-bounce delay any other key presses would be ignored, if any.
4.
After the de-bounce delay, the variable validkey would continue to reflect the same key code, unless and until
the same key is released or another key is pressed.
5.
After the de-bounce delay another scan line would be selected and the steps 2 to 4 would be repeated, if
required.
6.
If in the step 2, no return line would be found HIGH then another scan line would be selected.
7.
If no key is found pressed or the pressed key is released then the validkey would have value equal to NONE.
It should be noted that the multiple simultaneous key presses would not be taken care in this approach.
The following figure explains the key-matrix scanning with key de-bounce:
www.cypress.com
Document No. 002-04826Rev.*A
5
F²MC-16FX Family, MB96340 Key Matrix Interface using I/O Port
Figure 4. Key-matrix Scanning with Key De-bounce
www.cypress.com
Document No. 002-04826Rev.*A
6
F²MC-16FX Family, MB96340 Key Matrix Interface using I/O Port
2.2
Key ‘0’
Normally pin INT0 is at high level, once the key „0‟ is pressed, then the falling edge would appear on INT0 pin. This
generates an interrupt.
As shown in the connection diagram, the de-bouncing of the key „0‟ is taken care by the RC circuit comprises of R PU
and C (instead of the software de-bouncing as discussed above). The values of these should be chosen such that the
product of RC (RPU*C) is longer than the expected bounce time of the key. However, this puts a limitation on the rate
of recurrence of the key press.
2.3
Display Key
The key which is pressed currently would be reflected on the 7-Segment Display connected to Port 00. That means if
„1‟ is pressed, 7-Segment Display would display ”1” (i.e. segments b and c would be lit). If „2‟ is pressed, it would
display ”2” (i.e. segments a, b, e, d and g would be lit), so on and so forth. If no key is pressed then it would not
display anything. And in case of multiple simultaneous (invalid) key press, it would display “E.” (Error).
3
Resource Usage
3.1
Reload Timer
The Reload Timer 0 (RLT0) is used as the time base for key matrix scanning. RLT0 is configured to issue an interrupt
at an interval of 5 ms at 16 MHz CLKP1. It should be chosen such that the de-bounce delay of the keys is always
multiple of this scanning interval as discussed before. Here the de-bounce delay is considered as 20 ms.
In the RLT0 interrupt service routine (ISR) the scanning interval flag time_5ms is made TRUE so as to indicate the
scanning function that the delay of 5 ms is elapsed and it should carry out the scanning again.
The below figure describes the behavior described above:
Figure 5. Reload Timer Ticks and ISR
5 ms
RLT0 ISR
TRUE
TRUE
TRUE
TRUE
TRUE
TRUE
flag
The time_5ms would be made FALSE within the scanning function Scan_Key() once it is executed.
3.2
I/O Port
The Port 00 is used for displaying the information related to the currently pressed key.
The Port 01 is used for key matrix scanning. Port pins P01_0 to P01_2 are configured as output and the port pins
P01_3 to P01_5 configured as input.
3.3
External Interrupt
The external interrupt pin 0 (INT0) is connected to key „0‟. The INT0 pin is configured to generate an interrupt at every
falling edge.
In the INT0 ISR then the request is made to switch to STOP mode or RUN mode depending upon the current
operating mode. However, the transition from one mode to the other would happen in the function Ctrl_Power().
www.cypress.com
Document No. 002-04826Rev.*A
7
F²MC-16FX Family, MB96340 Key Matrix Interface using I/O Port
The reason for this is, if the STOP mode is requested in the INT0 ISR itself then, after the wakeup, the CPU would
execute the next instruction from where it was interrupted before going STOP mode. Because of this the software
may take decision based on the old context (context before entering STOP mode) which may be erroneous / invalid
after the wakeup
4
Example Code
4.1
Initialization Routines
4.1.1
Flowchart
InitExtInt0()
InitReloadTimer0()
Enable digital input on Ext.
INT0 (P07_0)
Set the RLT0 Reload value to 4999
Configure Ext. INT0 pin to
generate interrupt on falling edge
Configure TMCSR0 with
CLKP1/16, Reload, Interrupt
Enable, Count Enable, Trigger
Clear Ext. INT0 interrupt flag
and enable the interrupt
InitPort()
Init_Var()
Clear P01_0 to P01_2 outputs
Set P01_0 to P01_2 as outputs for scan
lines
Clear the de-bounce timer
Set all the key matrix related
variables to their respective
defaults
Set P01_3 to P01_5 as inputs for return lines
Enable digital input on P01_3 to P01_5
Clear Port00 and set as output for 7segment display
www.cypress.com
Document No. 002-04826Rev.*A
8
F²MC-16FX Family, MB96340 Key Matrix Interface using I/O Port
4.1.2
C Code
volatile unsigned char power_stat = POWER_ON;
volatile unsigned char time_5ms = FALSE;
// Power Status
// 5 ms elapsed flag
unsigned char timer_debounce = 0;
unsigned char keyflag = FALSE;
// Debounce timer
// Flag to indicate if any key is pressed currently
unsigned char keymask = 1;
unsigned char keyin = NONE;
// Keymask for the current key pressed
// Keycode for the current key pressed
unsigned char last_keymask = 1;
unsigned char last_keyin = NONE;
// Keymask for the last key pressed
// Keycode for the last key pressed
unsigned char validkey = NONE;
// Keycode for the current key pressed
// after considering debounce time
/*---------------------------------------------------------------------------*/
/*
Initialize RLT0
*/
/*---------------------------------------------------------------------------*/
void InitReloadTimer0 (void)
{
TMRLR0 = 4999;
// Set reload value
// Hence interrupt at 4999+1 * 1/1MHz = 5 ms
TMCSR0 = 0x041B;
// Clock CLKP1/16 =16MHz/16 = 1MHz, reload,
// Interrupt enable, count enable, trigger
}
/*---------------------------------------------------------------------------*/
/*
Initialize Port
*/
/*---------------------------------------------------------------------------*/
void InitPort (void)
{
PDR01 &= ~0x07;
// Clear P01_0 to P01_2
DDR01 |= 0x07;
// Set P01_0 to P01_2 as output for scan lines
DDR01 &= ~0x38;
// Set P01_3 to P01_5 as input for return lines
PIER01 |= 0x38;
// Enable digital input on P01_3 to P01_5
PDR00 = 0x00;
// Clear P00_0 to P00_7
DDR00 = 0xFF;
// Set P00_0 to P00_7 as ouput for 7-Segment Display
}
/*---------------------------------------------------------------------------*/
/*
Initialize INT0
*/
/*---------------------------------------------------------------------------*/
void InitExtInt0 (void)
{
ADER2 &= 0xFE;
// Port I/O mode on P07_0
PIER07_IE0 = 1;
// Enable digital input on P07_0
ELVRL0_LB0 = 1;
// LB0, LA0 = 11 -> Falling edge
ELVRL0_LA0 = 1;
EIRR0_ER0 = 0;
// Reset interrupt flag
ENIR0_EN0 = 1;
// Enable interrupt request
}
/*---------------------------------------------------------------------------*/
/*
Initialize variables
*/
/*---------------------------------------------------------------------------*/
void Init_Var (void)
{
timer_debounce = 0;
// Clear debounce timer
keyflag = FALSE;
// No key pressed currently
keymask = 1;
keyin = NONE;
// Select default scan line i.e. P00_1
// Clear keyin
last_keymask = 1;
last_keyin = NONE;
// Select default scan line i.e. P00_1
// Clear last_keyin
validkey = NONE;
// Clear validkey
}
www.cypress.com
Document No. 002-04826Rev.*A
9
F²MC-16FX Family, MB96340 Key Matrix Interface using I/O Port
4.2
Functionality Routines
4.2.1
Flowchart
It should be noted that all the functions described in this section except Rotate_KeyMask() should be called once
in at least 5ms time. Calling of Rotate_KeyMask() would be taken care by Scan_Key() function.
Rotate_KeyMask()
Ctrl_Power()
keymask =
4?
N
Y
keymask = 1
power_stat =
POWER_OFF?
N
Y
PDR00 = 0xAA to indicate
STOP mode entry
Left shift keymask by 1 to
select another scan line
stop_mode = TRUE
Exit
Go to STOP Mode by
configuring SMCR
NOP
N
power_stat =
POWER_ON
and stop_mode
= TRUE?
Y
Call Init_Var()
Exit
www.cypress.com
Document No. 002-04826Rev.*A
10
F²MC-16FX Family, MB96340 Key Matrix Interface using I/O Port
Disp_Key()
validkey =
NONE?
Y
N
validkey =
ONE?
PDR00 = 0xFF
PDR00 = 0xF9
Y
PDR00 = 0xA4
N
validkey =
TWO?
Y
N
validkey =
THREE?
PDR00 = 0xB0
PDR00 = 0x99
Y
PDR00 = 0x92
N
validkey =
FOUR?
Y
PDR00 = 0xF8
N
validkey =
FIVE?
PDR00 = 0x82
Y
PDR00 = 0x80
N
validkey =
SIX?
Y
N
Y
N
validkey =
SEVEN?
validkey =
NINE?
PDR00 = 0x90
Y
PDR00 = 0x06
N
validkey =
EIGHT?
Y
Exit
N
www.cypress.com
Document No. 002-04826Rev.*A
11
F²MC-16FX Family, MB96340 Key Matrix Interface using I/O Port
Scan_Key()
N
Select appropriate scan
line
Is 5 ms
delay
over?
Y
Read return lines and
store the keycode without
mask
Clear time_5ms flag
Any new
keypress?
N
Any key
pressed?
Y
Y
Increment debounce
timer
N
N
If last pressed
key released?
Is
debounce
delay
over?
Y
N
Y
Store NONE in
validkey
Select appropriate scan
line
Clear debounce timer, update
keyflag to indicate key
pressed
Read return lines and
store the keycode without
mask
Store keyin and keymask in
last_keyin and last_keymask
keypress and
same as last
keypress?
N
keymask =
last_keymask
?
N
Y
Store
corresponding
keycode in
validkey
Y
Store NONE in validkey
Store NONE in validkey
Call Rotate_KeyMask()
Clear keyflag for
next
keypress and call
Rotate_KeyMask(
)
Exit
www.cypress.com
Document No. 002-04826Rev.*A
12
F²MC-16FX Family, MB96340 Key Matrix Interface using I/O Port
4.2.2
C Code
/*
Rotate KeyMask
*/
/*---------------------------------------------------------------------------*/
void Rotate_KeyMask (void)
{
// Keymask sequence P01_0->P01_1->P01_2->P01_0->P01_1->P01_2
if (4 == keymask)
// If scan line P01_2 was selected last
{
keymask = 1;
// Select scan line P01_0
}
else
{
keymask = keymask << 1;
// Else, select the next scan line
}
keyin = 0;
// Clear keyin
}
/*---------------------------------------------------------------------------*/
/*
Display Key Pressed
*/
/*---------------------------------------------------------------------------*/
// This function needs to be called at least once in every 5 ms
void Disp_Key (void)
{
switch (validkey)
{
case NONE
:
PDR00 = 0xFF;
// If no key pressed, display nothing
break;
case ONE
:
PDR00 = 0xF9;
break;
// If 1 key pressed, display 1
case TWO
:
PDR00 = 0xA4;
break;
// If 2 key pressed, display 2
case THREE
:
PDR00 = 0xB0;
break;
// If 3 key pressed, display 3
case FOUR
:
PDR00 = 0x99;
break;
// If 4 key pressed, display 4
case FIVE
:
PDR00 = 0x92;
break;
// If 5 key pressed, display 5
case SIX
:
PDR00 = 0x82;
break;
// If 6 key pressed, display 6
case SEVEN
:
PDR00 = 0xF8;
break;
// If 7 key pressed, display 7
case EIGHT
:
PDR00 = 0x80;
break;
// If 8 key pressed, display 8
case NINE
:
PDR00 = 0x90;
break;
// If 9 key pressed, display 9
default
:
PDR00 = 0x06;
break;
//If invalid key pressed, display E.
}
}
/*---------------------------------------------------------------------------*/
/*
Power On/off Routine
*/
/*---------------------------------------------------------------------------*/
// This function needs to be called at least once in every 5 ms
void Ctrl_Power (void)
{
unsigned char stop_mode = FALSE;
if ( POWER_OFF == power_stat )
// If stop mode is requested
{
PDR00 = 0xAA;
// Indication of going to STOP mode
stop_mode = TRUE;
// set the flag
▼
www.cypress.com
Document No. 002-04826Rev.*A
13
F²MC-16FX Family, MB96340 Key Matrix Interface using I/O Port
▲
SMCR |= 0x03;
__asm(" NOP");
// Go to STOP mode
// NOP
}
if ( POWER_ON == power_stat && TRUE == stop_mode)
{
Init_Var();
}
// If woke up from stop mode
// Initialize all variables
}
/*---------------------------------------------------------------------------*/
/*
Key Matrix Scanning Routine
*/
/*---------------------------------------------------------------------------*/
// This function needs to be called at least once in every 5 ms
void Scan_Key (void)
{
unsigned char keywomask;
if ( TRUE == time_5ms )
{
time_5ms = FALSE;
if ( TRUE == keyflag )
{
timer_debounce++;
// If 5 ms delay elapsed
// Clear the flag for next 5 ms delay
// If any key is pressed currently
// Increment the debounce timer
//If the debounce delay elapsed
if ( DEBOUNCE_DELAY <= timer_debounce)
{
PDR01 &= ~0x07;
// Clear the scan line
// Select the appropriate scan line (P01_0-P00_2)
PDR01 |= keymask;
keyin = PDR01 & 0x3F;
// Read the return lines
// Store keycode of the key pressed without mask
keywomask = keyin & 0x38;
// If any key is pressed and current keypress is same as
// last key press
if ( 0 != keywomask && keyin == last_keyin )
{
// Keypress was longer than debounce time hence
// valid, store it
validkey = keyin;
}
else
{
// Keypress wasnt longer than debounce time hence
// invalid, discard it
validkey = NONE;
}
keyflag = FALSE;
// Next key press
Rotate_KeyMask (); //Rotate the keymask for next scan line
}
}
else
// If no key is pressed currently
{
PDR01 &= ~0x07; // Clear the scan line
PDR01 |= keymask;// Select the appropriate scan line (P01_0-P01_2)
keyin = PDR00 & 0x3F;
// Read the return lines
keywomask = keyin & 0x38; // Store keycode of the key pressed
// without mask
if ( 0 != keywomask )
// If any key is pressed
{
// If the last pressed key released
if ( keymask == last_keymask && keyin != last_keyin )
{
validkey = NONE;
// Discard the old keycode
}
▼
www.cypress.com
Document No. 002-04826Rev.*A
14
F²MC-16FX Family, MB96340 Key Matrix Interface using I/O Port
timer_debounce = 0;
keyflag = TRUE;
last_keyin = keyin;
// Clear the debounce timer
// Flag to indicate key pressed
// Store the keyin for comparing
// after debounce
last_keymask = keymask;
// Store the keyin for detecting
// key release
}
else
{
// If no key is pressed and keymask is same, means the last
// pressed key released
if ( keymask == last_keymask )
{
validkey = NONE;
// Discard the old keycode
}
Rotate_KeyMask ();// Rotate the keymask for next scan line
}
}
}
}
www.cypress.com
Document No. 002-04826Rev.*A
15
F²MC-16FX Family, MB96340 Key Matrix Interface using I/O Port
4.3
Main Function
4.3.1
Flowchart
main()
Initialize interrupt level and
enable interrupts
Call InitPort()
Call InitExtInt0()
Call InitReloadTimer0()
Call Ctrl_Power()
Call Scan_Key()
Call Disp_Key()
www.cypress.com
Document No. 002-04826Rev.*A
16
F²MC-16FX Family, MB96340 Key Matrix Interface using I/O Port
4.3.2
C Code
/*===========================================================================*/
/*
M A I N
*/
/*===========================================================================*/
void main(void)
{
InitIrqLevels();
__set_il(7);
// allow all levels
__EI();
// globally enable interrupts
InitPort();
InitExtInt0();
InitReloadTimer0();
while(1)
{
Ctrl_Power();
Scan_Key();
Disp_Key();
}
// Initialize port 0 & 1
// Initialize external interrupt 0
// Initialize reload timer 0
// Manage power on/off
// Scan the key matrix
// Display the key currently pressed
}
www.cypress.com
Document No. 002-04826Rev.*A
17
F²MC-16FX Family, MB96340 Key Matrix Interface using I/O Port
4.4
Interrupt Service Routines
4.4.1
Flowchart
ISRReloadTimer0()
Clear RLT0 underflow
interrupt flag
ISRExtInt0()
N
power_stat =
POWER_OFF?
Y
Set time_5ms flag
power_stat = POWER_ON
Exit
power_stat = POWER_OFF
Clear Ext. INT0 interrupt flag
Exit
www.cypress.com
Document No. 002-04826Rev.*A
18
F²MC-16FX Family, MB96340 Key Matrix Interface using I/O Port
4.4.2
C Code
/*===========================================================================*/
/*
I S R s
*/
/*===========================================================================*/
/*---------------------------------------------------------------------------*/
/*
Reload Timer 0 ISR
*/
/*---------------------------------------------------------------------------*/
__interrupt void ISRReloadTimer0(void)
{
TMCSR0_UF = 0;
// Reset underflow interrupt request flag
time_5ms = TRUE;
// Set the 5ms timer flag
}
/*---------------------------------------------------------------------------*/
/*
External Interrupt 0 ISR
*/
/*---------------------------------------------------------------------------*/
__interrupt void ISRExtInt0(void)
{
if ( POWER_OFF == power_stat )
{
power_stat = POWER_ON;
}
else
{
power_stat = POWER_OFF;
}
EIRR0_ER0 = 0;
}
www.cypress.com
Document No. 002-04826Rev.*A
// If it is powered off
// Request power on
// Else request power off
// Clear interrupt flag
19
F²MC-16FX Family, MB96340 Key Matrix Interface using I/O Port
4.5
Interrupt Vector
4.5.1
Code
void InitIrqLevels(void)
{
. . .
ICR = (17 << 8) | 2;
ICR = (51 << 8) | 3;
/* Priority Level 2 for Ext Int0 of MB9634x Series */
/* Priority Level 2 for RLT0 of MB9634x Series */
. . .
}
. . .
/* ISR prototype */
__interrupt void ISRExtInt0(void);
__interrupt void ISRReloadTimer0(void);
. . .
#pragma intvect ISRExtInt0
#pragma intvect ISRReloadTimer1
. . .
5
17
51
/* Ext Int0 of MB9634x Series */
/* RLT0 of MB9634x Series */
Additional Information
Information about Cypress Microcontrollers can be found on the following Internet page:
http://www.cypress.com/cypress-microcontrollers
The software example related to this application note is:
96340_key_matrix_io
It can be found on the following Internet page:
http://www.cypress.com/cypress-mcu-product-softwareexamples
www.cypress.com
Document No. 002-04826Rev.*A
20
F²MC-16FX Family, MB96340 Key Matrix Interface using I/O Port
6
Document History
Document Title: AN204826 - F²MC-16FX Family, MB96340 Key Matrix Interface using I/O Port
Document Number:002-04826
Revision
**
*A
www.cypress.com
ECN
-
5086026
Orig. of
Change
NOFL
NOFL
Submission
Date
Description of Change
04/16/2007
Initial release
06/06/2007
Updated with review findings from PHu
09/04/2007
Fixed typos and syntax highlighting
05/31/2016
Migrated Spansion Application Note MCU-AN-300238-E-V12 to
Cypress format
Document No. 002-04826Rev.*A
21
F²MC-16FX Family, MB96340 Key Matrix Interface using I/O Port
Worldwide Sales and Design Support
Cypress maintains a worldwide network of offices, solution centers, manufacturer‟s representatives, and distributors. To find
the office closest to you, visit us at Cypress Locations.
PSoC® Solutions
Products
®
®
ARM Cortex Microcontrollers
cypress.com/arm
PSoC 1 | PSoC 3 | PSoC 4 | PSoC 5LP
Automotive
cypress.com/automotive
Cypress Developer Community
Clocks & Buffers
cypress.com/clocks
Interface
cypress.com/interface
Lighting & Power Control
cypress.com/powerpsoc
Memory
cypress.com/memory
PSoC
cypress.com/psoc
Touch Sensing
cypress.com/touch
USB Controllers
cypress.com/usb
Wireless/RF
cypress.com/wireless
Forums | Projects | Videos | Blogs | Training| Components
Technical Support
cypress.com/support
PSoC is a registered trademark and PSoC Creator is a trademark of Cypress Semiconductor Corporation. All other trademarks or registered trademarks
referenced herein are the property of their respective owners.
Cypress Semiconductor
198 Champion Court
San Jose, CA 95134-1709
Phone
Fax
Website
: 408-943-2600
: 408-943-4730
: www.cypress.com
© Cypress Semiconductor Corporation, 2007-2016. This document is the property of Cypress Semiconductor Corporation and its subsidiaries,
including Spansion LLC (“Cypress”). This document, including any software or firmware included or referenced in this document (“Software”), is owned
by Cypress under the intellectual property laws and treaties of the United States and other countries worldwide. Cypress reserves all rights under such
laws and treaties and does not, except as specifically stated in this paragraph, grant any license under its patents, copyrights, trademarks, or other
intellectual property rights. If the Software is not accompanied by a license agreement and you do not otherwise have a written agreement with
Cypress governing the use of the Software, then Cypress hereby grants you a personal, non-exclusive, nontransferable license (without the right to
sublicense) (1) under its copyright rights in the Software (a) for Software provided in source code form, to modify and reproduce the Software solely for
use with Cypress hardware products, only internally within your organization, and (b) to distribute the Software in binary code form externally to end
users (either directly or indirectly through resellers and distributors), solely for use on Cypress hardware product units, and (2) under those claims of
Cypress‟s patents that are infringed by the Software (as provided by Cypress, unmodified) to make, use, distribute, and import the Software solely for
use with Cypress hardware products. Any other use, reproduction, modification, translation, or compilation of the Software is prohibited.
TO THE EXTENT PERMITTED BY APPLICABLE LAW, CYPRESS MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD
TO THIS DOCUMENT OR ANY SOFTWARE OR ACCOMPANYING HARDWARE, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. To the extent permitted by applicable law, Cypress reserves the right to
make changes to this document without further notice. Cypress does not assume any liability arising out of the application or use of any product or
circuit described in this document. Any information provided in this document, including any sample design information or programming code, is
provided only for reference purposes. It is the responsibility of the user of this document to properly design, program, and test the functionality and
safety of any application made of this information and any resulting product. Cypress products are not designed, intended, or authorized for use as
critical components in systems designed or intended for the operation of weapons, weapons systems, nuclear installations, life-support devices or
systems, other medical devices or systems (including resuscitation equipment and surgical implants), pollution control or hazardous substances
management, or other uses where the failure of the device or system could cause personal injury, death, or property damage (“Unintended Uses”). A
critical component is any component of a device or system whose failure to perform can be reasonably expected to cause the failure of the device or
system, or to affect its safety or effectiveness. Cypress is not liable, in whole or in part, and you shall and hereby do release Cypress from any claim,
damage, or other liability arising from or related to all Unintended Uses of Cypress products. You shall indemnify and hold Cypress harmless from and
against all claims, costs, damages, and other liabilities, including claims for personal injury or death, arising from or related to any Unintended Uses of
Cypress products.
Cypress, the Cypress logo, Spansion, the Spansion logo, and combinations thereof, PSoC, CapSense, EZ-USB, F-RAM, and Traveo are trademarks or
registered trademarks of Cypress in the United States and other countries. For a more complete list of Cypress trademarks, visit cypress.com. Other
names and brands may be claimed as property of their respective owners.
www.cypress.com
Document No. 002-04826Rev.*A
22