AN2600 Freescale Semiconductor / Motorola, AN2600 Datasheet - Page 17

no-image

AN2600

Manufacturer Part Number
AN2600
Description
A Simple Keypad Using LIN with the MC68HC908QT/QY MCU
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
/******************************************************************************
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
******************************************************************************/
void Read_Button (void)
{
unsigned char keypad;
static int keypadcount = 0;
static unsigned char keypad_last = 0;
MOTOROLA
keypad = BUTTONS;
if (keypad == keypad_last)
{
}
Function name: Read_Button
Originator:
Date:
Function:
if (keypadcount == 1)
{
}
else if (keypadcount < KEEPCOUNT)
{
}
else if (keypadcount == KEEPCOUNT)
{
}
if (keypad)
{
}
else
{
}
keypadcount++;
if (keypad)
data1 = keypad;
data1 = 0;
keypadcount++;
{
data2 = keypad;
}
D.Svrcek
8th August 2003
The port line is read and its level is compared to
previous values. If the value is the same, the counter
‘keypadcount’ is used for delay and to decide if the same *
state has been present for long enough (3 seconds). For a *
short key press, the value is saved from port B to data1
variable. For a long key press, the value is latched from *
port B and stored to data2 variable.
If the status of switch is changed, the counter is reset
and the data variables are cleared.
A Simple Keypad Using LIN with the MC68HC908QT/QY MCU
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
/* auxiliary variable
/* the number of interval
/* previous value of keys
/* read buttons on PTB
/* same as last time ?
/* yes, third time ?
/* key pressed?
/* yes, store buttons to
/* keypad status 1
/* no, clear keypad status1*/
/* prevents wraparound
/* time for save data1,
/* key is pressed for long?*/
/* yes, key pressed ?
/* yes, store buttons to
/* keypad status 2
Application Source Code
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*
*
*
*
*
*
*
*
*
*
*
*
AN2600/D
17

Related parts for AN2600