AN2600 Freescale Semiconductor / Motorola, AN2600 Datasheet - Page 15

no-image

AN2600

Manufacturer Part Number
AN2600
Description
A Simple Keypad Using LIN with the MC68HC908QT/QY MCU
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
Application Source Code
LIN_Keypad_QY.c
/******************************************************************************
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
******************************************************************************/
/******************************************************************************
*
*
*
******************************************************************************/
#include “MC68HC908QY4.h”
#include “LINdriver.h”
#include “LIN_Keypad_QY.h”
#define KEEPCOUNT 145
#define BUTTONS (~PTB) & 0x7B
#define ID_RECEIVE 0x1A
#define ID_SEND 0x5B
#define LED_STATUS 0x01
#define LED_SET PTA |= 0x08;
#define LED_CLEAR PTA &= 0xF7;
#define EVER (;;)
#pragma DATA_SEG SHORT _DATA_ZEROPAGE
unsigned char data1 = 0;
unsigned char data2 = 0;
unsigned char MsgSent [2];
MOTOROLA
Originator:
Date:
$Version: 1.1.4.0$
Function:
Includes, defines, globals and function prototypes
(c) MOTOROLA Inc. 2003
LIN keypad slave node for MC68HC908QY4
======================================
David Svrcek
11th September 2003
Slave keypad receives a 2-byte message and supplies
a 2-byte response. The MCU sends in the first byte
the value corresponding to the pressed buttons, and
in the second byte the value corresponding with longer
pressed buttons (those pressed down for longer
than 3 seconds). If bit 0 in the first receiving byte
is set, then the LED on pin PTA3 is enabled.
All the other bits are zero.
A Simple Keypad Using LIN with the MC68HC908QT/QY MCU
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
all rights reserved.
/* 20.5ms x (145+1) = 3s
/* define buttons on pins
/* ID for receiving
/* ID for sending
/* bit 0 in data st. reg.1 */
/* set LED on PTA3 pin
/* clear LED on PTA3 pin
/* forever loop
/* keypad status 1
/* keypad status 2
/* transmitted data
Application Source Code
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
AN2600/D
15

Related parts for AN2600