AN2600 Freescale Semiconductor / Motorola, AN2600 Datasheet - Page 6

no-image

AN2600

Manufacturer Part Number
AN2600
Description
A Simple Keypad Using LIN with the MC68HC908QT/QY MCU
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
AN2600/D
Main Programming
Loop
6
A Simple Keypad Using LIN with the MC68HC908QT/QY MCU
In the main loop of the application (depicted in
LIN_Msg() functions are called.
The first function (Read_Button()) reads the port B values (where the switches
are connected). They are compared to the previous values. If both values are
equal, the counter keypadcount is used for the debouncing delay and also to
decide if the same state has been present for long enough. For a short key
press, the state of the keypad is saved to data1 variable (keypad status 1),
while for a long key press, the keypad value is latched and stored in data2
(keypad status 2). The mapping of the keypads within the status variables is
shown in
Freescale Semiconductor, Inc.
For More Information On This Product,
Table
Go to: www.freescale.com
2.
Figure 2. Main Loop Flowchart
CLEAR OVERFLOW FLAG
INITIALIZATION OF THE
READ KEYPAD STATUS
MCU PERIPHERALS
INIT LIN DRIVER
Read_Button()
START main()
OVERFLOW?
LIN Rx and Tx
LIN_Msg()
LIN_Init()
TIMER
Y
N
Figure
2), Read_Button() and
MOTOROLA

Related parts for AN2600