ETC DRM005

Freescale Semiconductor, Inc...
Freescale Semiconductor, Inc.
Remote Keyless
Entry (RKE)
Reference Design
Using the
MC68HC908RF2
Designer Reference
Manual
M68HC08
Microcontrollers
DRM005/D
5/2002
WWW.MOTOROLA.COM/SEMICONDUCTORS
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc...
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
Freescale Semiconductor, Inc...
Remote Keyless Entry (RKE)
Reference Design
Using the MC68HC908RF2
By: Andrea Martini
ESSEPIE S.r.l. — Studio di progettazione
Via Artigianato,5
24044 Dalmine (BG) — Italy
63(
Email: [email protected]
Web: http://www.elektronikladen.de/en
Motorola and the Stylized M Logo are registered trademarks of Motorola, Inc.
DigitalDNA is a trademark of Motorola, Inc.
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
© Motorola, Inc., 2002
DRM005
3
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
Revision History
To provide the most up-to-date information, the revision of our
documents on the World Wide Web will be the most current. Your printed
copy may be an earlier revision. To verify you have the latest information
available, refer to:
http://www.motorola.com/semiconductors
Freescale Semiconductor, Inc...
The following revision history table summarizes changes contained in
this document. For your convenience, the page number designators
have been linked to the appropriate location.
Revision History
DRM005
Date
Revision
Level
May, 2002
N/A
Description
Initial release
Page
Number(s)
N/A
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
4
MOTOROLA
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
Designer Reference Manual — Remote Keyless Entry
List of Sections
Section 1. General Description . . . . . . . . . . . . . . . . . . . . 11
Freescale Semiconductor, Inc...
Section 2. Motorola RF Components . . . . . . . . . . . . . . . 17
Section 3. Reference Board Hardware . . . . . . . . . . . . . . 21
Section 4. HC908RF2 for Windows Installation . . . . . . . 33
Section 5. Remote Programming Commands . . . . . . . . 43
Appendix A. Source Code . . . . . . . . . . . . . . . . . . . . . . . . 59
Appendix B. Schematics . . . . . . . . . . . . . . . . . . . . . . . . 135
Appendix C. Board Layouts . . . . . . . . . . . . . . . . . . . . . . 139
Appendix D. Bill of Materials . . . . . . . . . . . . . . . . . . . . . 147
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
List of Sections
For More Information On This Product,
Go to: www.freescale.com
DRM005
5
Freescale Semiconductor, Inc.
Freescale Semiconductor, Inc...
List of Sections
DRM005
6
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
List of Sections
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Designer Reference Manual — Remote Keyless Entry
Table of Contents
Freescale Semiconductor, Inc...
Section 1. General Description
1.1
Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
1.2
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
1.3
Reference Board. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
1.4
Reference Goals. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Section 2. Motorola RF Components
2.1
Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.2
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.3
MC68HC908RF2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.4
MC33592/3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.5
MC33491 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Section 3. Reference Board Hardware
3.1
Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.2
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.3
Mother Board Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . .22
3.4
Remote Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24
3.5
Receiver Board Description . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
3.6
Transmitter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
3.7
Mother Board Display Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Section 4. HC908RF2 for Windows Installation
4.1
Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
4.2
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
4.3
Installation Screens . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .33
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Table of Contents
For More Information On This Product,
Go to: www.freescale.com
DRM005
7
Freescale Semiconductor, Inc.
Table of Contents
Section 5. Remote Programming Commands
5.1
Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
5.2
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
5.3
Communication Protocol. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Freescale Semiconductor, Inc...
5.4
Command Set Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
5.4.1
Erase Programming Algorithm Memory (EPG) . . . . . . . . . .45
5.4.2
Erase TX S19 Memory (ETX). . . . . . . . . . . . . . . . . . . . . . . .46
5.4.3
Erase User Code Memory (EUM) . . . . . . . . . . . . . . . . . . . . 47
5.4.4
Initialize MC33592/3 Registers (IRR) . . . . . . . . . . . . . . . . . . 48
5.4.5
Load Programming Algorithm (LPG) . . . . . . . . . . . . . . . . . . 49
5.4.6
Load TX S19 File (LTX) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
5.4.7
Product ID (PID) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .53
5.4.8
Read MC33592/3 Registers (RRR) . . . . . . . . . . . . . . . . . . .54
5.4.9
Update User Code (UUC) . . . . . . . . . . . . . . . . . . . . . . . . . . 55
5.4.10 MC33592/3 Registers (WRR). . . . . . . . . . . . . . . . . . . . . . . .57
Appendix A. Source Code
A.1
Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
A.2
Mother Board Firmware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
A.2.1
UK509.ASM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
A.2.2
UK509 PRM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
A.3
Transmitter Firmware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
Appendix B. Schematics
Appendix C. Board Layouts
Appendix D. Bill of Materials
DRM005
8
D.1
Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
D.2
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
D.3
Transmitter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
D.4
Receiver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
D.5
Mother Board . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .150
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Table of Contents
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Designer Reference Manual — Remote Keyless Entry
List of Figures and Tables
Freescale Semiconductor, Inc...
Figure
Title
1-1
1-2
1-3
Transmitter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Receiver Board . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Mother Board . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .16
2-1
2-2
MC33492 Pin Assignments . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
14-Lead TSSOP Pictorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3-1
3-2
3-3
3-4
3-5
3-6
3-7
3-8
Mother Board Block Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Remote Block Diagram. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Receiver Board Block Diagram. . . . . . . . . . . . . . . . . . . . . . . . . 25
Receiver Board . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Receiver Board Schematic . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Transmitter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Transmitter Schematic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Mother Board Display Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
4-1
4-2
4-3
4-4
4-5
4-6
4-7
4-8
Startup Screen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Welcome Screen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
License Agreement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .36
Choose Destination Location Screen . . . . . . . . . . . . . . . . . . . .37
Setup Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Select Program Folder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Install Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Finish . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
5-1
5-2
Command Packet Format. . . . . . . . . . . . . . . . . . . . . . . . . . . . .44
Command Packet Format. . . . . . . . . . . . . . . . . . . . . . . . . . . . .44
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Page
List of Figures and Tables
For More Information On This Product,
Go to: www.freescale.com
DRM005
9
Freescale Semiconductor, Inc.
List of Figures and Tables
Freescale Semiconductor, Inc...
Figure
Mother Board Schematic . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
Receiver Schematic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .137
Transmitter Schematic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
C-1
C-2
C-3
C-4
C-5
C-6
Transmitter Layout (Top View) . . . . . . . . . . . . . . . . . . . . . . . . 140
Transmitter Layout (Bottom View) . . . . . . . . . . . . . . . . . . . . . 141
Receiver Layout (Top View) . . . . . . . . . . . . . . . . . . . . . . . . . . 142
Receiver Layout (Bottom View) . . . . . . . . . . . . . . . . . . . . . . .143
Mother Board Layout (Top View) . . . . . . . . . . . . . . . . . . . . . . 144
Mother Board Layout (Bottom View). . . . . . . . . . . . . . . . . . . . 145
2-1
10
Page
B-1
B-2
B-3
Table
DRM005
Title
Title
Page
MC33492 Ordering Information . . . . . . . . . . . . . . . . . . . . . . . 20
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
List of Figures and Tables
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Designer Reference Manual — Remote Keyless Entry
Section 1. General Description
Freescale Semiconductor, Inc...
1.1 Contents
1.2
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
1.3
Reference Board. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
1.4
Reference Goals. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
1.2 Introduction
The purpose of this document is to detail the hardware and software
required for a remote key entry (RKE) application. For several reasons
this solution can fit well even for “wireless” applications where there is a
need to send data from a remote sensor via radio frequency (RF)
communication.
If you look at networking connections, some years ago the only way to
implement these was with hundreds of meter of wires. Today we are
faced with a new challenge. For clarification, some of the standards are
highlighted below along with their main application.
1. 2.4-GHz Standards — The main application for this standard is
business wireless local area networks (LANs), where the speed of
the communication is a key factor (up to 24-Mbps)
2. Bluetooth —Originally, Bluetooth was being studied to provide a
solution to point-to-point short-range links for voice applications,
such as cell phones to PDAs or a hands free automobile adapter
kit that eliminates the need for cables and adapter sockets. Even
in these cases, the purpose of the standard is to provide a
high-speed solution for communicating huge quantities of data.
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
General Description
For More Information On This Product,
Go to: www.freescale.com
DRM005
11
Freescale Semiconductor, Inc.
Designer Reference Manual
3. Radio Frequency (RF) — The number of RF applications are
unlimited. An example of RF use would be with gate opening
applications. RF can be considered as a cost-effective solution for
small to medium volume data transmission (not at high speeds).
For such applications, frequency bands most used are 200 MHz,
315 MHz, 433 MHz, 868 MHz, or 900 MHz. Some of the markets
interested in this standard include appliances, smoke sensors,
and home networking.
Freescale Semiconductor, Inc...
The RF standard is the subject of this document.
1.3 Reference Board
Over the past several years, Motorola has developed many RF
semiconductor products including the MC68HC908RF2 microcontroller
unit (MCU). This microcontroller includes the excellent performance of
the HC08 Family along with an integrated RF transmitter.
Reference board features:
DRM005
12
•
Mother Board: Connectable to a PC through an RS232 connector
for setting up the receiver. The setting can be implemented stand
alone using the integrated encoder and a display unit on the
board.
•
Remote Transmitter: Implemented using an MC68HC908RF2
MCU with integrated Motorola technology for UHF transmitters.
Eight buttons are implemented on the transmitter.
•
Receiver Board: The MC3359x UHF is used to receive data from
the transmitter. The received data can be viewed on the display
unit on the mother board.
•
433-MHz and 868-MHz band frequency transmission
implemented (the MC68HC908RF2 can transmit both of the
frequencies by simply changing a pin status
•
Simple rolling code provided
•
All source code and schematics provided for fast implementation
of an RF application
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
General Description
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
General Description
Reference Goals
It is important to highlight that the MC68HC908RF2 MCU can transmit at
two frequency levels: 433-MHz or 868-MHz simply by changing the
configuration of one pin (to be either a pullup or pulldown). For
evaluation reasons, Motorola has provided two separate transmitters so
that users can avoid buying or disconnecting a pullup on a case-by-case
basis.
Freescale Semiconductor, Inc...
See Figure 1-1.
Figure 1-1. Transmitter
1.4 Reference Goals
The main goal of this document is to demonstrate how to use the
Motorola components listed in 1.3 Reference Board to control
transmitting and receiving a RF transmission. However, it is important to
acknowledge the capabilities of the MC68HC908RF2’s FLASH memory
which will be demonstrated. A rolling code algorithm is provided with this
material (the source code is in Appendix A. Source Code). This
algorithm has been developed to use the embedded FLASH of the
MC68HC908RF2 MCU instead of an EEPROM memory.
In the remote transmitter, eight buttons have been implemented. The
pressure of one of these buttons is transformed in a RF transmitted
frame and captured by the receiver. The display mounted on the mother
board then shows an indication of the button pressed with the CRC code
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
General Description
For More Information On This Product,
Go to: www.freescale.com
DRM005
13
Freescale Semiconductor, Inc.
Designer Reference Manual
transmitted (highlighting the fix code and variable code in case a rolling
code transmission is chosen).
Due to the excellent current consumption features of the
MC68HC908RF2 a “small” 3-volt Lithium battery (i.e., CR2032) is used
in the remote transmitter. In this configuration the average transmission
distance is around 10 meters. However, with a simple modification to the
transmitter layout (including a small transistor for amplifying and a
“bigger” battery) a range of 100 meters can be achieved.
Freescale Semiconductor, Inc...
The mother board is powered with a 9-volt DC power supply and has a
encoder mounted to set up the configuration of the transmission (fixed
or rolling code) and the three registers which reside inside the RF
receiver. The value of these register can be viewed on the mother
board’s display.
Another way to change the register’s value is through Windows® PC
software which is provided on a CD ROM and downloadable from the
Motorola web site at:
www.motorola.com/semiconductors
All embedded software has been written using Metrowerks®
CodeWarrior® suite for Motorola HC08 devices. All the code is
commented and provided in Appendix A. Source Code.
The receiver board is shown in Figure 1-2 and the mother board in
Figure 1-3.
®
®
DRM005
14
Windows is a registered trademark of Microsoft Corporation in the U.S. and/or other countries.
Metrowerks and CodeWarrior are registered trademarks of Metrowerks, Inc., a wholly owned
subsidiary of Motorola, Inc.
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
General Description
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Freescale Semiconductor, Inc...
General Description
Reference Goals
Figure 1-2. Receiver Board
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
General Description
For More Information On This Product,
Go to: www.freescale.com
DRM005
15
Freescale Semiconductor, Inc.
Figure 1-3. Mother Board
Freescale Semiconductor, Inc...
General Description
DRM005
16
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
General Description
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Designer Reference Manual — Remote Keyless Entry
Section 2. Motorola RF Components
Freescale Semiconductor, Inc...
2.1 Contents
2.2
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.3
MC68HC908RF2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.4
MC33592/3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.5
MC33491 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.2 Introduction
This section provides a general overview of the Motorola RF
components used in this reference. They are:
•
MC68HC908RF2 — microcontroller unit (MCU)
•
MC33592/3 — phase locked loop (PLL) tuned ultra-high
frequency (UHF) receiver
•
MC33491 — PLL tuned UHF transmitter
2.3 MC68HC908RF2
The MC68HC908RF2 MCU is a member of the low-cost,
high-performance M68HC08 Family of 8-bit microcontroller units
(MCUs). Optimized for low-power operation and available in a small
32-pin low-profile quad flat pack (LQFP), this MCU is well suited for
remote keyless entry (RKE) transmitter designs.
This MCU can work with a Lithium battery because of the low level
current consumption that can be reached. In stop mode, the MCU
current consumption is almost 10 nA and it is possible to wakeup the
MCU with an external interrupt generated by the keyboard interrupt port.
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Motorola RF Components
For More Information On This Product,
Go to: www.freescale.com
DRM005
17
Freescale Semiconductor, Inc.
Motorola RF Components
Freescale Semiconductor, Inc...
Features of the MC68HC908RF2 MCU include:
DRM005
18
•
High-performance M68HC08 architecture, fully
upward-compatible object code with M6805, M146805, and
M68HC05 Families.
•
Maximum internal bus frequency of:
– 4 MHz at 3.3 volts
– 2 MHz at 1.8 volts
•
Internal oscillator requiring no external components
•
Software selectable bus frequencies
•
±25 percent accuracy with trim capability to±2 percent
•
Option allowing use of external clock source or external
crystal/ceramic resonator
•
2 Kbytes of on-chip FLASH memory
•
128 bytes of on-chip RAM
•
16-bit, 2-channel timer interface module (TIM)
•
12 general-purpose input/output (I/O) ports:
– Six shared with the keyboard wakeup function
– Two shared with the timer module
•
Port A pins have 3-mA sink capabilities
•
Low-voltage inhibit (LVI) module:
– 1.85-V detection forces MCU into reset
– 2.0-V detection sets indicator flag
•
6-bit keyboard interrupt with wakeup feature
•
External asynchronous interrupt pin with internal pullup (IRQ1)
•
UHF MC33491 transmitter featuring:
– Switchable frequency bands: 315, 434, and 868 MHz
– On/off keying (OOK) and frequency shift keying (FSK)
modulation
– Adjustable output power range
– Fully integrated voltage-controlled oscillator (VCO)
– Data clock output for the MCU
– Low external component count
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Motorola RF Components
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Motorola RF Components
MC33592/3
2.4 MC33592/3
MC33592/3 is a PLL tuned UHF receiver, usable in the receiver side of
a data transmitter application. It is a 24-lead quad flat package (LQFP)
device, completely configurable by a serial peripheral interface (SPI)
making it simple to interface with a MCU.
Freescale Semiconductor, Inc...
The MC33592/3 provides two band frequency ranges selectable by
mask option:
•
MC33592 supports 315/433 MHz band with an intermediate
frequency (IF) of 500 kHz
•
MC33593 supports 868 MHz band
The MC33592/3 supports either OOK or FSK modulation. With the data
manager active, the MC33592/3 is able to receive Manchester codified
data and communicate by SPI with an external MCU (a few components
are externally requested). By using MC33592/3 in sleep mode with the
strobe oscillator enabled, very low power consumption can be reached
(115 mA). In this condition, MC33592/3 will be periodically woken up
based on resistor-capacitor (RC) values outside and strobe ration
programmed from users.
2.5 MC33491
MC33491 is a PLL tuned UHF transmitter in a 14-lead thin shrink small
outline package (TSSOP). This device is characterized for low power
consumption (0.5 nA stand-by current) with a supply voltage range
between 1.9 volts and 3.7 volts (this feature is suitable for portable
applications).
NOTE:
MC33491 can work at 315 MHz, 433 MHz, and 868 MHz without mask
change as the frequency band is completely switchable. For the
European market, 868 MHz will be a band extremely important in the
future, since it has just recently become available in many countries.
Refer to Figure 2-1, Figure 2-2, and Table 2-1.
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Motorola RF Components
For More Information On This Product,
Go to: www.freescale.com
DRM005
19
Freescale Semiconductor, Inc.
Freescale Semiconductor, Inc...
Motorola RF Components
DATACLK
1
14
MODE
DATA
2
13
ENABLE
BAND
3
12
VCC
GND
4
11
GNDRF
XTAL1
5
10
RFOUT
XTAL0
6
9
VCC
REXT
7
8
CF8K
Figure 2-1. MC33492 Pin Assignments
TSSOP-14
DTB SUFFIX
CASE 948G
DTB
0.65 mm Pitch
5 mm x 4.4 mm Body
Figure 2-2. 14-Lead TSSOP Pictorial
Table 2-1. MC33492 Ordering Information
DRM005
20
Device
Ambient Temperature Range
Package
MC33491 DTB
–40°C to 125°C
TSSOP14
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Motorola RF Components
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Designer Reference Manual — Remote Keyless Entry
Section 3. Reference Board Hardware
Freescale Semiconductor, Inc...
3.1 Contents
3.2
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.3
Mother Board Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . .22
3.4
Remote Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24
3.5
Receiver Board Description . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
3.6
Transmitter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
3.7
Mother Board Display Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
3.2 Introduction
This section describes the MC68HC908RF2 reference board hardware.
The MC68HC908RF2 reference board (hereafter referred to as RF2
board) has these purposes:
•
Demonstration of a remote controller board for the
MC68HC908RF2 microcontroller (MCU)
•
Demonstration of a receiver board for the MC3359X receiver chip
The RF2 board can also program the FLASH memory of a
MC68HC908RF2 MCU from a personal computer (PC).
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Reference Board Hardware
For More Information On This Product,
Go to: www.freescale.com
DRM005
21
Freescale Semiconductor, Inc.
Reference Board Hardware
Freescale Semiconductor, Inc...
In the development of this reference:
•
The software was developed using Metrowerks C compiler and
assembler.
•
Printed circuit board (PCB) and schematics were developed using
ZUKEN-REDAC CR5000 software.
•
Debugging was done using a MMEVS08 debugger with
EML08GP32 daughter board for the MC68HC908GP32 and
EML08RK2 daughter board for the MC68HC908RF2.
The RF2 board is composed of three parts:
1. Mother board — see 3.3 Mother Board Description
2. Remote — see 3.4 Remote Description
3. Receiver board — see 3.5 Receiver Board Description
NOTE:
There is also a programming adapter board for the RF2 which is not
covered by this document.
3.3 Mother Board Description
The RF2 mother board is described here:
NOTE:
DRM005
22
•
The RF2 board is based on a MC68HC908GP32 FLASH MCU.
•
The user interface has a rotary encoder with:
– Push button
– Select switch
– 3-line by 12-character liquid crystal display (LCD)
•
A RS232 interface is provided to connect the board to the PC.
•
A programmable power supply generates all voltages required to
program FLASH MCU.
•
An input/output (I/O) connector is provided for the receiver board.
The receiver board has not been integrated with the mother board to
allow for future upgrades as long as receiver chips are in continuous
evolution.
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Reference Board Hardware
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Reference Board Hardware
Mother Board Description
•
Two option board connectors have been provided that can accept
either a programming adapter or any other demonstration board.
•
An optional external high density FLASH memory (128 Mbit) can
be installed to use the RF2 board as a general-purpose FLASH
programmer (firmware and adapters are not covered by this
document).
Freescale Semiconductor, Inc...
Refer to Figure 3-1 for a block diagram.
128M FLASH
(OPTIONAL)
RS232
DISPLAY
INPUT DEVICE
I/O
CONNECTOR
MCU
MC68HC908GP32
OPTION
BOARD
CONNECTOR
PROGRAMMABLE POWER SUPPLY SYSTEM
Figure 3-1. Mother Board Block Diagram
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Reference Board Hardware
For More Information On This Product,
Go to: www.freescale.com
DRM005
23
Freescale Semiconductor, Inc.
Reference Board Hardware
3.4 Remote Description
Freescale Semiconductor, Inc...
The remote is described here:
•
The remote is based on a MC68HC908RF2 FLASH MCU with an
integrated ultra-high frequency (UHF) module.
•
The circuit has:
– An 8-key silicon rubber keyboard to evaluate the wake-up
feature of the MCU
– A single cell CR2032 lithium battery
•
The antenna is a small loop on the PCB generally used in keyless
entry systems.
Refer to Figure 3-2 for a block diagram.
ANTENNA
4 X 2 RUBBER
KEYBOARD
MCU
MC68HC908RF2
1-CELL
LITHIUM
BATTERY
Figure 3-2. Remote Block Diagram
3.5 Receiver Board Description
The receiver board is based on a MC3359X UHF receiver (X = 1 and 2
for 433.92 MHz and X = 3 for 868 MHz). This circuit allows the
demonstration of the MC3359X wake-up feature and data manager.
DRM005
24
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Reference Board Hardware
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Reference Board Hardware
Receiver Board Description
Two connectors are provided for expandability:
•
One is a card edge connector so that the board can be used with
the MC68HC908RF2 mother board
•
The other (not assembled) is a standard 2-mm pitch PTH
connector so that the board can be easily used with a user target.
Freescale Semiconductor, Inc...
Refer to Figure 3-3 for a block diagram, Figure 3-4 shows the receiver
board, and Figure 3-5 the receiver board schematic.
ANTENNA
CONNECTOR
WAKE-UP
CIRCUIT
MC3359X
BOARD
CONNECTOR
Figure 3-3. Receiver Board Block Diagram
Figure 3-4. Receiver Board
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Reference Board Hardware
For More Information On This Product,
Go to: www.freescale.com
DRM005
25
C19
C8
100 P
CDG
4
RFIN
6
GNDL
1.4–3 pF
3 MM
GNDS
5
GND
8
2
1
Reference Board Hardware
For More Information On This Product,
Go to: www.freescale.com
500P
00G
22
18
IC2
MC33591
VDCL
3
500M
XJA
C5
12
C3
XJA
10N
24
23
C8
19
7
11
X2
10
6P
CDG
CR1
C11
ROBGAP
STROBE
RESETB
MISO
MOSI
SCLK
VCC
20
21
14
15
16
17
180K
R3
10 K
R5
Figure 3-5. Receiver Board Schematic
9 19
GND1
GND0
VCC
CAFC
MIKOUT
DMIXAGO
VDC0
CAGC
DMDAT
PFD
26
X1
DRM005
VCC1
B8N
X7A
GND
C4
470 K
R2
1U
Y5V
Freescale Semiconductor, Inc...
1U
Y6V
C10
C12
1uH
CN2
CN2
CN2
CN2
CN2
CN2
CN2
CN2
7
32
28
33
23
24
25
36
CN8
CN7
CN6
CN5
CN4
CN3
Freescale Semiconductor, Inc.
Reference Board Hardware
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Freescale Semiconductor, Inc.
Reference Board Hardware
Receiver Board Description
Freescale Semiconductor, Inc...
The circuit is very simple and not all components are needed in most
applications.
NOTE:
•
The power supply is first filtered with L1,C10, and C12. Note that
C10 must be placed as near as possible to IC2.
•
R3 is the bandgap biasing resistor and should have an 1%
tolerance.
•
CR1 and C11 are the reference oscillators for the phase locked
loop (PLL). Note that it is also possible to use an external
generator connected to X1 through a DC blocking capacitor.
However, the amplitude of the signal should not exceed 500 mV.
When you calculate the reference oscillator frequency you must add to
the carrier center frequency the IF center frequency (generally 660 kHz).
So, for 433.92 Mhz carrier frequency:
f(ref) = (433.92+0.66)/32 = 13.580625 MHz
In this way, the transmitter and receiver have different reference XTAL.
WARNING:
WARNING:
Reference oscillators values must be calculated accurately since a
difference of 10 kHz = 0.01 MHz will force the receiver out of tune
(for example, a XTAL of 13.57 MHz is not usable for a carrier of
433.92 MHz).
•
C3 is the AGC capacitor in the case of OOK modulation. In case
of FSK modulation, the voltage at this pin is used as reference.
•
C4 and R2 are the strobe oscillator external components. If a
strobe oscillator is not used R2 should be the jumper that connects
the strobe pin to VCC. Otherwise, MC33592/3 will be in sleep
mode.
If strobe = VCC, bit 4 of CR1 (strobe oscillator enable) must be 0.
•
The antenna is a very small loop antenna. While it is not the best
solution in that it is not well matched with the input impedance of
the LNA input amplifier, for most applications it is good enough
and there are no additional costs. A better solution would require
a matching network (with at least one inductor) and a input SAW
filter which is very expensive.
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Reference Board Hardware
For More Information On This Product,
Go to: www.freescale.com
DRM005
27
Freescale Semiconductor, Inc.
Reference Board Hardware
3.6 Transmitter
Freescale Semiconductor, Inc...
A programming connector is provided for in-circuit programming of the
MC68HC908RF2 and for loading custom user programs. The transmitter
is shown in Figure 3-6 and the schematic in Figure 3-7
Figure 3-6. Transmitter
DRM005
28
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Reference Board Hardware
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
2
BAT1
1 C42032
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Reference Board Hardware
For More Information On This Product,
Go to: www.freescale.com
1U
YBV
C8
TL0U1002
10
1K
10
R23
R22
CN5
CN4
GND
OSC1
21
DCLK
18
DATA
17
BAND
16
PLLEN
15 MODE
19
PTA0
1
PTA1/KBD1
32
PTA2/KBD2
31
PTA3/KBD3
30
PTA4/KBD4
29
PTA5/KBD5
28
PTA6/KBD6
27 PTA7
3
PTB0/MCLK
4
PTB1
5 PTB2/TCHO
20
PTB3/TCLK
2
25
22
26
23
8
X0
24
14
11
8P
C0G
CR1
7
IC1
HC908RF2REV1
C5
12K
10
Figure 3-7. Transmitter Schematic
10K
R21 R19
R16
330
1K
CNE
10k
R20 R18
IRQ
OSC2
10
R14
VDD
10k
R18
SW2
SW4
SW3
SW1
SW5
SW6
RESET
VSS
SW8
VCCPF
X1
SW7
VCC
CFBK
LD1
R17
9
PEXT
MOTOROLA
13
VCC
6
10N
X7R
RFOUT 12
GND
CN1 CN2 CN3
GNDPF
Freescale Semiconductor, Inc...
8P
C0G
C8
3 MM
1.4–3 pF
C3
C8
L1
C2
100P 1U
COB Y5V
22 nH
C7
Freescale Semiconductor, Inc.
Reference Board Hardware
Transmitter
DRM005
29
Freescale Semiconductor, Inc.
Reference Board Hardware
The circuit is very simple.
•
Freescale Semiconductor, Inc...
NOTE:
WARNING:
The power supply is a CR2032 lithium battery connected directly
to the MC68HC908RF2 (IC1).
When the RF PLL is disabled and the MCU is in sleep mode the power
consumption is less then 100 nA.
•
The keyboard (a 4 x 2 crosspoint rubber keyboard) connected to
the keyboard port wakes up the MCU.
•
The MCU has an internal clock generator with no external
components.
•
CR1 an C6 are the reference oscillators for the RF PLL enabled
by the PLLEN pin. When PLLEN = 1 the oscillator is ON and a
reference signal DCLK = XTAL/64 is available. DCLK is used as a
reference clock for the MCU timer to generate an accurate
modulation signal. This signal is available only when PLL is ON.
The MC68HC908RF2 has two separate chips in the same case, one
is the MCU and one is the RF transmitter. A buffer is needed if the
MCU is to be used to drive other logic gates.
•
C2, C3, C8, C9, and L1 are the matching network for the small
loop antenna.
•
R20 and R21 are used to select the band and only one of them
must be assembled.
•
R12 is the output power setting resistor and sets the current of the
RF power amplifier.
3.7 Mother Board Display Menu
Figure 3-8 shows the mother board display menu.
DRM005
30
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Reference Board Hardware
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
MOTOROLA
TX Menu
Power Off
X RX Menu
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Reference Board Hardware
For More Information On This Product,
Go to: www.freescale.com
X
CR2=A1
CR3=00
X
Receive
Set MC3359x
315MHz
XCR1=14
Coding type
Rolling
ESC to exit
X
Coding type
Fixed
ESC to exit
Figure 3-8. Mother Board Display Menu
Program Tx
File name:
UK804
X
Program Tx
File name:
No File
X
Programming
firmware not
loaded!
No File in
memory!
Set MC3359x
434/868MHz
XReceive
Rx board not
found!
Freescale Semiconductor, Inc...
--ID--KKRRRR
5423F4860084
C587B8F090FD
Tx ID 5423F4
Key Sx 3
CRC EC
Freescale Semiconductor, Inc.
Reference Board Hardware
Mother Board Display Menu
DRM005
31
Freescale Semiconductor, Inc.
Freescale Semiconductor, Inc...
Reference Board Hardware
DRM005
32
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Reference Board Hardware
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Designer Reference Manual — Remote Keyless Entry
Section 4. HC908RF2 for Windows Installation
Freescale Semiconductor, Inc...
4.1 Contents
4.2
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
4.3
Installation Screens . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .33
4.2 Introduction
This section provides the installation screens for the MC68HC908RF2
reference board.
4.3 Installation Screens
See Figure 4-1 through Figure 4-8.
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
HC908RF2 for Windows Installation
For More Information On This Product,
Go to: www.freescale.com
DRM005
33
Freescale Semiconductor, Inc.
Freescale Semiconductor, Inc...
HC908RF2 for Windows Installation
Figure 4-1. Startup Screen
DRM005
34
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
HC908RF2 for Windows Installation
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Freescale Semiconductor, Inc...
HC908RF2 for Windows Installation
Installation Screens
Figure 4-2. Welcome Screen
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
HC908RF2 for Windows Installation
For More Information On This Product,
Go to: www.freescale.com
DRM005
35
Freescale Semiconductor, Inc.
Freescale Semiconductor, Inc...
HC908RF2 for Windows Installation
Figure 4-3. License Agreement
DRM005
36
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
HC908RF2 for Windows Installation
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Freescale Semiconductor, Inc...
HC908RF2 for Windows Installation
Installation Screens
Figure 4-4. Choose Destination Location Screen
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
HC908RF2 for Windows Installation
For More Information On This Product,
Go to: www.freescale.com
DRM005
37
Freescale Semiconductor, Inc.
Freescale Semiconductor, Inc...
HC908RF2 for Windows Installation
Figure 4-5. Setup Type
DRM005
38
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
HC908RF2 for Windows Installation
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Freescale Semiconductor, Inc...
HC908RF2 for Windows Installation
Installation Screens
Figure 4-6. Select Program Folder
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
HC908RF2 for Windows Installation
For More Information On This Product,
Go to: www.freescale.com
DRM005
39
Freescale Semiconductor, Inc.
Freescale Semiconductor, Inc...
HC908RF2 for Windows Installation
Figure 4-7. Install Files
DRM005
40
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
HC908RF2 for Windows Installation
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Freescale Semiconductor, Inc...
HC908RF2 for Windows Installation
Installation Screens
Figure 4-8. Finish
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
HC908RF2 for Windows Installation
For More Information On This Product,
Go to: www.freescale.com
DRM005
41
Freescale Semiconductor, Inc.
Freescale Semiconductor, Inc...
HC908RF2 for Windows Installation
DRM005
42
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
HC908RF2 for Windows Installation
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Designer Reference Manual — Remote Keyless Entry
Section 5. Remote Programming Commands
Freescale Semiconductor, Inc...
5.1 Contents
5.2
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
5.3
Communication Protocol. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
5.4
Command Set Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
5.4.1
Erase Programming Algorithm Memory (EPG) . . . . . . . . . .45
5.4.2
Erase TX S19 Memory (ETX). . . . . . . . . . . . . . . . . . . . . . . .46
5.4.3
Erase User Code Memory (EUM) . . . . . . . . . . . . . . . . . . . . 47
5.4.4
Initialize MC33592/3 Registers (IRR) . . . . . . . . . . . . . . . . . . 48
5.4.5
Load Programming Algorithm (LPG) . . . . . . . . . . . . . . . . . . 49
5.4.6
Load TX S19 File (LTX) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
5.4.7
Product ID (PID) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .53
5.4.8
Read MC33592/3 Registers (RRR) . . . . . . . . . . . . . . . . . . .54
5.4.9
Update User Code (UUC) . . . . . . . . . . . . . . . . . . . . . . . . . . 55
5.4.10 MC33592/3 Registers (WRR). . . . . . . . . . . . . . . . . . . . . . . .57
5.2 Introduction
A set of commands is available to control the FlashProg from the RS232
serial interface. This section will explain the format and parameters of
each command.
5.3 Communication Protocol
Commands are send to FlashProg using data packets. A data packet is
composed of packet length, the command, parameters, data, and
checksum. Parameters and data fields are optional.
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Remote Programming Commands
For More Information On This Product,
Go to: www.freescale.com
DRM005
43
Freescale Semiconductor, Inc.
Remote Programming Commands
The maximum length of a packet is 64 bytes. The packet length is 1 byte,
the command is an ASCII mnemonic of three characters. Parameters
and data are of variable size and the checksum length is 1 byte.
Freescale Semiconductor, Inc...
The command packet format is shown in Figure 5-1.
$1B
PACKET LENGTH
1 BYTE
BYTE 0
BYTE 1
COMMAND
3 BYTES
PARAMETERS
n BYTES
DATA
m BYTES
CHECKSUM
1 BYTE
BYTE p
Figure 5-1. Command Packet Format
Checksum is one’s complement of the least significant bit (LSB) of the
sum from packet length (included) to the checksum (excluded).
The answer from FlashProg can be one of four types:
•
“Y” = Packet correct and command executed without error
•
“N” = Packet error
•
Exxx = Packet correct but command ended with error xxx
•
A data packet
The answer data package format is shown in Figure 5-2.
$1B
PACKET LENGTH
1 BYTE
BYTE 0
BYTE 1
DATA
m BYTES
CHECKSUM
1 BYTE
BYTE p
Figure 5-2. Command Packet Format
5.4 Command Set Parameters
This subsection provides the command set parameters available to
control the FlashProg from the RS232 serial interface.
DRM005
44
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Remote Programming Commands
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Remote Programming Commands
Command Set Parameters
5.4.1 Erase Programming Algorithm Memory (EPG)
The EPG command will erase the memory area from $D7FF to $D6FF.
The programming algorithm for the MC68HC908RF2 is stored in this
area.
The EPG command packet has the following composition:
Freescale Semiconductor, Inc...
$1B
$04
EPG
$1F
Field
Value
Type
Length
Header
$1B
Byte
1
Length
4
Byte
1
Mnemonic
EPG
Character
3
Checksum
Checksum
Byte
1
The answer to the EPG command has the following composition:
Answer
ASCII
Meaning
Y
$59
Memory erased
N
$4E
Packet not valid
Command examples:
To erase the programming algorithm area the following command
packet must be sent.
$1B,$04,”EPG”,$1F
or in HEX
$1B,$04,$45,$50,$47,$1F
The answer will be:
Y
or in HEX
$59
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Remote Programming Commands
For More Information On This Product,
Go to: www.freescale.com
DRM005
45
Freescale Semiconductor, Inc.
Remote Programming Commands
5.4.2 Erase TX S19 Memory (ETX)
The ETX command will erase the memory area from $E700 to $EFFF.
The S19 file for the MC68HC908RF2 is stored in this area.
The ETX command packet has the following composition:
Freescale Semiconductor, Inc...
$1B
$04
ETX
$0A
Field
Value
Type
Length
Header
$1B
Byte
1
Length
4
Byte
1
Mnemonic
ETX
Character
3
Checksum
Checksum
Byte
1
The answer to the ETX command has the following composition:
Answer
ASCII
Meaning
Y
$59
Memory erased
N
$4E
Packet not valid
Command examples:
To erase the programming algorithm area the following command
packet must be sent.
$1B,$04,”ETX”,$0A
or in HEX
$1B,$04,$45,$54,$58,$0A
The answer will be:
Y
or in HEX
$59
DRM005
46
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Remote Programming Commands
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Remote Programming Commands
Command Set Parameters
5.4.3 Erase User Code Memory (EUM)
The EUM command will erase the memory area from $8000 to $CFFF.
The user code is stored in this area.
The EUM command packet has the following composition:
Freescale Semiconductor, Inc...
$1B
$04
EUM
$14
Field
Value
Type
Length
Header
$1B
Byte
1
Length
4
Byte
1
Mnemonic
EUM
Character
3
Checksum
Checksum
Byte
1
The answer to the EUM command has the following composition:
Answer
ASCII
Meaning
Y
$59
Memory erased
N
$4E
Packet not valid
Command examples:
To erase the user code area the following command packet must be
sent.
$1B,$04,” EUM”,$14
or in HEX
$1B,$04,$45,$55,$4D,$14
The answer will be:
Y
or in HEX
$59
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Remote Programming Commands
For More Information On This Product,
Go to: www.freescale.com
DRM005
47
Freescale Semiconductor, Inc.
Remote Programming Commands
5.4.4 Initialize MC33592/3 Registers (IRR)
The IRR command will load MC3359X registers CR1, CR2, and CR3
with the value stored in FLASH memory.
The IRR command packet has the following composition:
Freescale Semiconductor, Inc...
$1B
$04
IRR
$0E
Field
Value
Type
Length
Header
$1B
Byte
1
Length
4
Byte
1
Mnemonic
IRR
Character
3
Checksum
Checksum
Byte
1
The answer to the EPG command has the following composition:
Answer
ASCII
Meaning
Y
$59
Command executed
successfully
N
$4E
Packet not valid
E001
$45, $30, $30,
$31
Receiver board not present
Command examples:
To INIT the MC3359X registers with the NV memory value the
following command packet must be sent.
$1B,$04,” IRR”,$0E
or in HEX
$1B,$04,$49,$52,$52,$0E
If the command has been executed successfully and is blank the
answer will be:
Y
or in HEX
$59
If the receiver board is not present the answer will be:
E001
or in HEX
$45,$30,$30,$31
DRM005
48
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Remote Programming Commands
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Remote Programming Commands
Command Set Parameters
5.4.5 Load Programming Algorithm (LPG)
The LPG command will load the programming algorithm for the
MC68HC908GP32 and will wait for data.
The LPG command packet has the following composition:
Freescale Semiconductor, Inc...
$1B
$04
LPG
$18
Field
Value
Type
Length
Header
$1B
Byte
1
Length
4
Byte
1
Mnemonic
LPG
Character
3
Checksum
Checksum
Byte
1
The answer to the LPG command has the following composition:
Answer
ASCII
Meaning
Y
$59
Read to receive data
N
$4E
Packet not valid
Command examples:
After the answer “Y”, the MC68HC908GP32 on the reference board
is ready to receive data. The PC must send the character “S” and
receive an “S” as echo.
The data is sent after the “S” and has the following composition:
Number
of Packets
(2 Bytes)
Packet 1
…..
Packet N
Checksum
(1 Byte)
Start Address
Data Bytes
(Max 256)
Data format:
Number
of Data Bytes
(1 Byte)
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Remote Programming Commands
For More Information On This Product,
Go to: www.freescale.com
DRM005
49
Freescale Semiconductor, Inc.
Remote Programming Commands
Packet format:
At the end of each packet the reference board will send the
character “Y”.
Command examples:
To start loading the programming algorithm area the following
command packet must be sent:
$1B,$04,”LPG”,$18
Freescale Semiconductor, Inc...
or in HEX
$1B,$04,$4C,$50,$47,$18
The answer will be:
Y
or in HEX
$59
DRM005
50
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Remote Programming Commands
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Remote Programming Commands
Command Set Parameters
5.4.6 Load TX S19 File (LTX)
The LTX command will load the programming algorithm for the
MC68HC908GP32 and will wait for data. The data will be stored in the
Tx S19 file area (0xE700 to 0xEFFF).
The LPG command packet has the following composition:
Freescale Semiconductor, Inc...
$1B
$04
LTX
$03
Field
Value
Type
Length
Header
$1B
Byte
1
Length
4
Byte
1
Mnemonic
LTX
Character
3
Checksum
Checksum
Byte
1
The answer to the LTX command has the following composition:
Answer
ASCII
Meaning
Y
$59
Ready to receive data
N
$4E
Packet not valid
After the answer “Y”, the MC68HC908GP32 on the reference board is
ready to receive data. The PC must send the character “S” and receive
an “S” as echo.
The data is sent after the “S” and has the following composition:
Number
of Packets
(2 Bytes)
Packet 1
…..
Packet N
Checksum
(1 byte)
Start Address
Data Bytes
(Max 256)
Data format:
Number
of Data Bytes
(1 Byte)
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Remote Programming Commands
For More Information On This Product,
Go to: www.freescale.com
DRM005
51
Freescale Semiconductor, Inc.
Remote Programming Commands
Packet format:
At the end of each packet the reference board will send the
character “Y”.
Command examples:
To start loading the S19 file area the following command packet must
be sent.
$1B,$04,”LTX”,$03
Freescale Semiconductor, Inc...
or in HEX
$1B,$04,$4C,$54,$58,$03
The answer will be:
Y
or in HEX
$59
DRM005
52
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Remote Programming Commands
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Remote Programming Commands
Command Set Parameters
5.4.7 Product ID (PID)
The PID command will ask the MC68HCHC908RF2 for the firmware
revision.
The PID command packet has the following composition:
Freescale Semiconductor, Inc...
$1B
$04
PID
$1E
Field
Value
Type
Length
Header
$1B
Byte
1
Length
4
Byte
1
Mnemonic
PID
Character
3
Checksum
Checksum
Byte
1
The answer to the PID command has the following composition:
Answer
ASCII
RFB XY.Z
$52, $46, $42,
$20, $XX, $3Y,
$2E, $3Z
N
$4E
Meaning
Packet not valid
Command examples:
To get the firmware revision, the following command packet must be
sent.
$1B,$04,”PID”,$1E
or in HEX
$1B,$04,$50,$49,$44,$1E
An example answer will be:
RFB A0.0
or in HEX
$52,$46,$42,$20,$41,$30,$2E,$30
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Remote Programming Commands
For More Information On This Product,
Go to: www.freescale.com
DRM005
53
Freescale Semiconductor, Inc.
Remote Programming Commands
5.4.8 Read MC33592/3 Registers (RRR)
The RRR command will read MC3359X registers CR1, CR2, and CR3.
The RRR command packet has the following composition:
Freescale Semiconductor, Inc...
$1B
$04
RRR
$05
Field
Value
Type
Length
Header
$1B
Byte
1
Length
4
Byte
1
Mnemonic
RRR
Character
3
Checksum
Checksum
Byte
1
The answer to the RRR command has the following composition:
Answer
ASCII
Meaning
XYZ Y
$XX, $YY,
$ZZ, $59
XX = CR1, YY = CR2,
ZZ = CR3
N
$4E
Packet not valid
E001
$45, $30, $30,
$31
Receiver board not present
Command examples:
To read the MC3359X registers, the following command packet must
be sent.
$1B,$04,” RRR”,$05
or in HEX
$1B,$04,$52,$52,$52,$05
If the command has been executed successfully and CR1 = $46,
CR2 = $04, CR3 = $00 the answer will be:
$46,$04,$00,Y
or in HEX
$46,$04,$00,$59
If the receiver board is not present the answer will be:
E001
or in HEX
$45,$30,$30,$31
DRM005
54
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Remote Programming Commands
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Remote Programming Commands
Command Set Parameters
5.4.9 Update User Code (UUC)
The UUC command will update the firmware stored in the area 0x8000
to 0xCFFF.
The UUC command packet has the following composition:
Freescale Semiconductor, Inc...
$1B
$04
UUC
$0E
Field
Value
Type
Length
Header
$1B
Byte
1
Length
4
Byte
1
Mnemonic
UUC
Character
3
Checksum
Checksum
Byte
1
The answer to the UUC command has the following composition:
Answer
ASCII
Meaning
Y
$59
Ready to receive data
N
$4E
Packet not valid
After the answer “Y”, the MC68HC908GP32 on the reference board is
ready to receive data. The PC must send the character “S” and receive
an “S” as echo.
The data is sent after the “S” and has the following composition:
Number
of Packets
(2 Bytes)
Packet 1
…..
Packet N
Checksum
(1 Byte)
Start Address
Data Bytes
(Max 256)
Data format:
Number
of Data Bytes
(1 Byte)
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Remote Programming Commands
For More Information On This Product,
Go to: www.freescale.com
DRM005
55
Freescale Semiconductor, Inc.
Remote Programming Commands
Packet format:
At the end of each packet the reference board will send the character
“Y”.
Command examples:
To start updating the firmware the following command packet must be
sent:
$1B,$04,”UUC”,$0E
Freescale Semiconductor, Inc...
or in HEX
$1B,$04,$55,$55,$43,$0E
The answer will be:
Y
or in HEX
$59
DRM005
56
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Remote Programming Commands
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Remote Programming Commands
Command Set Parameters
5.4.10 MC33592/3 Registers (WRR)
The WRR command will write MC3359X registers CR1, CR2, and CR3
and update the INIT value stored in the FLASH memory.
The WRR command packet has the following composition:
Freescale Semiconductor, Inc...
$1B
$07
WRR
CR1, CR2, CR3
(3 Bytes)
Checksum
Field
Value
Type
Length
Header
$1B
Byte
1
Length
$07
Byte
1
Mnemonic
WRR
Character
3
Parameter
CR1, CR2,
CR3
Byte
3
Checksum
Checksum
Byte
1
The answer to the WRR command has the following composition:
Answer
ASCII
Meaning
Y
$59
Command executed
successfully
N
$4E
Packet not valid
E001
$45, $30, $30,
$31
Receiver board not present
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Remote Programming Commands
For More Information On This Product,
Go to: www.freescale.com
DRM005
57
Freescale Semiconductor, Inc.
Remote Programming Commands
Command examples:
To set CR1 = $54, CR2 = $30, and CR3 = $00 the following command
packet must be sent:
$1B,$05,”WRR”,$54,$30,$00,$79
or in HEX
$1B,$05,$53,$42,$4D,$03,$79
The answer will be:
Freescale Semiconductor, Inc...
Y
or in HEX
$59
If the receiver board is not present the answer will be
E001
or in HEX
$45,$30,$30,$31
DRM005
58
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Remote Programming Commands
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Designer Reference Manual — Remote Keyless Entry
Appendix A. Source Code
A.1 Contents
Freescale Semiconductor, Inc...
A.2
Mother Board Firmware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
A.2.1
UK509.ASM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
A.2.2
UK509 PRM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
A.3
NOTE:
Transmitter Firmware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
The MC33592/3 is referred to as Romeo and the MC33491 is referred to
as Tango in the source code.
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Source Code
For More Information On This Product,
Go to: www.freescale.com
DRM005
59
Freescale Semiconductor, Inc.
Source Code
A.2 Mother Board Firmware
A.2.1 UK509.ASM
Freescale Semiconductor, Inc...
base $10
USERSUM
USERSUM1
USERSUM2
equ
equ
equ
$912D
$0569
$13EB
;Emulated
;TestAgent
equ
equ
0
0
;------------------------------------------------------------------------------;
; MC908RF2 reference board software
;
;------------------------------------------------------------------------------;
; SOURCE
: UK509.ASM
; CONTROLLER : 68HC908GP32
; CLOCK
: 9.8304 Mhz
;
; VERSION
: B.00
04 Ago 2001
;
;------------------------------------------------------------------------------;
;
#$-VIEW:Schematics-$
Revision
PlugVer
include
;
equ
equ
$0100
3
"C:\Metrowerks\lib\HC08c\INC\H908GP32.INC"
#$-VIEW:Register Declarations-$#
;------------------------------------------------------------------------------;
; Port A
;
; Port A is used as 8 bit Data bus
;
;
; Pull Down : A(7)
;
DDRAInit
PortAInit
equ
equ
%00000000
%00000000
;
;
;------------------------------------------------------------------------------;
DRM005
60
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Source Code
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Freescale Semiconductor, Inc...
Source Code
Mother Board Firmware
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
Port B
Port B bits
CDE
SC
OE
Bank0
Bank1
WE
SCLP
SDAP
:
:
:
:
:
:
:
:
HN29F12814A Command Data Enable
HN29F12814A Serial Clock
HN29F12814A Output Enable
Bank0 0/1 selct
Bank1 0/1 selct
HN29F12814A Write Enable
I2C Bus Pod SCL
I2C Bus Pod SDA
Hardware changes
None
; Porta B
CDE
SC
OE
Bank0
Bank1
WE
SCLP
SDAP
equ
equ
equ
equ
equ
equ
equ
equ
0
1
2
3
4
5
6
7
;
;
;
;
;
;
;
;
DDRBInit
PortBInit
equ
equ
%11111111
%11111101
;
;
;------------------------------------------------------------------------------;
; Port C
;
; Port C bits
;
;KEY
: Select Switch : 0=Pushed 1=Not pushed
;EVHH
: Enable Mon08 VHH
;RST
: Mon08 Reset
;HOLD
: Main Power Supply Hold (1=Hold,0=Power Off)
;EVCC
: Enable Mon08 VCC
;NDAC
: Max533 DAC Enable (active low)
;LE
: Switch Led (0=On,1=Off)
;
; Hardware changes
;
; None
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Source Code
For More Information On This Product,
Go to: www.freescale.com
DRM005
61
Freescale Semiconductor, Inc.
Source Code
Freescale Semiconductor, Inc...
; Porta C
KEY
EVHH
RST
HOLD
EVCC
NDAC
LED
equ
equ
equ
equ
equ
equ
equ
0
1
2
3
4
5
6
;
;
;
;
;
;
;
DDRCInit
PortCInit
equ
equ
%01111110
%01101000
;
;
;------------------------------------------------------------------------------;
; Port D
;
; Port D bits
;
;Slave
: SPI Slave pin
;PodIRQ
: MON08 IRQ
;MOSI
: SPI MOSI
;PodData
: MON08 Data
;PUSHBUT
: Encoder Push Button (0=Pushed,1=Not pushed)
;ENCB
: Encoder Phase B
;SCL
: I2C Bus clock
;SDA
: I2C Bus data
;
; Hardware changes
;
; None
;
; Porta D
Slave
PodIRQ
MOSI
PodData
PUSHBUT
ENCB
SCL
SDA
equ
equ
equ
equ
equ
equ
equ
equ
0
1
2
3
4
5
6
7
;
;
;
;
;
;
;
;
DDRDInit
PortDInit
equ
equ
%11000011
%11000101
;
;
DRM005
62
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Source Code
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Freescale Semiconductor, Inc...
Source Code
Mother Board Firmware
FlashRAM:
SECTION SHORT
LineLen
LineSum
StartAddr
EndAddr
ByteCount
NumLines
FlashTop
DS.B
DS.B
DS.B
DS.B
DS.B
DS.B
DS.B
1
1
2
2
1
2
2
;
;
;
;
;
;
;
Dly30usPod
equ
$20
;20us @ Fbus=2.4576MHz
BiosRAM:
SECTION SHORT
RFflags
BufferRF
BitCount
RFCRC
BufPtr
LastTim
Cell0
DeltaT
EncCnt
EncStep
CurX
CurY
Max
Min
CurItem
CurMenuPtr
TmpPtr
RS232St
CRC232
SFlags
BufferCnt
SourcePtr
DestPtr
VHH
RS232Tmo
DispDump1
EchoFlags
LastV
UpdateTmo
MFlags
CR1
CR2
CR3
DS.B
DS.B
DS.B
DS.B
DS.B
DS.W
DS.B
DS.W
DS.B
DS.B
DS.B
DS.B
DS.B
DS.B
DS.B
DS.B
DS.B
DS.B
DS.B
DS.B
DS.B
DS.B
DS.B
DS.B
DS.B
DS.B
DS.B
DS.B
DS.B
DS.B
DS.B
DS.B
DS.B
1
8
1
1
1
1
1
1
1
1
1
1
1
1
1
2
2
1
1
1
1
2
2
1
2
14
1
1
1
1
1
1
1
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Source Code
For More Information On This Product,
Go to: www.freescale.com
DRM005
63
Freescale Semiconductor, Inc.
Freescale Semiconductor, Inc...
Source Code
BUFFERS:
SECTION
BufferSize
equ
$50
RxBuffer
StringBuffer
StringBuffer1
StringBuffer2
FlashBuffer
DS.B
DS.B
DS.B
DS.B
DS.B
50
18
18
18
50
EEBuf
equ
StringBuffer
;Size of RS232 buffer
; Bit of RS232Status
EscRec
equ
1
;Esc received (Receiving Packet)
equ
equ
equ
0
1
2
;User commands enabled
;1=Tx code present
;Programming code enabled
Cod
equ
0
;0=Fixed,1=Rolling
ModeMsk
equ
%00000001
;
; Bit of SFlags
UserC
TXFile
UserP
; Bit of MFlags
; Bit of RFFlags
CRCP
EndFrame
EdgRF
BlankW
LoadRF
SyncW
Lockd
equ
equ
equ
equ
equ
equ
equ
0
1
2
3
4
5
6
;Flag
;Flag
;Flag
;Flag
;Flag
;Flag
;Flag
RFMask
equ
%00000100
;
DRM005
64
CRC Pending
Lern OK
RF Edge
Sync Waiting
Received Status
Waiting Sync
RF locked
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Source Code
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Source Code
Mother Board Firmware
Freescale Semiconductor, Inc...
;Bit of CR1
HE
DME
SR0
SR1
SOE
MOD
CF
RW
equ
equ
equ
equ
equ
equ
equ
equ
0
1
2
3
4
5
6
7
;0=Write CRx
;
;
;
;
;
;
;
CFMsk
equ
%01000000
;
;------------------------------------------------------------------------------;
; Time contants
Dly5us
Dly10us
Dly30us
Dly100us
equ
equ
equ
equ
$04
$08
$28
$51
;5uS @ FBus=2.4576MHz
;10uS @ FBus=2.4576MHz
;30uS @ FBus=2.4576MHz
;100uS @ FBus=2.4576MHz
MinSync
MaxCell
equ
equ
75
60
;
;
;------------------------------------------------------------------------------;
;------------------------------------------------------------------------------;
; Blink Frequency divider
;
; This value is used to set the blinking frequency of the cursor during input
BlinkDiv
equ
%00001000
;-------------------------------------------------------------------------------
UserCode:
SECTION
UserCodeSum
DC.W
DC.W
USERSUM
UserCodeEnd
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Source Code
For More Information On This Product,
Go to: www.freescale.com
DRM005
65
Freescale Semiconductor, Inc.
Source Code
UserProg
IFNDEF TestAgent
jsr
jmp
Clr
MainMenu
;
;
Freescale Semiconductor, Inc...
Warning
pshx
pshh
jsr
pulh
pulx
jsr
jsr
rts
Clr
PrintStr1
WaitInput
;
;
;
;
;
;
;
;
;Hex to string convesion
;
;On entry
; X,A=Pointer to string
; SP-3=Data
;On exit
; X,A=Pointer to end of string
HexToStr
pshx
pulh
tax
lda
nsa
and
bsr
lda
and
bsr
clr
pshh
txa
pulx
rts
3,SP
#$0F
SetNibble
3,SP
#$0F
SetNibble
,X
;
;
;
;
;
;
;
;
;
;
;Null terminate string
;
;
;
;
SetNibble
add
cmp
bls
add
#$30
#$39
NoAlfa1
#$07
;
;Convert to ascii
;
;
sta
aix
rts
,X
#$0001
;
;
;
NoAlfa1
DRM005
66
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Source Code
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Source Code
Mother Board Firmware
;Char to Hex nibble
;
;On entry
; A=char
;On exit
; A=Hex value
CharToHex
Freescale Semiconductor, Inc...
sub
cmp
bls
sub
#$30
#$09
NibbleOK
#$07
;
;
;
;
NibbleOK
rts
;
;******************************************************************************
;
; RS232 User routines
;
;******************************************************************************
;***********************************************
; Init Romeo Register Command
;
; Buffer status;
;
; 00
PackLen (Packet Length 04)
; 01-03
"IRR"
; 04
Packet Checksum ($0E)
;***********************************************
CmdIRR
jsr
beq
lda
jmp
ChkRomeo
CmdIRR1
#$01
ErrCode
;
;
;
;
jsr
jmp
InitRomeo
CmdOK
;
;
CmdIRR1
;***********************************************
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Source Code
For More Information On This Product,
Go to: www.freescale.com
DRM005
67
Freescale Semiconductor, Inc.
Source Code
; Read Romeo Register Command
;
; Buffer status;
;
; 00
PackLen (Packet Length 04)
; 01-03
"RRR"
; 04
Packet Checksum ($05)
;***********************************************
Freescale Semiconductor, Inc...
CmdRRR
jsr
beq
lda
jmp
ChkRomeo
CmdRRR1
#$01
ErrCode
;
;
;
;
jsr
lda
jsr
lda
jsr
lda
jsr
jmp
ReadRomeo
CR1
PutRS232
CR2
PutRS232
CR3
PutRS232
CmdOK
;
;
;
;
;
;
;
;
CmdRRR1
;***********************************************
; Write Romeo Registers Command
;
; Buffer status;
;
; 00
PackLen (Packet Length 07)
; 01-03
"WRR"
; 04
CR1
; 05
CR2
; 06
CR3
; 07
Packet Checksum ($XX)
;***********************************************
CmdWRR
jsr
beq
lda
jmp
ChkRomeo
CmdWRR1
#$01
ErrCode
;
;
;
;
lda
and
sta
lda
sta
lda
sta
jsr
jsr
RxBuffer+4
#$7F
CR1
RxBuffer+5
CR2
RxBuffer+6
CR3
WriteRomeo
SaveNVCR
;
;
;
;
;
;
;
;
;
CmdWRR1
DRM005
68
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Source Code
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Source Code
Mother Board Firmware
CmdOK
Freescale Semiconductor, Inc...
lda
jsr
clr
clr
rts
#’Y’
PutRS232
BufferCnt
RS232St
;
;
;
;
;
;***********************************************
; Send Error Code
;
; 01=No Romeo Module
;
;***********************************************
ErrCode
psha
lda
jsr
pula
jsr
clr
clr
rts
#’E’
PutRS232
SendDec
BufferCnt
RS232St
;
;
;
;
;
;
;
;
;******************************************************************************
;
; ROMEO2 driver
;
;******************************************************************************
ReadRomeo
pshh
pshx
psha
mov
bclr
bclr
lda
jsr
jsr
sta
lda
bsr
bsr
sta
lda
bsr
bsr
sta
#%00101010,SPCR
Bank0,PORTB
Bank1,PORTB
#$80
SendRomeo
GetRomeo
CR1
#$00
SendRomeo
GetRomeo
CR2
#$00
SendRomeo
GetRomeo
CR3
;
;
;
;Init SPI as master
;CS3 must be low
;
;
;
;
;
;
;
;
;
;
;
;
;
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Source Code
For More Information On This Product,
Go to: www.freescale.com
DRM005
69
Freescale Semiconductor, Inc.
Source Code
bset
bset
pula
pulx
pulh
rts
Bank0,PORTB
Bank1,PORTB
;CS3 must be high
;
;
;
;
;
jsr
lda
psha
lda
sta
bsr
jsr
lda
ldx
sta
stx
bsr
pula
cmp
rts
ReadRomeo
CR2
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
lda
sta
lda
sta
lda
sta
bsr
jsr
mov
bset
bclr
rts
NVRegs
CR1
NVRegs+1
CR2
NVRegs+2
CR3
WriteRomeo
ReadRomeo
#%10001010,SPCR
Bank0,PORTB
Bank1,PORTB
;
;
;
;
;
;
;
;
;Init SPI slave
;CS2 must be low
;
;
jsr
sta
ReadRomeo
CR2
;
;
#%00101010,SPCR
Bank0,PORTB
Bank1,PORTB
CR1
;
;
;
;Init SPI as master
;CS3 must be low
;
;
Freescale Semiconductor, Inc...
ChkRomeo
#$AA
CR2
WriteRomeo
ReadRomeo
CR2
1,SP
1,SP
CR2
WriteRomeo
#$AA
InitRomeo
RomeoSetID
WriteRomeo
pshh
pshx
psha
mov
bclr
bclr
lda
DRM005
70
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Source Code
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Freescale Semiconductor, Inc...
Source Code
Mother Board Firmware
and
bsr
bsr
lda
bsr
bsr
lda
bsr
bsr
bset
bset
pula
pulx
pulh
rts
#$7F
SendRomeo
GetRomeo
CR2
SendRomeo
GetRomeo
CR3
SendRomeo
GetRomeo
Bank0,PORTB
Bank1,PORTB
;WE bit low
;
;
;
;
;
;
;
;
;CS3 must be high
;
;
;
;
;
brclr
sta
rts
SPTE,SPSCR,*
SPDR
;Wait transmitter empty
;
;
brclr
lda
rts
SPRF,SPSCR,*
SPDR
;
;
;
tst
lda
rti
SPSCR
SPDR
;
;
;
SendRomeo
GetRomeo
SPIProc
;******************************************************************************
;
; Reception Routines without Data Manager Enabled
;
;******************************************************************************
InitCode
jsr
ldhx
brclr
ldhx
Home
#Frame1
Cod,MFlags,PrintFrame
#Frame2
;
;
;
;
jsr
PrintStr1
;
PrintFrame
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Source Code
For More Information On This Product,
Go to: www.freescale.com
DRM005
71
Freescale Semiconductor, Inc.
Source Code
InitRF
Freescale Semiconductor, Inc...
lda
sta
lda
sta
bset
bset
bclr
bclr
clr
rts
#$08
BitCount
#$07
BufPtr
SyncW,RFflags
BlankW,RFflags
Lockd,RFflags
CRCP,RFflags
RFCRC
;
;
;
;
;
;
;
;
;
;
; Check of the RF signal edges
GetRF
brclr
jmp
EndFrame,RFflags,NotEOF ;End Frame ?
EOF
;
lda
eor
and
bne
rts
PORTD
RFflags
#RFMask
NewEdge
NotEOF
;
;Change in RF Input signal ?
;
;
;
; Calculation of DeltaT, Update of LastRTCC, Reset of Offset
; and change of edge
NewEdge
;
;
;
;
;
;
;
;
NewEdge1
ldhx
brclr
lda
dbnza
lda
eor
and
bne
rts
txa
sub
sta
pshh
pula
sbc
sta
sthx
lda
eor
sta
brset
DRM005
72
T1CNTH
EdgRF,RFflags,NewEdge1
#$50
$
PORTD
RFflags
#RFMask
NewEdge1
LastTim+1
DeltaT+1
LastTim
DeltaT
LastTim
#RFMask
RFflags
RFflags
EdgRF,RFflags,RiseRF
;
;Rising edge ?
;
;
;
;RF Input changed?
;
;
;
;
;If Yes, determine DeltaT
;
;
;
;
;
;
;Change of edge
;
;
;Rising edge ?
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Source Code
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Source Code
Mother Board Firmware
Freescale Semiconductor, Inc...
;Falling Edge: If don’t wait for Sync determine the bit
bclr
bset
brclr
brset
ldhx
cphx
bhi
cphx
blo
bclr
LED,PORTC
Lockd,RFflags
SyncW,RFflags,BitCalc
BlankW,RFflags,ExitRF
DeltaT
#$0060
InitRF
#$0020
InitRF
SyncW,RFflags
;
;Syncronization Signal
;Sync waiting ?
;Yes,Sync waiting ?
;Yes,check if Sync is correct
;
;
;
;
;Sync flag reset
ExitRF
rts
;Go out
;Rising Edge : Cell0=DeltaT
RiseRF
bset
brclr
brclr
ldhx
cphx
bhi
cphx
blo
bclr
rts
LED,PORTC
Lockd,RFflags,ExitRF
BlankW,RFflags,RiseRF1
DeltaT
#$0060
InitRF
#$0020
InitRF
BlankW,RFflags
;
;Locked ?
;Yes,Sync waiting ?
;Yes,check if Sync is correct
;
;
;
;
;Sync Flag Reset
;
lda
bne
lda
sta
rts
DeltaT
ExitRF
DeltaT+1
Cell0
;
;
;
;
;
RiseRF1
;Calcola bit
BitCalc
clrh
lda
bne
lda
cmp
bhi
lda
sub
ldx
ror
brclr
lda
DeltaT
ExitRF
DeltaT+1
#MaxCell
FrameErr1
Cell0
DeltaT+1
BufPtr
BufferRF,X
CRCP,RFflags,NoCRC
RFCRC
;
;Yes, check if the cell is correct
;
;
;
;
;Calculation of the Cell Rapport
;
;
;bit Insertion
;CRC Pending ?
;
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Source Code
For More Information On This Product,
Go to: www.freescale.com
DRM005
73
Freescale Semiconductor, Inc.
Source Code
rora
ror
lda
eor
and
bclr
beq
bset
lda
eor
sta
RFCRC
RFCRC
BufferRF,X
#%10000000
7,RFCRC
NoCRC
7,RFCRC
#%00001100
RFCRC
RFCRC
;
;
;
;
;
;
;
;
;
;
;
dbnz
BitCount,ExitRF
;Next bit
Freescale Semiconductor, Inc...
NoCRC
;Next Byte
lda
sta
dec
bset
lda
bpl
bset
rts
#$08
BitCount
BufPtr
CRCP,RFflags
BufPtr
ExitRF
EndFrame,RFflags
;
;Yes, next byte
;
;
;
;
;Yes,End Frame signal
;No, go out
jmp
FrameErr
;
FrameErr1
; End Frame: Initialization and enable RF signal Research
EOF
bclr
bclr
lda
nsa
sta
lda
rola
rol
lda
cmp
bne
brclr
lda
ldx
jsr
lda
ldx
jsr
lda
DRM005
74
LED,PORTC
EndFrame,RFflags
BufferRF+7
BufferRF+7
BufferRF+7
BufferRF+7
RFCRC
BufferRF+7
FrameErr1
Cod,MFlags,NoRoll
#$00
#$02
GotoXY
BufferRF+2
BufferRF+1
PrintShort
BufferRF+3
;
;Yes,Reset End Frame
;
;
;
;
;
;
;Check CRC
;
;
;
;
;
;
;
;
;
;
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Source Code
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Source Code
Mother Board Firmware
jsr
lda
jsr
lda
jsr
lda
jsr
PrintHex
BufferRF+4
PrintHex
BufferRF+5
PrintHex
BufferRF+7
PrintHex
;
;
;
;
;
;
;
ldhx
lda
eor
sta
lda
eor
sta
lda
eor
sta
lda
eor
sta
lda
eor
sta
lda
and
beq
tax
#BufferRF
4,X
5,X
5,X
3,X
4,X
4,X
2,X
3,X
3,X
1,X
2,X
2,X
0,X
1,X
1,X
BufferRF+6
#$0F
NoRotate
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
lda
rola
rol
rol
rol
rol
rol
rol
dbnzx
BufferRF
BufferRF+5
BufferRF+4
BufferRF+3
BufferRF+2
BufferRF+1
BufferRF
NextRotate
;
;
;
;
;
;
;
;
;
brclr
Cod,MFlags,ShowFix
;
lda
ldx
jsr
lda
ldx
jsr
lda
jsr
lda
jsr
#$00
#$01
GotoXY
BufferRF+2
BufferRF+1
PrintShort
BufferRF+3
PrintHex
BufferRF+4
PrintHex
;
;
;
;
;
;
;
;
;
;
Freescale Semiconductor, Inc...
NoRoll
NextRotate
NoRotate
ShowRoll
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Source Code
For More Information On This Product,
Go to: www.freescale.com
DRM005
75
Freescale Semiconductor, Inc.
Source Code
clra
jsr
lda
jsr
jmp
PrintHex
BufferRF+6
PrintHex
InitRF
;
;
;
;
;
lda
ldx
jsr
lda
ldx
jsr
lda
jsr
lda
ldx
jsr
lda
bpl
lda
jsr
lda
jsr
lda
jsr
bra
#$06
#$00
GotoXY
BufferRF+2
BufferRF+1
PrintShort
BufferRF+3
PrintHex
#$06
#$01
GotoXY
BufferRF+4
KeyDx
#’D’
PrintChar1
#’x’
PrintChar1
#’ ’
PrintChar1
KeyNum
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
lda
jsr
lda
jsr
lda
jsr
#’S’
PrintChar1
#’x’
PrintChar1
#’ ’
PrintChar1
;
;
;
;
;
;
lda
and
tax
lda
cbeqx
cbeqx
cbeqx
BufferRF+4
#$0F
;
;
;
;
;
;
;
Freescale Semiconductor, Inc...
ShowFix
KeyDx
KeyNum
#$34
#$01,Key4
#$06,Key3
#$04,Key2
Key1
deca
;
deca
;
deca
;
Key2
Key3
DRM005
76
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Source Code
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Source Code
Mother Board Firmware
Key4
jsr
lda
ldx
jsr
lda
jsr
PrintChar1
#$06
#$02
GotoXY
BufferRF+5
PrintHex
;
;
;
;
;
;
InitRF
;
nop
FrameErr
Freescale Semiconductor, Inc...
jmp
;------------------------------------------------------------------------------;
; Menu handling procedures
;
;-------------------------------------------------------------------------------
;-----------------------------------------------;
; Main menu routines
;
;-----------------------------------------------MainMenu
ldhx
pshx
pshh
ldhx
clra
jsr
ais
bra
#Menu1
#$0200
Menu
#$02
MainMenu
;
;
;
;
;
;
;
;Endless loop on main menu
;-----------------------------------------------;
; Level 1 menu routines
;
;-----------------------------------------------RxMenu
jsr
beq
jsr
ldhx
jsr
jsr
rts
ChkRomeo
RomeoFound
Clr
#NoRomeoMsg
PrintStr1
WaitInput
;
;
;
;
;
;
;
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Source Code
For More Information On This Product,
Go to: www.freescale.com
DRM005
77
Freescale Semiconductor, Inc.
Source Code
RomeoFound
jsr
ldhx
pshx
pshh
ldhx
clra
jsr
ais
rts
InitRomeo
#Menu11
ldhx
pshx
pshh
ldhx
clra
jsr
ais
rts
#Menu12
#$0200
Menu
#$02
;
;
;
;
;
;
;
;
;
Freescale Semiconductor, Inc...
TxMenu
#$0000
Menu
#$02
;
;
;
;
;
;
;
;
;-----------------------------------------------;
; Level 1.1 menu routines
;
;-----------------------------------------------;Level 1.1 menu Do routines
DoReceive
ldhx
pshx
pshh
ldhx
lda
jsr
ais
jsr
jsr
jsr
#Menu11a
jsr
jsr
cbeqa
bset
rts
GetRF
PushOK
#$00,RFLoop
LED,PORTC
#$0101
#$01
Menu
#$02
WaitNotPush
InitRomeo
InitCode
;
;
;
;
;
;
;
;
;
;
RFLoop
DRM005
78
;
;
;
;
;
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Source Code
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Source Code
Mother Board Firmware
RomeoMenu
ldhx
pshx
pshh
ldhx
clra
jsr
ais
rts
#Menu112
lda
eor
sta
rts
#ModeMsk
MFlags
MFlags
;
;
;
;
lda
eor
sta
jmp
#CFMsk
CR1
CR1
SaveNVCR
;
;
;
;
clra
ldx
jsr
ldhx
brclr
ldhx
#$01
GotoXY
#FixedMsg
Cod,MFlags,PrintMode
#RollMsg
;
;
;
;
;
;
#$0200
Menu
#$02
;
;
;
;
;
;
;
;
Freescale Semiconductor, Inc...
RxMode
BandSel
Menu11aI2
PrintMode
jsr
rts
PrintStr1
;
;
Menu11I3
clra
ldx
jsr
ldhx
brclr
ldhx
#$02
GotoXY
#Band315Msg
CF,CR1,PrintBand
#Band434Msg
;
;
;
;
;
;
PrintBand
jsr
rts
PrintStr1
;
;
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Source Code
For More Information On This Product,
Go to: www.freescale.com
DRM005
79
Freescale Semiconductor, Inc.
Source Code
;-----------------------------------------------;
; Level 1.2 menu routines
;
;-----------------------------------------------;Level 1.1 menu Do routines
Freescale Semiconductor, Inc...
DoProgram
brset
jsr
ldhx
jsr
jsr
rts
TXFile,SFlags,TXOK
Clr
#NoFileMsg1
PrintStr1
WaitInput
;
;
;
;
;
;
brset
jsr
ldhx
jsr
jsr
rts
UserP,SFlags,TXOK1
Clr
#BadProgMsg
PrintStr1
WaitInput
;
;
;
;
;
;
jsr
rts
ProgTx
;
;
TXOK
TXOK1
Menu12I3
clra
ldx
jsr
bsr
brset
#$02
GotoXY
ChkFileName
TXFile,SFlags,PrintName
;
;
;
;
;
ldhx
#NoFileMsg
;
jsr
rts
PrintStr1
;
;
bclr
lda
cbeqa
ldhx
jsr
cmp
bhs
bset
TXFile,SFlags
FileName
#$FF,NoName
#FileName
StrLen
#$0C
NoName
TXFile,SFlags
;
;
;
;
;
;
;
;
PrintNoName
PrintName
ChkFileName
NoName
rts
DRM005
80
;
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Source Code
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Source Code
Mother Board Firmware
;-----------------------------------------------;
; Level 1.1.2 menu routines
;
;------------------------------------------------
Freescale Semiconductor, Inc...
EditCR1
lda
clr
mov
jsr
sta
bra
CR1
CurY
#$05,CurX
InputByte
CR1
SaveNVCR
;
;
;
;
;
;
lda
mov
mov
jsr
sta
bra
CR2
#$01,CurY
#$05,CurX
InputByte
CR2
SaveNVCR
;
;
;
;
;
;
lda
mov
mov
jsr
sta
CR3
#$02,CurY
#$05,CurX
InputByte
CR3
;
;
;
;
;
lda
sta
lda
sta
lda
sta
ldhx
sthx
jsr
ldhx
sthx
aix
sthx
jsr
jsr
rts
CR1
FlashBuffer
CR2
FlashBuffer+1
CR3
FlashBuffer+2
#NVRegs
SourcePtr
EraseFPage
#NVRegs
SourcePtr
#$03
DestPtr
ProgFRange
InitRomeo
;
;
;
;
;
;
;
;
;Erase parameter flash page
;
;
;
;
;Program parameter flash page
;
;
EditCR2
EditCR3
SaveNVCR
;Level 1.2 draw routines
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Source Code
For More Information On This Product,
Go to: www.freescale.com
DRM005
81
Freescale Semiconductor, Inc.
Source Code
Menu112I1
jsr
lda
clrx
jsr
lda
jsr
rts
ReadRomeo
#$05
;
;
;
;
;
;
;
jsr
lda
ldx
jsr
lda
jsr
rts
ReadRomeo
#$05
#$01
GotoXY
CR2
PrintHex
;
;
;
;
;
;
;
jsr
lda
ldx
jsr
lda
jsr
rts
ReadRomeo
#$05
#$02
GotoXY
CR3
PrintHex
;
;
;
;
;
;
;
NIL
equ
$0000
Menu1Msg
DC.B
DC.B
DC.B
DC.B
DC.B
DC.B
DC.B
DC.B
DC.B
DC.B
DC.B
DC.B
DC.B
DC.B
DC.B
DC.B
DC.B
DC.B
DC.B
DC.B
DC.B
DC.B
DC.B
DC.B
DC.B
" RX Menu
" TX Menu
" Power Off
"Coding type
" Fixed
"ESC to exit
" Receive
" Set MC3359x
" Program Tx
"File name:
" CR1=
" CR2=
" CR3=
" 315MHz
" 434/868MHz
" Fixed
" Rolling
"Rx board not
"found !
"No File
"No File in
"memory !
"Programming
"firmware not
"valid !
GotoXY
CR1
PrintHex
Freescale Semiconductor, Inc...
Menu112I2
Menu112I3
Menu11aMsg
Menu11Msg
Menu12Msg
Menu112Msg
Band315Msg
Band434Msg
FixedMsg
RollMsg
NoRomeoMsg
NoFileMsg
NoFileMsg1
BadProgMsg
DRM005
82
"
"
",$00
"
"
",$00
"
",$00
"
",$00
"
"
",$00
",$00
",$00
",$00
",$00
"
",$00
",$00
"
",$00
"
"
",$00
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Source Code
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Source Code
Mother Board Firmware
;------------------------------;Menu 1 (main Menu)
;-------------------------------
Freescale Semiconductor, Inc...
Menu1
DC.W
Menu1Msg
DC.W
NIL
DC.W
NIL
DC.W
NIL
DC.W
NIL
DC.W
RxMenu
DC.W
TxMenu
DC.W
PowerOff
DC.W
NIL
;------------------------------;Menu 1.1a (Coding Menu)
;-------------------------------
;Menu text
;Draw Item
;Draw Item
;Draw Item
;Draw Item
;Do Item 1
;Do Item 2
;Do Item 3
;Do Item 4
Menu11a
DC.W
Menu11aMsg
DC.W
NIL
DC.W
Menu11aI2
DC.W
NIL
DC.W
NIL
DC.W
NIL
DC.W
RxMode
DC.W
NIL
DC.W
NIL
;------------------------------;Menu 1.1 (RX Menu)
;-------------------------------
;Menu text
;Draw Item
;Draw Item
;Draw Item
;Draw Item
;Do Item 1
;Do Item 2
;Do Item 3
;Do Item 4
Menu11
DC.W
Menu11Msg
DC.W
NIL
DC.W
NIL
DC.W
Menu11I3
DC.W
NIL
DC.W
DoReceive
DC.W
RomeoMenu
DC.W
BandSel
DC.W
NIL
;------------------------------;Menu 1.1 (TX Menu)
;-------------------------------
;Menu text
;Draw Item
;Draw Item
;Draw Item
;Draw Item
;Do Item 1
;Do Item 2
;Do Item 3
;Do Item 4
Menu12
;Menu text
;Draw Item
;Draw Item
;Draw Item
;Draw Item
;Do Item 1
;Do Item 2
;Do Item 3
;Do Item 4
DC.W
DC.W
DC.W
DC.W
DC.W
DC.W
DC.W
DC.W
DC.W
Menu12Msg
NIL
NIL
Menu12I3
NIL
DoProgram
NIL
NIL
NIL
1
2
3
4
1
2
3
4
1
2
3
4
1
2
3
4
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Source Code
For More Information On This Product,
Go to: www.freescale.com
DRM005
83
Freescale Semiconductor, Inc.
Source Code
;------------------------------;Menu 1.1.2 (Romeo Menu)
;-------------------------------
Freescale Semiconductor, Inc...
Menu112
Frame1
Frame2
DC.W
DC.W
DC.W
DC.W
DC.W
DC.W
DC.W
DC.W
DC.W
Menu112Msg
Menu112I1
Menu112I2
Menu112I3
NIL
EditCR1
EditCR2
EditCR3
NIL
DC.B
DC.B
DC.B
DC.B
DC.B
DC.B
"Tx ID
"
"Key
"
"CRC
",$00
"--ID--KKRRRR"
"
"
"
",$00
;Menu text
;Draw Item
;Draw Item
;Draw Item
;Draw Item
;Do Item 1
;Do Item 2
;Do Item 3
;Do Item 4
1
2
3
4
ENDIF
UserCodeEnd
;******************************************************************************
;
; HC908RF2 Fast Programming Algorithm
;
;******************************************************************************
ProgCode:
SECTION
ProgSum
DC.W
DC.W
USERSUM2
ProgTxEnd
ProgTx
IFNDEF TestAgent
NoProgMsg
jsr
ldhx
jsr
jsr
rts
Clr
#NoProgMsg
PrintStr1
WaitInput
DC.B
DC.B
DC.B
"Programming "
"fimware not "
"loaded !
",$00
;
;
;
;
;
ENDIF
ProgTxEnd
DRM005
84
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Source Code
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Source Code
Mother Board Firmware
;******************************************************************************
;
; Remote user commands jump table
;
;******************************************************************************
UserCmd:
SECTION
Freescale Semiconductor, Inc...
UserCmdSum
DC.W
DC.W
DC.B
UserCmdNum
UserCmdTab
IFNDEF TestAgent
DC.B
DC.W
DC.B
DC.W
DC.B
DC.W
ENDIF
UserCmdTabEnd
TXCode:
SECTION
FileName
DC.B
USERSUM1
UserCmdTabEnd
$03
"IRR"
CmdIRR
"RRR"
CmdRRR
"WRR"
CmdWRR
;
;
;
;
;
;
$FF
;
;------------------------------------------------------------------------------;
; Software del loader Agent rev A0.0
;
;-------------------------------------------------------------------------------
XDEF
XDEF
XDEF
Loader:
LAInit
LAIRQProc
LAGetRS232
SECTION
LAInit
mov
mov
mov
mov
mov
#%00000001,CONFIG1
#PortAInit,PORTA
#DDRAInit,DDRA
#PortBInit,PORTB
#DDRBInit,DDRB
;
;
;
;
;
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Source Code
For More Information On This Product,
Go to: www.freescale.com
DRM005
85
Freescale Semiconductor, Inc.
Source Code
mov
mov
mov
mov
mov
mov
#PortCInit,PORTC
#DDRCInit,DDRC
#%00100001,PTCPUE
#DDRDInit,DDRD
#PortDInit,PORTD
#%00110000,PTDPUE
;
;
;
;
;
;
ldhx
#0040
;
clr
aix
cphx
bne
,X
#$01
#$0240
ClrRAM
;
;
;
;
mov
mov
mov
mov
mov
ldhx
sthx
#%01000000,SCC1
#%00101100,SCC2
#%00000010,SCBR
#%00000110,T1SCR
#%000000001,SPSCR
#$099A
T2MODH
;
;
;
;
;Set SPI Baud rate
;Init Timer2 modulo register
;
ldhx
txs
#$0240
;Init Stack pointer
;
BufferCnt
RS232St
#$0400
RS232Tmo
;
;
;
;
EncCnt
#$01,EncStep
Min
CurItem
;
;
;
;
jsr
jsr
LASetContrast
LAInit7123
;
;
clr
jsr
jsr
ldhx
VHH
LASetVHH
LAWait200ms
#DevName
;
;
;
;Startup screen
;Clear RAM
Freescale Semiconductor, Inc...
ClrRAM
LAWarmStart
;init RS232 variables
clr
clr
ldhx
sthx
;init Input device
clr
mov
clr
clr
;init Output device
;init VHH
DRM005
86
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Source Code
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Source Code
Mother Board Firmware
jsr
jsr
jsr
ldhx
jsr
jsr
jsr
ldhx
jsr
LAPrintStr1
LAWait1s
LAClr
#AgentMsg
LAPrintStr1
LAWait1s
LAClr
#SumMsg
LAPrintStr1
;
;
;
;BLIC Agent screen
;
;
;
;BLIC Agent screen
;
mov
lda
sta
lda
sta
ldhx
jsr
cmp
bne
cpx
bne
lda
bset
bra
#$02,CurY
UserCmdSum+2
TmpPtr
UserCmdSum+3
TmpPtr+1
#UserCmdTab
LACalcUserSum
UserCmdSum+1
LABadUserCmd
UserCmdSum
LABadUserCmd
#’ ’
UserC,SFlags
LATestPG
;
;
;
;
;
;
;
;
;
;
;
;
;
;
bclr
lda
UserC,SFlags
#’x’
;
;
Freescale Semiconductor, Inc...
;Test User Command Table
LABadUserCmd
;Test Programming algorithm code
LATestPG
jsr
mov
lda
sta
lda
sta
ldhx
jsr
cmp
bne
cpx
bne
lda
bset
bra
LAPrintChar1
#$01,CurY
ProgSum+2
TmpPtr
ProgSum+3
TmpPtr+1
#ProgTx
LACalcUserSum
ProgSum+1
LABadProg
ProgSum
LABadProg
#’ ’
UserP,SFlags
LATestUC
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Source Code
For More Information On This Product,
Go to: www.freescale.com
DRM005
87
Freescale Semiconductor, Inc.
Source Code
LABadProg
bclr
lda
UserP,SFlags
#’x’
;
;
jsr
clr
lda
sta
lda
sta
ldhx
jsr
cmp
bne
cpx
bne
jsr
jmp
LAPrintChar1
CurY
UserCodeSum+2
TmpPtr
UserCodeSum+3
TmpPtr+1
#UserProg
LACalcUserSum
UserCodeSum+1
LABadUserCode
UserCodeSum
LABadUserCode
LAWait1s
UserProg
;
;
;
;
;
;
;
;
;
;
;
;
;
;
lda
jsr
jsr
#’x’
LAPrintChar1
LAWait1s
;
;
;
jsr
LAEraseUM
;
jsr
ldhx
jsr
jsr
cli
bra
LAClr
#FirmUpdMsg
LAPrintStr1
LAWait1s
;
;
;
;
;
;Wait RS232 commands
;Test User Code
Freescale Semiconductor, Inc...
LATestUC
LABadUserCode
LAUpdateUM1
LAUpdateUM2
$
;Calculate user checksum and print it
;
;On entry
; H,X=Start address
; TempPtr=EndAddress
;On exit
; X,A=Checksum
LACalcUserSum
clra
psha
psha
DRM005
88
;
;
;
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Source Code
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Source Code
Mother Board Firmware
Freescale Semiconductor, Inc...
LANextCodeSum
lda
add
sta
clra
adc
sta
aix
cphx
bne
lda
ldx
jsr
ldx
lda
jsr
lda
jsr
pulx
pula
rts
,X
2,SP
2,SP
lda
psha
pulh
ldx
jmp
$FFFE
$FFFF
,X
;
;
;
;
;
brclr
bclr
bra
KEY,PORTC,*
HOLD,PORTC
$
;Wait until button released
;Power Off
;
1,SP
1,SP
#$01
TmpPtr
LANextCodeSum
#$06
CurY
LAGotoXY
1,SP
2,SP
LAPrintShort
#’ ’
LAPrintChar1
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;Software reset
;
LASoftReset
;Power Off
;
LAPowerOff
;Delay of 1ms
;This delay is indipendent from PPL because Timer2 modulo
;is recalculated each time PLL is changed
;
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Source Code
For More Information On This Product,
Go to: www.freescale.com
DRM005
89
Freescale Semiconductor, Inc.
Source Code
LADly1ms
mov
bclr
bclr
brclr
bset
rts
#%00110000,T2SCR;Stop and reset Timer2
7,T2SCR
;Clear TOF
5,T2SCR
;Start Timer2
7,T2SCR,*
;Wait overflow
5,T2SCR
;Stop Timer2
;
jsr
aix
cphx
bne
rts
LADly1ms
#$FF
#$0000
LADlyNms
Freescale Semiconductor, Inc...
;Delay of N ms
;HX=N
;
LADlyNms
;Delay of 1ms
;
;
;
;
;Delay of 20ms
;
LAWait20ms
pshx
pshh
ldhx
bsr
pulh
pulx
rts
#$14
LADlyNms
;
;
;
;
;
;
;
;Delay of 200ms
;
LAWait200ms
pshx
pshh
ldhx
bsr
pulh
pulx
rts
#$C8
LADlyNms
;
;
;
;
;
;
;
;Delay of 1s
;
LAWait1s
pshx
pshh
ldhx
bsr
pulh
pulx
rts
#$3E8
LADlyNms
;
;
;
;
;
;
;
;Delay of 5us
;
DRM005
90
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Source Code
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Source Code
Mother Board Firmware
LAWait5uS
Freescale Semiconductor, Inc...
pshx
ldx
dbnzx
pulx
rts
#Dly5us
$
;15+4*Dly5us including JSR
;[2] Save X
;[2]
;[4*Dly5us]
;[2] Restore X
;[4]
;******************************************************************************
;
; MAX533 DAC Device Driver
;
; MAX533 parameters
;
; X=DAC Control Byte 0000AACC
;
AA=DAC Number,CC=01=Load Inp.Register DAC AA
;
AA=DAC Number,CC=11=Load Inp.Register DAC AA and Load all DACs
;
AA=01,CC=00 Load all DACs
;
; A=DAC value
;
; Out0=Contrast control
; Out1=VMCU control voltage
; Out2=VHH control voltage
; Out3=Not used
;
;
;******************************************************************************
; MAX533 Control Register Values
; MAX533
DACLCD
DACVHH
equ
equ
%00000111
%00000011
lda
ldx
bra
Contrast
#DACLCD
LAWriteDAC
;
;Get Control Register Value
;
lda
ldx
VHH
#DACVHH
;
;
bclr
mov
bset
stx
brclr
ldx
NDAC,PORTC
#%00100000,SPCR
SPE,SPCR
SPDR
SPRF,SPSCR,*
SPDR
;CS Low for programming
;Init SPI as Master
;Enable SPI
;Send to SPI
;Wait end of frame
;
LASetContrast
LASetVHH
LAWriteDAC
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Source Code
For More Information On This Product,
Go to: www.freescale.com
DRM005
91
Freescale Semiconductor, Inc.
Source Code
Freescale Semiconductor, Inc...
brset
sta
brclr
ldx
brset
bset
bclr
rts
SPRF,SPSCR,*
SPDR
SPRF,SPSCR,*
SPDR
SPRF,SPSCR,*
NDAC,PORTC
SPE,SPCR
;Wait SPRF Low
;Send second byte
;Wait end of frame
;
;Wait SPRF Low
;Rise CS to execute instruction
;Disable SPI
;
;******************************************************************************
;
; EA7123 LCD Device Driver
;
; Times to be rispected:
; 1) t(BuF)>4.7us Bus Free Time (SDA=H SCL=H)
; 2) t(HdSta)> 4us Start Hold Time (SDA=L minimum time with SCL=H)
; 3) t(Low)>4.7us SCL Low Time
; 4) t(High)>4us SCL High Time
; 5) t(SuSto)> 4us Stop Setup Time (SCL=H minimum time before SDA rise)
;
;******************************************************************************
EEAddr
equ
%10100000
;24C00 I2C Bus Address
EA7123Addr
I2CRWMsk
EA7123WReg
EA7123RBusy
EA7123WData
EA7123RData
equ
equ
equ
equ
equ
equ
%01110100
%00000001
%00000000
%00100000
%01000000
%01100000
;EA7123 I2C Bus Address
;I2C Bus R/W mask
;Write EA7123 Redgister
;Read EA7123 Busy Flag
;Write EA7123 Data
;Read EA7123 Data
EA7123Clr
EA7123Home
EA7123Mode
EA7123Off
EA7123CursOff
EA7123CursOn
EA7123BlinkOn
EA7123CursMove
EA7123Init
equ
equ
equ
equ
equ
equ
equ
equ
equ
%00000001
%00000010
%00000100
%00001000
%00001100
%00001110
%00001111
%00010100
%00101110
EA7123CAddr
EA7123DAddr
equ
equ
%01000000
%10000000
;Read EA7123 Clear Display
;Read EA7123 Go Home
;Read EA7123 Mode Set
;Read EA7123 Display Off
;Read EA7123 Display On Cusror Off
;Read EA7123 Display On Cusror On Blink Off
;Read EA7123 Display On Cusror On Blink On
;Read EA7123 Cursor Move Right
;Read EA7123 Init Display Functions
12Charx4Row,Vlcd=V0-0.8
;Read EA7123 CGRAM Addr
;Read EA7123 DDARM Addr
bclr
SDA,PORTD
;SDA H->L
ldx
#$08
;
LASendCtrlByte
LASendByte
DRM005
92
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Source Code
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Source Code
Mother Board Firmware
LANextBit
jsr
LAWait5uS
;Meet Start Hold Time and
bclr
bset
lsla
bcc
bset
bra
SCL,PORTD
SDA,DDRD
LASDALow
SDA,PORTD
LARiseSCL
;Change SDA with SCL Low
;SDA in Output
;Copy Bit 7 in Carry
;Copy Carry in SDA
;
;
bclr
SDA,PORTD
;
jsr
bset
dbnzx
jsr
bclr
bclr
brn
jsr
bset
brclr
lda
LAWait5uS
SCL,PORTD
LANextBit
LAWait5uS
SCL,PORTD
SDA,DDRD
$
LAWait5uS
SCL,PORTD
SDA,PORTD,LAExitByte
#$01
;Meet SCL Low Time
;Rise SCL
;
;Meet SCL High Time
;Controlla Ack
;SDA in Input
;
;Meet SCL Low Time
;
;Se Ack A=0
;Se Nack A=1
SCL High
Time
LASDALow
Freescale Semiconductor, Inc...
LARiseSCL
LAExitByte
rts
;
LARead7123
lda
jsr
cbeqa
#(EA7123Addr+I2CRWMsk)
LASendCtrlByte
#$01,LAStopBit
;Read EA7123
;
;
ldx
#$08
;X as bit counter
jsr
bclr
bclr
jsr
bset
clc
brclr
sec
LAWait5uS
SCL,PORTD
SDA,DDRD
LAWait5uS
SCL,PORTD
;Meet SCL High Time
;
;SDA in Input
;Meet SCL Low Time
;
;
;
;
LANextRead
LANextBitIn
SDA,PORTD,LASDALowIn
LASDALowIn
rola
dbnzx
jsr
bclr
bset
bclr
jsr
bset
rts
LANextBitIn
LAWait5uS
SCL,PORTD
SDA,DDRD
SDA,PORTD
LAWait5uS
SCL,PORTD
;
;
;Meet SCL High Time
;Ack out
;SDA in Output
;
;Meet SCL Low Time
;
;
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Source Code
For More Information On This Product,
Go to: www.freescale.com
DRM005
93
Freescale Semiconductor, Inc.
Source Code
LALastRead
ldx
#$08
;X as bit counter
jsr
bclr
bclr
jsr
bset
clc
brclr
sec
LAWait5uS
SCL,PORTD
SDA,DDRD
LAWait5uS
SCL,PORTD
;Meet SCL High Time
;
;SDA in Input
;Meet SCL Low Time
;
;
;
;
LANextBitIn1
SDA,PORTD,LASDALowIn1
Freescale Semiconductor, Inc...
LASDALowIn1
rola
dbnzx
jsr
bclr
bset
bset
jsr
bset
rts
LANextBitIn1
LAWait5uS
SCL,PORTD
SDA,DDRD
SDA,PORTD
LAWait5uS
SCL,PORTD
;
;
;Meet SCL High Time
;Nack out
;SDA in Output
;
;Meet SCL Low Time
;
;
LAPutChar7123
psha
lda
jsr
cbeqa
lda
bra
#EA7123Addr
LASendCtrlByte
#$01,LAError7123
#EA7123WData
LASendReg
;Save Register value
;Send StartBit and Address
;
;If not Ack exit with error
;Send WriteData Control Register
;
psha
lda
jsr
cbeqa
lda
#EA7123Addr
LASendCtrlByte
#$01,LAError7123
#EA7123WReg
;Save Register value
;Send StartBit and Address
;
;If not Ack exit with error
;Send WriteRegister Control Register
LAWriteReg7123
LASendReg
jsr
cbeqa
pula
jsr
pshx
LASendByte
#$01,LAError7123
LASendByte
;
;If not Ack exit with error
;Recover Register value
;Put it on the bus
;Dummy push
LAError7123
pulx
;Pull out stacked value
LAStopBit
bclr
bclr
bset
bset
jsr
bset
jsr
rts
DRM005
94
SCL,PORTD
SDA,PORTD
SDA,DDRD
SCL,PORTD
LAWait5uS
SDA,PORTD
LAWait5uS
;Change SDA with SCL Low
;
;SDA in Output
;SDA in Output
;Meet Stop Hold Time
;
;Meet Bus Free Time
;
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Source Code
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Source Code
Mother Board Firmware
LAWaitBusy7123
lda
jsr
cbeqa
lda
jsr
cbeqa
bsr
jsr
#EA7123Addr
LASendCtrlByte
#$01,LAStopBit
#EA7123RBusy
LASendByte
#$01,LAStopBit
LAStopBit
LARead7123
;Send StartBit and Address
;
;If not Ack exit with error
;Send ReadBusyFlag Control Register
;
;If not Ack exit with error
;Send StopBit
;Read BusyFlag,first read is not
jsr
bmi
LANextRead
LABusy7123
;Read BusyFlag
;Busy Flag is in Bit7 (Bit7=1 LCD
bsr
bra
LALastRead
LAStopBit
;Last Read without aknowledge
;Send StopBit
clr
clr
lda
bra
CurX
CurY
#EA7123Home
LAWriteReg7123
;
;
;
;
lda
bsr
cbeqa
lda
bsr
#EA7123Init
LAWriteReg7123
#$01,LAEndInit
#EA7123CursMove
LAWriteReg7123
;
;
;If not Ack exit with error
;
;
clr
clr
lda
bsr
cbeqa
bsr
lda
bra
CurX
CurY
#EA7123Clr
LAWriteReg7123
#$01,LAEndInit
LAWaitBusy7123
#EA7123CursOff
LAWriteReg7123
;
;
;
;
;
;
;
;
Freescale Semiconductor, Inc...
valid
LABusy7123
busy)
LAHome
LAInit7123
LAClr
LAEndInit
rts
;
LACursOn
lda
jmp
#EA7123CursOn
LAWriteReg7123
;
;
lda
jmp
#EA7123CursOff
LAWriteReg7123
;
;
LACursOff
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Source Code
For More Information On This Product,
Go to: www.freescale.com
DRM005
95
Freescale Semiconductor, Inc.
Source Code
LABlinkOn
lda
jmp
#EA7123BlinkOn
LAWriteReg7123
;
;
sta
stx
psha
txa
and
lsla
nsa
tax
pula
pshx
ldhx
div
pshh
pula
add
pulx
add
jmp
CurX
CurY
;Save X coordinate
;
;
;
;Y coordinate modulo 4
;
;
;
;Restore X coordinate
;Save Y coordinate
;
;
;H = X coordinate modulo 0x0E
;Move in A
;Add Y coordinate
;Take it out of the stack
;Add register mask
;Set Cursor Address
Freescale Semiconductor, Inc...
LAGotoXY
#%00000011
#$000E
1,SP
#EA7123DAddr
LAWriteReg7123
LAPrintStr
pshx
pulh
tax
;Load pointer
;
;
LAPrintStr1
lda
beq
ora
aix
pshh
pshx
bsr
pulx
pulh
bra
,X
LAEndString
#$80
#1
LAPrintChar
LAPrintStr1
;
;
;
;
;Save pointer
;
;
;Restore pointer
;
;
LAEndString
rts
;
LAPrintChar1
ora
#$80
;
jsr
inc
lda
clrh
ldx
div
LAPutChar7123
CurX
CurX
;Print char
;Increment cursor position
;Check if new line
;
;
;
LAPrintChar
DRM005
96
#$0C
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Source Code
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Freescale Semiconductor, Inc...
Source Code
Mother Board Firmware
pshh
pulx
stx
cbeqa
add
clrh
ldx
div
pshh
pulx
stx
lda
bsr
CurX
#$00,LAEndPrintChar
CurY
#$3
CurY
CurX
LAGotoXY
;
;
;
;
;New line
;
;
;
;
;
;
;
;
LAEndPrintChar
rts
;
LAPrintDec
ldx
clrh
div
pshh
clrh
div
pshh
tsta
bne
lda
jsr
pula
tsta
bne
lda
jsr
bra
#$0A
add
jsr
pula
#$30
LAPrintChar1
;
;
;
add
jsr
#$30
LAPrintChar1
;
;
pula
add
jsr
rts
#$30
LAPrintChar1
;
;
;
;
LADigit3
#’ ’
LAPrintChar1
LADigit2
#’ ’
LAPrintChar1
LADigit1
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
LADigit3
LADigit2
LADigit1
LAPrintHex
psha
pshx
bra
LAPrintLowByte
;
;
;
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Source Code
For More Information On This Product,
Go to: www.freescale.com
DRM005
97
Freescale Semiconductor, Inc.
Source Code
LAPrintShort
psha
pshx
txa
nsa
and
jsr
lda
and
jsr
#$0F
LAPrintNibble
1,SP
#$0F
LAPrintNibble
;Save Low byte
;Save High byte
;
;
;
;
;
;
;
Freescale Semiconductor, Inc...
LAPrintLowByte
lda
nsa
and
jsr
lda
and
jsr
pulx
pula
rts
2,SP
add
cmp
bls
add
#$B0
#$B9
LANoAlfa
#$07
;
;Convert to ascii
;
;
jsr
rts
LAPrintChar
;
;
lda
jsr
cbeqa
lda
jsr
cbeqa
jsr
jsr
rts
#EA7123Addr
LASendCtrlByte
#$01,LAStopBit1
#EA7123RData
LASendByte
#$01,LAStopBit1
LAStopBit
LARead7123
;Send StartBit and Address
;
;If not Ack exit with error
;Send ReadBusyFlag Control Register
;
;If not Ack exit with error
;Send StopBit
;Read Data
;
jmp
LAStopBit
;
Min
;Space for local var
;
;
;Save Min
;
#$0F
LAPrintNibble
2,SP
#$0F
LAPrintNibble
;
;
;
;
;
;
;
;
;
;
LAPrintNibble
LANoAlfa
LAGetChar7123
LAStopBit1
LAInputHex
psha
psha
lda
psha
lda
DRM005
98
Max
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Source Code
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Freescale Semiconductor, Inc...
Source Code
Mother Board Firmware
psha
lda
psha
lda
psha
mov
mov
mov
jsr
sta
sta
sta
jsr
jsr
jsr
jsr
#$30,Min
#$46,Max
#$FF,EncStep
LAGetChar7123
6,SP
5,SP
EncCnt
LASamePoint
LAWaitNotKeyOK
LAWaitNotPush
LASamePoint
;Save Max
;
;Save EncCnt
;
;Save EncStep
;
;
;
;
;Save Char
;Set Last Char
;
;
;
;
;
bset
lda
cmp
blo
cmp
bhi
lda
cmp
bhi
lda
sta
bra
lda
sta
1,INTSCR
EncCnt
#$3A
LAInpHexOK
#$40
LAInpHexOK
5,SP
EncCnt
LAChar39
#$41
EncCnt
LAInpHexOK
#$39
EncCnt
;
;
;
;
;
;
;
;
;
;
;
;
;
;
lda
cbeq
lda
bclr
sta
jsr
jsr
5,SP
EncCnt,LANoNewInp
EncCnt
1,INTSCR
5,SP
LAPutChar7123
LASamePoint
;
;
;
;
;
;
;
bclr
jsr
cbeqa
jsr
cbeqa
jsr
sta
jsr
1,INTSCR
LAPushOK
#$01,LAEndInpHex
LAKeyOK
#$00,LAInputHexLoop
LAGetChar7123
6,SP
LASamePoint
;
;
;
;
;
;
;
;
EncCnt
EncStep
LAInputHexLoop
LAChar39
LAInpHexOK
LANoNewInp
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Source Code
For More Information On This Product,
Go to: www.freescale.com
DRM005
99
Freescale Semiconductor, Inc.
Source Code
Freescale Semiconductor, Inc...
LAEndInpHex
pula
sta
pula
sta
pula
sta
pula
sta
pula
lda
jsr
jsr
pula
sub
cmp
blo
sub
EncStep
EncCnt
Max
Min
1,SP
LAPutChar7123
LASamePoint
#$30
#$0A
LAExitInpHex
#$07
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
LAExitInpHex
rts
;
LASamePoint
lda
ldx
jsr
rts
CurX
CurY
LAGotoXY
;
;
;
;
;******************************************************************************
;
; Menu manager
;
;******************************************************************************
Arrow
equ
$2E
;Menu selection char
;Redraw current menu
;
;On entry
; CurMenuPtr Ponter to menu template
; A=Current item
;On exit
; No parameter
LAMenuRedraw
psha
lda
psha
jsr
ldhx
lda
DRM005
100
#$04
LAClr
CurMenuPtr
,X
;Save CurItem
;Init counter
;
;Clear screen
;Get text pointer into HX
;
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Source Code
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Source Code
Mother Board Firmware
psha
lda
psha
pulx
pulh
jsr
ldhx
aix
1,X
LAPrintStr1
CurMenuPtr
#$02
;
;
;
;
;
;Print menu mask
;
;
Freescale Semiconductor, Inc...
LAMenuDrawLoop
pshx
pshh
lda
,X
bne
lda
beq
LADrawItem
1,X
LANextItemDraw
lda
psha
ldx
pulh
lda
jsr
,X
;
;
;Use DrawItem routine if pointer not
null
;
;
;
LADrawItem
1,X
4,SP
,X
;
;
;
;
;Get CurItem
;
LANextItemDraw
pulh
pulx
aix
dbnz
clra
ldx
jsr
lda
jsr
pula
pula
rts
#$02
1,SP,LAMenuDrawLoop
EncCnt
LAGotoXY
#Arrow
LAPrintChar
;
;
;
;
;Print arrow at current item
;
;
;
;
;Free stack
;
;
;Menu Rotine handles menu N
;
;On entry
; CurMenuPtr Ponter to menu template
; A=Current item
; H=Item Max
; X=Item min
;On exit
; No parameter
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Source Code
For More Information On This Product,
Go to: www.freescale.com
DRM005
101
Freescale Semiconductor, Inc.
Source Code
LAMenu
psha
pshx
pshh
sei
jsr
LAPushEncoder
;Save
;Save
;Save
;
;Push
CurItem
Min
Max
Encoder status
Freescale Semiconductor, Inc...
LAInitMenu
sei
lda
sta
lda
sta
mov
lda
sta
lda
sta
lda
sta
bsr
cli
jsr
jsr
LAWaitNotKeyOK
LAWaitNotPush
;
;
;
;
;
;
;
;
;
;
;
;
;Draw menu (A=CurItem)
;
;
;
jsr
cbeqa
jsr
cbeqa
jsr
ldhx
cphx
bne
clr
clr
ldhx
LAKeyOK
#$01,LASelected
LAPushOK
#$01,LAEscaped
LADly1ms
RS232Tmo
#$0000
LANoTmo
RS232St
BufferCnt
#$0401
;
;If select do item action
;
;Else exit menu
;
;
;
;
;
;
;
aix
sthx
lda
cbeq
tax
clra
jsr
lda
jsr
lda
sta
clra
ldx
jsr
lda
jsr
bra
#$FF
RS232Tmo
7,SP
EncCnt,LASelectLoop
;
;
;
;
;If arrow position changes
;
;
;
;Clear the old one
;
;
;
;
;
;
;And draw the new one
;
6,SP
Min
5,SP
Max
#$01,EncStep
$0A,SP
CurMenuPtr
$0B,SP
CurMenuPtr+1
7,SP
EncCnt
LAMenuRedraw
LASelectLoop
LANoTmo
DRM005
102
LAGotoXY
#’ ’
LAPrintChar1
EncCnt
7,SP
7,SP
LAGotoXY
#Arrow
LAPrintChar
LASelectLoop
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Source Code
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Source Code
Mother Board Firmware
Freescale Semiconductor, Inc...
LASelected
lda
asla
add
add
tax
clra
adc
psha
pulh
lda
bne
lda
beq
7,SP
lda
psha
ldx
pulh
jsr
,X
,X
;
;
;
;
;
jmp
LAInitMenu
;
jsr
pula
ais
rts
LAPullEncoder
;Resore old Encoder status
;
;
;
#$0A
CurMenuPtr+1
CurMenuPtr
,X
LADoItem
1,X
LADoNotItem
;Get Item DoProcPtr
;
;
;
;
;
;
;
;
;
;
;
;
LADoItem
1,X
LADoNotItem
LAEscaped
#$02
;******************************************************************************
;
; Input Device Driver
;
;******************************************************************************
;Input 2 Digit hex value
;
;On entry
;A=Start value
;On exit
;A=Selected value
LAInputByte
psha
lda
ldx
jsr
lda
jsr
sei
CurX
CurY
LAGotoXY
1,SP
LAPrintHex
;
;
;
;
;
;
;
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Source Code
For More Information On This Product,
Go to: www.freescale.com
DRM005
103
Freescale Semiconductor, Inc.
Source Code
jsr
clr
mov
lda
sta
psha
lda
sta
cli
jsr
jsr
LAPushEncoder
Min
#$FF,Max
5,SP
EncCnt
jsr
cbeqa
lda
cbeq
sta
ldx
lda
deca
deca
jsr
lda
jsr
bra
LAKeyOK
#$01,LASelHex
EncCnt
1,SP,LASameHex
1,SP
CurY
CurX
#$01
EncStep
LAWaitNotKeyOK
LABlinkOn
;Save Encoder status
;
;
;
;
;
;
;
;
;
;
Freescale Semiconductor, Inc...
LASameHex
LAGotoXY
1,SP
LAPrintHex
LASameHex
;
;
;
;
;
;
;
;
;
;
;
;
;
LASelHex
sei
lda
sta
pula
jsr
jsr
jsr
pula
rts
EncCnt
6,SP
LAPullEncoder
LACursOff
LAWaitNotKeyOK
;
;
;
;
;
;
;
;
;
;Wait Input wait for Select or Escape
;
;On exit
;Carry=1 Select, Carry=0 Escape
;
LAWaitInput
jsr
jsr
LAWaitNotKeyOK
LAWaitNotPush
;
;
jsr
sec
cbeqa
jsr
cbeqa
clc
LAKeyOK
;
;
;
;
;
;
WaitInput1
DRM005
104
#$01,WaitInputEnd
LAPushOK
#$00,WaitInput1
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Source Code
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Source Code
Mother Board Firmware
WaitInputEnd
rts
;
LAKeyOK
clra
brset
lda
dbnza
brset
inca
KEY,PORTC,ExitOK
#Dly100us
$
KEY,PORTC,ExitOK
;
;If Key not pressed return FALSE
;
;Else wait 100us
;If noise return FALSE
;Else return TRUE
Freescale Semiconductor, Inc...
ExitOK
rts
;
clrx
;
LAWaitKeyOK
KeyDown
bsr
cbeqa
dbnzx
rts
LAKeyOK
#$00,LAWaitKeyOK
KeyDown
;
;
;
;
LAWaitNotKeyOK
clrx
;
KeyDown1
bsr
cbeqa
dbnzx
rts
LAKeyOK
#$01,LAWaitNotKeyOK
KeyDown1
;
;
;
;
LAWaitNotPush
clrx
;
PushDown
bsr
cbeqa
dbnzx
rts
LAPushOK
#$01,LAWaitNotPush
PushDown
;
;
;
;
LAWaitPush
clrx
;
PushDown1
bsr
cbeqa
dbnzx
rts
LAPushOK
#$00,LAWaitPush
PushDown1
;
;
;
;
LAPushOK
clra
brset
lda
dbnza
brset
inca
PUSHBUT,PORTD,ExitPush
#Dly100us
$
PUSHBUT,PORTD,ExitPush
;
;If Key not pressed return FALSE
;
;Else wait 100us
;If noise return FALSE
;Else return TRUE
ExitPush
rts
;
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Source Code
For More Information On This Product,
Go to: www.freescale.com
DRM005
105
Freescale Semiconductor, Inc.
Source Code
;Save current Encoder status into the stack
;On Entry
; No parameter
;On Exit
; No parameter
Freescale Semiconductor, Inc...
LAPushEncoder
pulh
pulx
lda
psha
lda
psha
lda
psha
lda
psha
jmp
Min
Max
EncCnt
EncStep
,X
;
;
;Save Encoder Status
;
;
;
;
;
;
;
;
;Restore Encoder status from the stack
;On Entry
; No parameter
;On Exit
; No parameter
;Stack status
;
SP-1,SP-2=Return address
;
SP-3=EncStep
;
SP-4=EncCnt
;
SP-5=Max
;
SP-6=Min
LAPullEncoder
pulh
pulx
sei
pula
sta
pula
sta
pula
sta
pula
sta
cli
jmp
DRM005
106
EncStep
EncCnt
Max
Min
,X
;
;
;Disable interrupt during
;Encoder status restore
;
;
;
;
;
;
;
;Enable interrupt
;
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Source Code
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Source Code
Mother Board Firmware
; IRQ Handling procedures
;
;
LAIRQProc
psha
pshx
ldx
#Dly100us
;Save A
;Save X
;Wait 100uS for anti-debouncing
dbnzx
bih
EncDly
EndIRQ
;
;If IRQ1=1 the interrupt isn’t
lda
tax
brclr
sub
sta
lda
bpl
EncCnt
ENCB,PORTD,EncUp
EncStep
EncCnt
EncStep
ChkEncMin
;EncCnt value loaded in Accumulator
;
;If EncB=1 then increase
;Otherwise decrase
;
;
;
cpx
bhi
lda
cmp
bls
EncCnt
SetToMax
EncCnt
Max
EndIRQ
;
;
;
;If less than Max is OK
;
lda
sta
bra
Max
EncCnt
EndIRQ
;
;
;
lda
add
sta
lda
bpl
EncStep
EncCnt
EncCnt
EncStep
ChkEncMax
;
;Increase EncCnt
;
;
;
cpx
blo
lda
cmp
bhs
EncCnt
SetToMin
EncCnt
Min
EndIRQ
;
;
;
;
;If bigger than Min is OK
lda
sta
Min
EncCnt
;
;
bset
pulx
pula
rti
2,INTSCR
;Delete wrong IRQ
;Reload X
;Reload A
;
EncDly
Freescale Semiconductor, Inc...
correct
ChkEncMax
SetToMax
EncUp
ChkEncMin
SetToMin
EndIRQ
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Source Code
For More Information On This Product,
Go to: www.freescale.com
DRM005
107
Freescale Semiconductor, Inc.
Source Code
;******************************************************************************
;
; RS232 Device Driver
;
;******************************************************************************
Freescale Semiconductor, Inc...
LAGetRS232
pshh
ldhx
sthx
clrh
tst
lda
brclr
bra
;Save H
;
;
;
SCS1
;Read Received byte and clear flag
SCDR
;
EscRec,RS232St,LAChkEsc ;Check if $1B already received
LAEscOk
;
#$0400
RS232Tmo
LAChkEsc
cmp
bne
bset
clr
bra
#$1B
LA232NoCode
EscRec,RS232St
BufferCnt
LA232NoCode
;If char is Esc=$1B init buffer
;If not skip
;Set flag
;
;
ldx
sta
cbeqx
cpx
beq
bra
BufferCnt
RxBuffer,X
#$00,LAInitPack
RxBuffer
LAChkPack
LANext232
;
;
;If first byte clear CRC
;
;If last byte validate Packet
;Else store into Rx buffer
clr
cmp
bhs
cmp
blo
CRC232
#LOW(BufferSize)
LABadPack
#$04
LABadPack
;
;If packet too big exit with error
;
;If packet too small exit with error
;
add
sta
inc
bra
CRC232
CRC232
BufferCnt
LA232NoCode
;
;
;
;
coma
cbeq
CRC232,LADecode
;
;If CRC ok decode command
lda
clr
clr
jsr
#’N’
RS232St
BufferCnt
LAPutRS232
;Exit with bad packet message
;
;
;
LAEscOk
LAInitPack
LANext232
LAChkPack
LABadPack
DRM005
108
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Source Code
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Source Code
Mother Board Firmware
LA232NoCode
pulh
rti
;
;
;Decode Command
Freescale Semiconductor, Inc...
LADecode
bclr
ldhx
lda
bsr
cphx
beq
jsr
bra
EscRec,RS232St
#CmdTab
CmdNum
LASrcCmd
#$0000
LASrcUserCmd
,X
LA232NoCode
;
;Search command in Bios table
;
;
;If not found
;Search User command
;Else execute it
;
brclr
ldhx
lda
bsr
cphx
beq
jsr
bra
UserC,SFlags,LABadPack
#UserCmdTab
UserCmdNum
LASrcCmd
#$0000
LABadPack
,X
LA232NoCode
;
;Search command in Bios table
;
;
;If not found
;Error
;Else execute it
;
LASrcUserCmd
;Search a command in the table pointed by HX
;
;On entry
; HX=TablePtr
; A=Num Commands in the table
; Rxbuffer+1->RxBuffer+3 Command
;On exit
; HX=Command Routine Pointer
LASrcCmd
psha
pshx
pshh
clra
psha
psha
;Save number of commands
;Save Table addr
;
;
;Init command counter
;Space for char counter
NextCmd
clr
1,SP
;Init char counter
lda
add
tax
lda
adc
psha
4,SP
1,SP
;
;
;
;
;
;
NextCmdChar
3,SP
#$00
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Source Code
For More Information On This Product,
Go to: www.freescale.com
DRM005
109
Freescale Semiconductor, Inc.
Freescale Semiconductor, Inc...
Source Code
pulh
lda
clrh
ldx
inc
cbeqx
cmp
beq
inc
lda
cmp
bhs
lda
add
sta
clra
adc
sta
bra
,X
1,SP
1,SP
#$03,CmdFound
RxBuffer+1,X
NextCmdChar
2,SP
2,SP
5,SP
CmdTableEnd
#$05
4,SP
4,SP
3,SP
3,SP
NextCmd
;
;Get Cmd char
;
;
;
;If 4th char Cmd found
;
;Loop for oll Cmd char
;If not equal next Cmd
;
;
;Untill last Cmd
;Next Cmd
;
;
;
;
;
;
CmdFound
lda
tax
lda
psha
pulh
lda
psha
ldx
pulh
ais
rts
4,SP
;
;
;
;
;
;
;
;
;
;
;
ldhx
ais
rts
#$0000
#$05
;
;
;
brclr
sta
rts
7,SCS1,*
SCDR
;
;
;
ldx
clrh
div
pshh
clrh
div
pshh
add
#$0A
;
;
;
;
;
;
;
;
3,SP
3,X
4,X
#$05
CmdTableEnd
LAPutRS232
LASendDec
DRM005
110
#$30
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Source Code
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Source Code
Mother Board Firmware
bsr
pula
add
bsr
pula
add
bsr
rts
LAPutRS232
lda
beq
aix
pshh
pshx
bsr
pulx
pulh
bra
,X
LAEndString1
#$01
#$30
LAPutRS232
#$30
LAPutRS232
;
;
;
;
;
;
;
;
Freescale Semiconductor, Inc...
LASendStr1
LAPutRS232
LASendStr1
;
;
;
;Save pointer
;
;
;Restore pointer
;
;
LAEndString1
rts
;
;Get the length of a string
;
;On entry
; HX=String pointer
;On exit
; A=Len (max 254 char) A=FF length error
; HX=String end pointer
LAStrLen
pshx
pshh
clra
;Save string pointer
;
LANextStrLen
tst
beq
aix
inca
cbeqa
bra
,X
LAStrLenEnd
#$01
#$FF,LAStrLenEnd
LANextStrLen
;
;
;
;
;
;
LAStrLenEnd
pulh
pulx
rts
;
;
;
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Source Code
For More Information On This Product,
Go to: www.freescale.com
DRM005
111
Freescale Semiconductor, Inc.
Source Code
Freescale Semiconductor, Inc...
;******************************************************************************
;
; Remote commands
;
;******************************************************************************
;***********************************************
; Programmer Identify Command
;
; Buffer status;
;
; 00
PackLen (Packet Length 04)
; 01-03
"PID"
; 04
Packet Checksum ($1E)
;***********************************************
CmdPID
ldhx
#PIDStr
;
jsr
rts
LASendStr1
;
;
PID1
;***********************************************
; Erase User Memory Command
;
; Buffer status;
;
; 00
PackLen (Packet Length 04)
; 01-03
"EUM"
; 04
Packet Checksum ($14)
;***********************************************
CmdEUM
jsr
ldhx
jsr
jsr
jmp
DRM005
112
LAClr
#EraseFirmMsg
LAPrintStr1
LAEraseUM
LACmdOK
;
;
;
;
;
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Source Code
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Source Code
Mother Board Firmware
;***********************************************
; Erase Programming Code Memory Command
;
; Buffer status;
;
; 00
PackLen (Packet Length 04)
; 01-03
"EPG"
; 04
Packet Checksum ($1F)
;***********************************************
Freescale Semiconductor, Inc...
CmdEPG
jsr
bclr
jmp
LAErasePG
UserP,SFlags
LACmdOK
;
;
;
;***********************************************
; Erase TX Memory Command
;
; Buffer status;
;
; 00
PackLen (Packet Length 04)
; 01-03
"ETX"
; 04
Packet Checksum ($0A)
;***********************************************
CmdETX
jsr
jmp
LAEraseTX
LACmdOK
;
;
;***********************************************
; Load TX Memory Command
;
; Buffer status;
;
; 00
PackLen (Packet Length 04)
; 01-03
"LTX"
; 04
Packet Checksum ($03)
;***********************************************
CmdLTX
jsr
jmp
LAUpdateTX
LACmdOK
;
;
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Source Code
For More Information On This Product,
Go to: www.freescale.com
DRM005
113
Freescale Semiconductor, Inc.
Source Code
;***********************************************
; Load Program Code Memory Command
;
; Buffer status;
;
; 00
PackLen (Packet Length 04)
; 01-03
"LPG"
; 04
Packet Checksum ($18)
;***********************************************
Freescale Semiconductor, Inc...
CmdLPG
jsr
LAUpdatePG
;
lda
clr
clr
jsr
rts
#’Y’
RS232St
BufferCnt
LAPutRS232
;
;
;
;
;
LACmdOK
;***********************************************
; Update User Code Command
;
; Buffer status;
;
; 00
PackLen (Packet Length 04)
; 01-03
"UUC"
; 04
Packet Checksum ($0E)
;***********************************************
CmdUUC
jsr
ldhx
jsr
jsr
bcc
jsr
ldhx
jsr
jsr
jmp
LAClr
#LoadFirmMsg
LAPrintStr1
LAUpdateUM
CmdUUC3
LAClr
#ErrFirmMsg
LAPrintStr1
LAWaitInput
LASoftReset
;
;
;
;
;
;
;
;
;
;
lda
jmp
SCDR
LASoftReset
;
;
CmdUUC3
DRM005
114
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Source Code
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Source Code
Mother Board Firmware
;****************************************************
;
; Flash programming routine
;
;****************************************************
;SourcePtr=address of page (128bytes) to be erased
Freescale Semiconductor, Inc...
LAErasePage
ldhx
lda
sta
lda
sta
lda
dbnza
lda
sta
ldx
SourcePtr
#%00000010
FLCR
FLBPR
,X
#Dly10us
$
#%00001010
FLCR
#$0A
;
;
;ERASE to 1
;
;
;Wait 10uS
;
;
;HVEN to 1
;
lda
dbnza
dbnzx
lda
sta
lda
dbnza
clra
sta
rts
#Dly100us
$
EraseDly
#%00001000
FLCR
#Dly100us
$
;
;
;
;
;ERASE to 0
;
;
;
;
;
EraseDly
FLCR
LAErasePageEnd
LAErasePageLen
equ
LOW(LAErasePageEnd-LAErasePage)
;SourcePtr=Start Address
;DestPtr=End Address
;FlashBuffer=Data buffer
LAProgRange
ldhx
clra
psha
SourcePtr
;
;
;
NextRow
lda
sta
lda
sta
lda
#%00000001
FLCR
FLBPR
,X
#Dly10us
;
;PGM to 1
;
;Dummy write in a flash location
;
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Source Code
For More Information On This Product,
Go to: www.freescale.com
DRM005
115
Freescale Semiconductor, Inc.
Source Code
dbnza
lda
sta
lda
dbnza
$
#%00001001
FLCR
#Dly5us
$
;Wait 10us
;
;HVEN to 1
;
;Wait 5us
Freescale Semiconductor, Inc...
NextRowByte
ldx
clrh
lda
ldhx
sta
inc
aix
sthx
cphx
beq
txa
and
beq
lda
dbnza
bra
1,SP
FlashBuffer,X
SourcePtr
,X
1,SP
#$01
SourcePtr
DestPtr
EndRow
#%00111111
EndRow
#Dly30us
$
NextRowByte
;
;
;
;
;
;
;
;
;
;
;
;Check if end of row
;
;
;Wait 30us
;Next Byte
EndRow
lda
dbnza
lda
sta
lda
dbnza
sta
cphx
bne
pula
rts
#Dly30us
$
#%00001000
FLCR
#Dly10us
$
FLCR
DestPtr
NextRow
;
;Wait 30us
;
;PGM to 0
;
;Wait 10us
;
;
;
;
;
LAProgRangeEnd
LAProgRangeLen
equ
LOW(LAProgRangeEnd-LAProgRange)
LALoadRAM
psha
clra
psha
;
;
;
LALoadRAMLoop
lda
aix
pshx
pshh
clrh
ldx
DRM005
116
,X
#$01
3,SP
;
;
;
;
;
;
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Source Code
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Source Code
Mother Board Firmware
sta
pulh
pulx
inc
dbnz
pula
pula
rts
RxBuffer,X
1,SP
2,SP,LALoadRAMLoop
;
;
;
;
;
;
;
;
Freescale Semiconductor, Inc...
LAEraseFPage
ldhx
lda
jsr
jsr
rts
#LAErasePage
#LAErasePageLen
LALoadRAM
RxBuffer
;
;
;Load routine in RAM
;
;
ldhx
lda
jsr
jsr
rts
#LAProgRange
#LAProgRangeLen
LALoadRAM
RxBuffer
;
;
;Load routine in RAM
;
;
ldhx
#$0000
;
lda
sta
aix
cphx
bne
rts
LAFirmUpdate,X
$100,X
#$01
#LAFirmUpdateLen
LAUpdateLoop
;
;
;
;
;
;
ldhx
#$0000
;
lda
sta
aix
cphx
bne
rts
LAEraseUser,X
$100,X
#$01
#LAEraseUserLen
LAEraseLoop
;
;
;
;
;
;
bsr
ldhx
sthx
ldhx
sthx
jsr
rts
LALoadUpdate
#$D700
EndAddr
#$8000
FlashTop
$100
;
;
;
;
;
;
;
LAProgFRange
LALoadUpdate
LAUpdateLoop
LALoadErase
LAEraseLoop
LAUpdateUM
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Source Code
For More Information On This Product,
Go to: www.freescale.com
DRM005
117
Freescale Semiconductor, Inc.
Source Code
LAEraseUM
bsr
ldhx
sthx
ldhx
sthx
jsr
rts
LALoadErase
#$8000
StartAddr
#$D700
EndAddr
$100
;
;
;
;
;
;
;
bsr
ldhx
sthx
ldhx
sthx
jsr
rts
LALoadUpdate
#$E700
EndAddr
#$D700
FlashTop
$100
;
;
;
;
;
;
;
bsr
ldhx
sthx
ldhx
sthx
jsr
rts
LALoadErase
#$D700
StartAddr
#$E700
EndAddr
$100
;
;
;
;
;
;
;
bsr
ldhx
sthx
ldhx
sthx
jsr
rts
LALoadUpdate
#$F000
EndAddr
#$E700
FlashTop
$100
;
;
;
;
;
;
;
bsr
ldhx
sthx
ldhx
sthx
jsr
rts
LALoadErase
#$E700
StartAddr
#$F000
EndAddr
$100
;
;
;
;
;
;
;
Freescale Semiconductor, Inc...
LAUpdatePG
LAErasePG
LAUpdateTX
LAEraseTX
LAEraseUser
tpa
psha
sei
ldhx
DRM005
118
StartAddr
;Save Status register
;
;
;
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Source Code
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Source Code
Mother Board Firmware
LAEraseUserLoop
sthx
lda
sta
lda
sta
lda
dbnza
lda
sta
ldx
StartAddr
#%00000010
FLCR
FLBPR
,X
#Dly10us
$
#%00001010
FLCR
#$0A
;
;
;ERASE to 1
;
;
;Wait 10uS
;
;
;HVEN to 1
;
lda
dbnza
dbnzx
lda
sta
lda
dbnza
clra
sta
ldhx
aix
aix
cphx
bne
pula
tap
rts
#Dly100us
$
LAEraseDly
#%00001000
FLCR
#Dly100us
$
;
;
;
;
;ERASE to 0
;
;
;
;
;
;
;
;
;
;
;
;
Freescale Semiconductor, Inc...
LAEraseDly
FLCR
StartAddr
#$40
#$40
EndAddr
LAEraseUserLoop
LAEraseUserEnd
LAFirmUpdate
tpa
psha
sei
bsr
LASendYes
;Save Status register
;
;
;
bsr
cbeqa
lda
bsr
bra
LAGet232
#’S’,LAFirm1
#’N’
LAPut232
LAFirmUpdate1
;
;
;
;
;
bsr
bsr
psha
bsr
tax
pulh
bra
LAPut232
LAGet232
;
;
;
;
;
;
;
LAFirmUpdate1
LAFirm1
LAGet232
LANextL
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Source Code
For More Information On This Product,
Go to: www.freescale.com
DRM005
119
Freescale Semiconductor, Inc.
Source Code
LAGet232
brclr
lda
rts
5,SCS1,*
SCDR
;
;
;
lda
bsr
pula
tap
sec
rts
#’N’
LAPut232
;
;
;
;
;
;
lda
#’Y’
;
brclr
sta
rts
7,SCS1,*
SCDR
;
;
;
sthx
bsr
sta
sta
clr
bsr
sta
bsr
sta
ldhx
NumLines
LAGet232
LineLen
ByteCount
LineSum
LAGet232
StartAddr
LAGet232
StartAddr+1
#$0090
;
;
;Save Line length
;
;
;
;
;
;
;
bsr
sta
add
sta
incx
dbnz
bsr
cmp
bne
ldhx
lda
sta
LAGet232
,X
LineSum
LineSum
;
;
;
;
;
;
;
;
;
;
;
;
LAProgErr
Freescale Semiconductor, Inc...
LASendYes
LAPut232
LANextL
NextLineByte
LineLen,NextLineByte
LAGet232
LineSum
LAProgErr
StartAddr
#$90
LASourceData
LANextRow
lda
sta
lda
sta
lda
dbnza
lda
sta
lda
dbnza
DRM005
120
#%00000001
FLCR
FLBPR
,X
#Dly10us
$
#%00001001
FLCR
Dly5us
$
;
;PGM to 1
;
;Dummy write in a flash location
;Wait 10us
;
;
;HVEN to 1
;
;Wait 10us
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Source Code
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Source Code
Mother Board Firmware
LANextRowByte
lda
cphx
bhs
cphx
blo
sta
$90
EndAddr
SkipByte
FlashTop
SkipByte
,X
;
;
;
;
;
;
Freescale Semiconductor, Inc...
SkipByte
lda
dbnza
aix
txa
and
beq
lda
inca
sta
dbnz
#Dly30us
$
#$01
;
;Wait 30us
;
;
#%00111111
;Check if end of row
LAEndRow
;
LASourceData
;
;
LASourceData
;
ByteCount,LANextRowByte ;
lda
sta
lda
dbnza
sta
cbeq
dbnz
#%00001000
FLCR
#Dly10us
$
FLCR
ByteCount,LAEndRow1
ByteCount,LANextRowByte
LAEndRow
;
;PGM to 0
;Wait 10us
;
;
;
;
LAEndRow1
bsr
ldhx
aix
cphx
bne
pula
tap
brclr
lda
clc
rts
LASendYes
NumLines
#$FF
#$0000
LANextL
equ
LOW(LAEraseUserEnd-LAEraseUser)
equ
LOW(LAFirmUpdateEnd-LAFirmUpdate)
equ
LANextRowByte-LAFirmUpdate+$101
5,SCS1,*
SCDR
;
;
;
;
;
;
;
;
;
;
;
LAFirmUpdateEnd
LAEraseUserLen
LAFirmUpdateLen
LASourceData
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Source Code
For More Information On This Product,
Go to: www.freescale.com
DRM005
121
Freescale Semiconductor, Inc.
Source Code
;****************************************************
;
; ROM DATA SECTION FOR LOADER AGENT
;
;****************************************************
FirmUpdMsg
EraseFirmMsg
Freescale Semiconductor, Inc...
LoadFirmMsg
ErrFirmMsg
DevName
AgentMsg
SumMsg
FirmOKMsg
BadFirmMsg
Contrast
VHHVal
PIDStr
CmdNum
CmdTab
DC.B
DC.B
DC.B
DC.B
DC.B
DC.B
DC.B
DC.B
"Waiting for
"Firmware...
"Erasing
"Firmware...
"Loading
"Firmware...
"Error !
"Press a kay
"
",$00
"
",$00
"
",$00
"
",$00
DC.B
DC.B
DC.B
DC.B
DC.B
DC.B
DC.B
DC.B
DC.B
DC.B
DC.B
DC.B
DC.B
DC.B
" 68HC908RF2
" Reference
" Board
"BLIC Agent
"Rev 1.0
"Code :
"Prog :
"Table:
":Pass
":Fail
"No Firmware
$60
$FF
"RFB A0.0
"
"
",$00
"
",$00
"
"
",$00
",$00
",$00
",$00
DC.B
$07
DC.B
DC.W
DC.B
DC.W
DC.B
DC.W
DC.B
DC.W
DC.B
DC.W
DC.B
DC.W
DC.B
DC.W
"PID"
CmdPID
"EPG"
CmdEPG
"ETX"
CmdETX
"EUM"
CmdEUM
"LPG"
CmdLPG
"LTX"
CmdLTX
"UUC"
CmdUUC
",$00
;
;
;
;
;
;
;
;
;
;
;
;
;
;
CmdTabEnd
DRM005
122
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Source Code
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Source Code
Mother Board Firmware
;******************************************************************************
;
; BIOS Jump Table
;
;******************************************************************************
Freescale Semiconductor, Inc...
IFNDEF TestAgent
BiosVectors:
SECTION
WaitInput
KeyOK
WaitKeyOK
WaitNotKeyOK
WaitNotPush
PushOK
WaitPush
PushEncoder
PullEncoder
InputByte
PowerOff
Dly1ms
DlyNms
Wait20ms
Wait200ms
Wait1s
SetContrast
SetVHH
WriteDAC
Wait5uS
Home
CursOn
CursOff
BlinkOn
Clr
GotoXY
PrintStr
PrintStr1
PrintChar
PrintChar1
PrintHex
PrintShort
PrintDec
InputHex
PutRS232
GetRS232
SendDec
SendStr1
EraseFPage
ProgFRange
UpdateUM
Menu
SoftReset
StrLen
jmp
jmp
jmp
jmp
jmp
jmp
jmp
jmp
jmp
jmp
jmp
jmp
jmp
jmp
jmp
jmp
jmp
jmp
jmp
jmp
jmp
jmp
jmp
jmp
jmp
jmp
jmp
jmp
jmp
jmp
jmp
jmp
jmp
jmp
jmp
jmp
jmp
jmp
jmp
jmp
jmp
jmp
jmp
jmp
LAWaitInput
LAKeyOK
LAWaitKeyOK
LAWaitNotKeyOK
LAWaitNotPush
LAPushOK
LAWaitPush
LAPushEncoder
LAPullEncoder
LAInputByte
LAPowerOff
LADly1ms
LADlyNms
LAWait20ms
LAWait200ms
LAWait1s
LASetContrast
LASetVHH
LAWriteDAC
LAWait5uS
LAHome
LACursOn
LACursOff
LABlinkOn
LAClr
LAGotoXY
LAPrintStr
LAPrintStr1
LAPrintChar
LAPrintChar1
LAPrintHex
LAPrintShort
LAPrintDec
LAInputHex
LAPutRS232
LAGetRS232
LASendDec
LASendStr1
LAEraseFPage
LAProgFRange
LAUpdateUM1
LAMenu
LASoftReset
LAStrLen
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
ENDIF
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Source Code
For More Information On This Product,
Go to: www.freescale.com
DRM005
123
Freescale Semiconductor, Inc.
Source Code
Freescale Semiconductor, Inc...
;******************************************************************************
;
; Parameter Flash
;
;******************************************************************************
Param:
SECTION
NVRegs
DC.B
DC.B
DC.B
$D4
$A1
$00
END
A.2.2 UK509 PRM
NAMES
ansi.lib
/* other object files to link are passed from the IDF with the linker -Add option
*/
END
SECTIONS
DIRECT_RAM = READ_WRITE 0x40 TO 0xFF;
BUFF_RAM = READ_WRITE 0x0100 TO 0x01FF;
STACK_RAM = READ_WRITE 0x0200 TO 0x023F;
MY_ROM = READ_ONLY 0x8000 TO 0xEFFF;
LOADER_ROM = READ_ONLY 0xF000 TO 0xFBFF;
BIOSVEC_ROM = READ_ONLY 0xFC00 TO 0xFCFF;
PARAM_ROM = READ_ONLY 0xFD00 TO 0xFDFF;
END
PLACEMENT
DEFAULT_ROM, ROM_VAR, STRINGS
DEFAULT_RAM
BUFFERS
BiosVectors
Loader
Param
SSTACK
END
INTO
INTO
INTO
INTO
INTO
INTO
INTO
MY_ROM;
DIRECT_RAM;
BUFF_RAM;
BIOSVEC_ROM;
LOADER_ROM;
PARAM_ROM;
STACK_RAM;
STACKSIZE 0x40
INIT LAInit
VECTOR ADDRESS 0xFFFE LAInit
VECTOR ADDRESS 0xFFFA IRQProc
VECTOR ADDRESS 0xFFE4 GetRS232
DRM005
124
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Source Code
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Source Code
Transmitter Firmware
A.3 Transmitter Firmware
Freescale Semiconductor, Inc...
;Emulated
equ
0
;
;------------------------------------------------------------------------------;
; UK804 : Transmitter Sw (inside the MC68HC908RF2)
;
;------------------------------------------------------------------------------;
; SOURCE
: UK804.ASM
; CONTROLLER : 68HC908RF2
; CLOCK
: 8 Mhz
;
; VERSIONE
: 1.00
28 Feb 2001
;
;------------------------------------------------------------------------------;
;
;
#$-VIEW:UK804 Schematics-$#
include
;
"C:\Metrowerks\lib\HC08c\INC\H908RK2.INC"
#$-VIEW:RK2 Registers Declarations-$#
;###############################################################################
;#
#
;#
TRANSMISSION FRAME COMPOSITION
#
;#
#
;# NNNNNNME-IIIIIIII-IIIIIIII-IIIIIIII-DGGGTTTT-RRRRRRRR
#
;# | EXTRA |--------ID NUMBER--------| codice | --CRC--|
#
;#
#
;# I=ID NUMBER -> FIX IDENTIFICATION CODE (3 BYTES)
#
;# G=GROUP
-> SELECTED GROUP
#
;# D=DIRECTION -> 1=INCREASE 0=DECREASE
#
;# M=MODE
-> 1=Toggle 0=Normal
#
;# T=BUTTON
-> BUTTON SELECTED CODE
#
;# R=CRC
-> CRC
#
;# E=EXTRA
-> COMMUTATION FLAG (1-> COMMUTATION 0-> IT CHANGES)
#
;# N=UNUSED
-> THEY MUST BE 0
#
;#
#
;#
#
;#
TEMPORIZATIONS
#
;#
#
;# Duration Time of the sync signal = 6ms
#
;# Duration Time of a Bit
= 2ms
#
;# Bit 0 -> LowTime=1.33ms HighTime=0.66ms
#
;# Bit 1 -> LowTime=0.66ms HighTime=1.33ms
#
;#
#
;###############################################################################
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Source Code
For More Information On This Product,
Go to: www.freescale.com
DRM005
125
Freescale Semiconductor, Inc.
Source Code
; Keyboard Buttons Codification
;
;
;
;
;
COL0
COL1
02 <D--P1--U>
04 <D--P2--U>
06 <D--P3--U>
01 <D--P4--U>
82
84
86
81
ROW0
ROW1
ROW2
ROW3
Freescale Semiconductor, Inc...
; Porta A
PLLEn
Row0
Row1
Row2
Row3
Col0
Col1
Led
equ
equ
equ
equ
equ
equ
equ
equ
0
1
2
3
4
5
6
7
;Tango PLL Enable
;Keyboard Row 0
;Keyboard Row 1
;Keyboard Row 2
;Keyboard Row 3
;Keyboard Column 0
;Keyboard Column 1
;Led
DDRAInit
PortAInit
equ
equ
%10000001
%00000000
;
;
Data
DClk
equ
equ
2
3
;Data Out to Tango
;Data Clock from Tango
DDRBInit
PortBInit
equ
equ
%00000100
%00000000
;
;
1
1
1
1
1
1
1
1
1
1
1
1
;Control Byte
;ID0
;ID1
;ID2
;Key
;RC0
;RC1
;
;
;
;
;
; Porta B
ORG $80
Buffer0
Buffer1
Buffer2
Buffer3
Buffer4
Buffer5
Buffer6
CRC
BitCount
LastRow
LastCol
TxCnt
DRM005
126
DS.B
DS.B
DS.B
DS.B
DS.B
DS.B
DS.B
DS.B
DS.B
DS.B
DS.B
DS.B
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Source Code
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Source Code
Transmitter Firmware
Freescale Semiconductor, Inc...
; Costanti
Dly300ms
MinTx
FrameDly
equ
equ
equ
$03
$03
$20
codeSec:
SECTION
XDEF
XDEF
;300ms@8Mhz
;Minimum number of frame transmitted
;Delay between frames
(771*FrameDly cycles)
main
KeybIRQ
main
mov
#%00000011,CONFIG1
;Diasble COP and enable Stop
instruction
;Init stack pointer
#DDRAInit,DDRA
#PortAInit,PORTA
#DDRBInit,DDRB
#PortBInit,PORTB
PLLEn,PORTA
;Init PORTA
;
;Init PORTB
;
;Start PLL of Tango
rsp
WarmStart
mov
mov
mov
mov
bset
;
; WARNING !!!!! IMASKK is inverted in emulation with MMDS/MMEVS
;
ifdef
Emulated
mov
#%00000011,INTKBSCR
;Init Keyboard
mov
#%00100001,INTKBSCR
;
mov
#%00011110,INTKBIER
;
bset
ACKK,INTKBSCR
bset
bclr
Led,PORTA
PLLEn,PORTA
;Clear possible Keyboard interrupt
before Stop
;Power off led
;Stop PLL of Tango
else
endif
Sleep
;
; WARNING !!!!! Stop instruction does not work with MMDS/MMEVS
;
ifdef
Emulated
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Source Code
For More Information On This Product,
Go to: www.freescale.com
DRM005
127
Freescale Semiconductor, Inc.
Source Code
StopProc
cli
nop
bra
;Emulated Stop instruction
;
StopProc
else
StopProc
stop
nop
bra
;
;
StopProc
brclr
jmp
7,INTKBSCR,KeyboardProc ;Check if IRQ intetrrupt
IRQProc
;
bset
bclr
clrx
2,INTKBSCR
Led,PORTA
;Reset Keyboard Flag
;Led On
;
lda
coma
and
lsra
bne
dbnza
dbnzx
jmp
PORTA
RowOk
$
WaitRow
ExitKeyb
;Read Key Row
;
;
;
;
;
;If Row=0 wait until timeout
;Row timeout
sta
clr
LastRow
INTKBIER
;Save Row number
;Clear Keyboard interrupt enable
lda
ora
sta
lda
ora
sta
clrx
mov
#%00011110
DDRA
DDRA
#%00011110
PORTA
PORTA
#$10,BitCount
;All rows to 1
;
;
;
;
;
;
;
lda
#$40
;
Freescale Semiconductor, Inc...
endif
KeybIRQ
KeyboardProc
WaitRow
#%00011110
RowOk
bits
ColLoop
KeyLoop
dbnzx
dbnza
DRM005
128
KeyLoop
KeyLoop
;
;Wait 49152 cycles
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Source Code
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Source Code
Transmitter Firmware
WaitCol
lda
and
nsa
lsra
bne
dbnz
jmp
PORTA
#%01100000
ColOk
BitCount,ColLoop
ExitKeyb
;Get Column
;
;
;
;
;If Row=0 wait until timeout
;Column timeout
sta
lda
brset
lda
brset
lda
brset
lda
LastCol
#$02
0,LastRow,SetCol
#$04
1,LastRow,SetCol
#$06
2,LastRow,SetCol
#$01
;Save column
;Decode Key
;
;
;
;
;
;
brclr
ora
1,LastCol,SetKey
#$80
;
;
Freescale Semiconductor, Inc...
ColOk
SetCol
;Init Transmission Buffer
SetKey
sta
clr
lda
sta
lda
sta
lda
sta
lda
Buffer4
Buffer0
ID0
Buffer1
ID1
Buffer2
ID2
Buffer3
#Dly300ms
;Init Key Code
;
;Init ID
;
;
;
;
;
;Wait for the time specified in
Accumulator
;
;
;
dbnzx
dbnza
dbnz
pula
$
ToggleDly
1,SP,ToggleDly
;[3*256=768]
;[256*771]
;[197379*Dly300ms]
;
lda
and
nsa
lsra
bne
bset
PORTA
#%01100000
;Check if key still down
;
;
;
;
;
psha
clra
clrx
ToggleDly
NoToggle
0,Buffer0
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Source Code
For More Information On This Product,
Go to: www.freescale.com
DRM005
129
Freescale Semiconductor, Inc.
Source Code
NoToggle
lda
add
sta
clra
adc
sta
lda
and
beq
tax
#$01
Buffer6
Buffer6
lda
rora
ror
ror
ror
ror
ror
ror
dbnzx
Buffer5
Buffer0
Buffer1
Buffer2
Buffer3
Buffer4
Buffer5
NextRotate
;
;
;
;
;
;
;
;
;
ldhx
lda
eor
sta
eor
sta
eor
sta
eor
sta
eor
sta
#Buffer0
,X
1,X
1,X
2,X
2,X
3,X
3,X
4,X
4,X
5,X
5,X
;
;
;
;
;
;
;
;
;
;
;
;
Buffer5
Buffer5
Buffer6
#$0F
NoRotate
;
;
;
;
;
;
;
;
;
;
Freescale Semiconductor, Inc...
NextRotate
NoRotate
; Calculate CRC
clr
ldhx
CRC
#Buffer6
;
;
mov
#$08,BitCount
;
lda
eor
lsr
and
beq
lda
eor
sta
0,X
CRC
CRC
#$01
NoXor
#%10001100
CRC
CRC
;
;
;
;
;
;
;
;
NextCRCByte
NextCRCBit
DRM005
130
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Source Code
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Source Code
Transmitter Firmware
Freescale Semiconductor, Inc...
NoXor
lda
rora
ror
dbnz
decx
cpx
bne
lda
ror
rora
nsa
sta
0,X
0,X
BitCount,NextCRCBit
#Buffer0-1
NextCRCByte
CRC
CRC
CRC
;
;
;
;
;
;
;
;
;
;
;
;
;################################################################################
;#
;#
Data Timing
;#
;# Timing is derived from Tango DataClock signal (Tango Xtal/64) that is
;# [email protected] (4.717 us period).
;# Tango DataClock is used as Timer Module Clock by MCU. When external clock
;# is used by Timer Module the prescaler is not available and the clock is
;# directly to the timer counter.
;#
;################################################################################
#
#
#
#
#
#
#
#
#
;Transmission Loop
mov
mov
mov
mov
bset
mov
#DDRAInit,DDRA
#PortAInit,PORTA
#%00011110,INTKBIER
#MinTx,TxCnt
PLLEn,PORTA
#%00110111,TASCR
;
;
;
;
;
;Stop and reset Timer
bset
ldx
clra
Data,PORTB
#FrameDly
;
;
;
clr
dbnza
dbnzx
mov
bclr
mov
ldhx
sthx
ldhx
sthx
bclr
TASC0
$
FrameBlank
#%00110111,TASCR
Data,PORTB
#%00010010,TASC0
#$0300
TAMODH
#$0180
TACH0H
7,TASC0
;
;
;
;Stop and reset Timer
;
;
;Timer modulo=$0300 (3.622ms)
;
;Compare Value=$0180 (0.603ms)
;
;Clear Flag
NextFrame
FrameBlank
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Source Code
For More Information On This Product,
Go to: www.freescale.com
DRM005
131
Freescale Semiconductor, Inc.
Freescale Semiconductor, Inc...
Source Code
mov
#%00011110,TASC0
bclr
bclr
brclr
mov
ldhx
sthx
clr
lda
sta
ldhx
psha
mov
7,TASCR
5,TASCR
7,TASCR,*
#%00110111,TASCR
#$00D2
TAMODH
TACH0H
#$46
TACH0L
#CRC
bclr
5,TASCR
;Set On Compare and Toggle on
Overflow
;Clear Flag
;Start Timer
;Wait
;Stop Timer
;Timer modulo=$00D2 (990us)
;
;
;
;Compare Value=1/3 bit time
;HX points to CRC
;Space in stack for bit counter
;Set On Compare and Toggle on
Overflow
;Start Timer
lda
sta
#$08
1,SP
;Init Bit Counter
;
lda
rora
ror
clr
lda
bcs
lsla
0,X
;
;
;
;
;Compare Value=1/3 bit time if bit=1
;
;Compare Value=2/3 bit time if bit=0
sta
brclr
bclr
dbnz
decx
cpx
bne
mov
pula
clra
dbnza
tst
beq
dbnz
TACH0L
7,TASCR,*
7,TASCR
1,SP,NextTxBit
#%00011110,TASC0
NextTxByte
NextTxBit
0,X
TACH0H
#$46
Bit1
Bit1
#Buffer0-1
NextTxByte
#%00110111,TASCR
$
TxCnt
ChkKey
TxCnt,NextFrame
;
;Wait
;Clear Flag
;
;
;
;
;Stop Timer
;Free stack
;
;
;
;
;
ChkKey
lda
coma
and
bne
bclr
DRM005
132
PORTA
#%00011110
NextFrame
PLLEn,PORTA
;
;
;
;
;
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Source Code
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Source Code
Transmitter Firmware
ExitKeyb
mov
mov
mov
#DDRAInit,DDRA
#PortAInit,PORTA
#%00011110,INTKBIER
;
;
;
lda
coma
and
bne
bset
bset
tst
bne
dec
PORTA
;
;
;
;
;
;
;Test Return Address Low
;
;
Freescale Semiconductor, Inc...
WaitKeyUp
#%00011110
WaitKeyUp
ACKK,INTKBSCR
Led,PORTA
5,SP
DecLow
4,SP
DecLow
dec
rti
5,SP
;
;
bset
rti
6,INTKBSCR
;Reset IRQ Flag
DC.B
DC.B
DC.B
$54
$23
$F4
IRQProc
ID0
ID1
ID2
END
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Source Code
For More Information On This Product,
Go to: www.freescale.com
DRM005
133
Freescale Semiconductor, Inc.
Freescale Semiconductor, Inc...
Source Code
DRM005
134
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Source Code
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Designer Reference Manual — Remote Keyless Entry
Appendix B. Schematics
Freescale Semiconductor, Inc...
This appendix includes:
•
Mother Board schematic — Figure B-1
•
Receiver schematic — Figure B-2
•
Transmitter schematic — Figure B-3
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Schematics
For More Information On This Product,
Go to: www.freescale.com
DRM005
135
Freescale Semiconductor, Inc.
Figure B-1. Mother Board Schematic
Freescale Semiconductor, Inc...
Schematics
DRM005
136
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Schematics
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
C19
C8
100 P
CDG
4
RFIN
6
GNDL
1.4–3 pF
3 MM
GNDS
5
GND
8
VCC
9 19
GND1
GND0
VCC1
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Schematics
For More Information On This Product,
Go to: www.freescale.com
500P
00G
22
3
VDCL
18
IC2
MC33591
12
C3
23
XJA
10N
24
C8
19
7
11
10
6P
CDG
CR1
C11
ROBGAP
STROBE
RESETB
MISO
MOSI
SCLK
VCC
20
21
14
15
16
17
180K
R3
10 K
Figure B-2. Receiver Schematic
500M
XJA
C5
CAFC
MIKOUT
DMIXAGO
VDC0
CAGC
DMDAT
PFD
2
X1
MOTOROLA
1
X2
B8N
X7A
R5
GND
C4
470 K
R2
1U
Y5V
1U
Y6V
C10
Freescale Semiconductor, Inc...
C12
1uH
CN2
CN2
CN2
CN2
CN2
CN2
CN2
CN2
7
32
28
33
23
24
25
36
CN8
CN7
CN6
CN5
CN4
CN3
Freescale Semiconductor, Inc.
Schematics
DRM005
137
2
BAT1
1 C42032
Schematics
For More Information On This Product,
Go to: www.freescale.com
1U
YBV
C8
10
1K
1K
10
R23
R22
CN5
CN4
GND
DCLK
18
DATA
17
BAND
16
PLLEN
15
MODE
OSC1
21
19
PTA0
1
PTA1/KBD1
32
PTA2/KBD2
31
PTA3/KBD3
30
PTA4/KBD4
29
PTA5/KBD5
28
PTA6/KBD6
27 PTA7
3
PTB0/MCLK
4
PTB1
5 PTB2/TCHO
20
PTB3/TCLK
2
25
22
26
23
8
X0
24
14
11
8P
C0G
CR1
7
IC1
HC908RF2REV1
C5
12K
10
Figure B-3. Transmitter Schematic
10K
R21 R19
CNE
330
R16
SW2
SW4
10k
R20 R18
10k
R18
SW1
SW3
TL0U1002
10
R14
IRQ
OSC2
SW5
RESET
VSS
SW6
VDD
SW8
VCCPF
SW7
X1
LD1
VCC
CFBK
138
R17
9
PEXT
DRM005
GNDPF
13
6
10N
X7R
RFOUT 12
GND
CN1 CN2 CN3
VCC
Freescale Semiconductor, Inc...
8P
C0G
C8
3 MM
1.4–3 pF
C3
C8
L1
C2
100P 1U
COB Y5V
22 nH
C7
Freescale Semiconductor, Inc.
Schematics
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Freescale Semiconductor, Inc.
Designer Reference Manual — Remote Keyless Entry
Appendix C. Board Layouts
Freescale Semiconductor, Inc...
This appendix includes pictorials of the board layouts (top and bottom
views) for:
•
Transmitter — Figure C-1 and Figure C-2
•
Receiver — Figure C-3 and Figure C-4
•
Mother board — Figure C-5 and Figure C-6
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Board Layouts
For More Information On This Product,
Go to: www.freescale.com
DRM005
139
Freescale Semiconductor, Inc.
Freescale Semiconductor, Inc...
Board Layouts
Figure C-1. Transmitter Layout (Top View)
DRM005
140
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Board Layouts
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Freescale Semiconductor, Inc...
Board Layouts
Figure C-2. Transmitter Layout (Bottom View)
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Board Layouts
For More Information On This Product,
Go to: www.freescale.com
DRM005
141
Freescale Semiconductor, Inc.
Freescale Semiconductor, Inc...
Board Layouts
Figure C-3. Receiver Layout (Top View)
DRM005
142
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Board Layouts
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Freescale Semiconductor, Inc...
Board Layouts
Figure C-4. Receiver Layout (Bottom View)
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Board Layouts
For More Information On This Product,
Go to: www.freescale.com
DRM005
143
Freescale Semiconductor, Inc.
Figure C-5. Mother Board Layout (Top View)
Freescale Semiconductor, Inc...
Board Layouts
DRM005
144
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Board Layouts
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Figure C-6. Mother Board Layout (Bottom View)
Freescale Semiconductor, Inc...
Board Layouts
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Board Layouts
For More Information On This Product,
Go to: www.freescale.com
DRM005
145
Freescale Semiconductor, Inc.
Freescale Semiconductor, Inc...
Board Layouts
DRM005
146
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Board Layouts
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Designer Reference Manual — Remote Keyless Entry
Appendix D. Bill of Materials
Freescale Semiconductor, Inc...
D.1 Contents
D.2
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
D.3
Transmitter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
D.4
Receiver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
D.5
Mother Board . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .150
D.2 Introduction
This appendix provides the remote keyless entry (RKE) reference
design bill of materials.
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Bill of Materials
For More Information On This Product,
Go to: www.freescale.com
DRM005
147
Freescale Semiconductor, Inc.
Bill of Materials
D.3 Transmitter
Transmitter PARTLIST
Title TX
Customer Motorola
Author Andrea Martini
Rev
A1.0
PWS Rev A0.0
Date 09 Nov 2001
Freescale Semiconductor, Inc...
Components
DRM005
148
Ref
Value
Package
Function
BAT1
C2
C3
C5
C6
C7
C8
C9
CR1
IC1
L1
LD1
R14
R15
R16
R17
R18
R19
R20
R21
R22
R23
SW
100p
8p
6p
1u
1u
10n
1.4-3pF
13.560MHz
HC908RF2REV1
22nH
LED0805
330
1K
1K
12K
10K
10K
10
10
10K
10
PIH
0603
0603
0603
0603
0603
0603
SMD
HC49SMX
LQFP32
008
0805
0603
0603
0603
0603
0603
0603
0603
0603
0603
0603
BATTERY CONTACT
CAPACITOR
CAPACITOR
CAPACITOR
CAPACITOR
CAPACITOR
CAPACITOR
TRIMMER
XTAL
MICRO
INDUCTORS
LED
RESISTOR
RESISTOR
RESISTOR
RESISTOR
RESISTOR
RESISTOR
RESISTOR
RESISTOR
RESISTOR
RESISTOR
Keyboard
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Bill of Materials
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Bill of Materials
Receiver
D.4 Receiver
Receiver PARTLIST
Title RX Board
Customer MOTOROLA
Author Andrea Martini
Rev
A1.0
PWS Rev A0.0.0
Date 09/11/01
Freescale Semiconductor, Inc...
Components
Ref
Value
Package
Function
C10
C11
C12
C13
C3
C4
C5
C6
C8
CR1
IC2
L1
R2
R3
R5
1u
6p
1u
1.4-3pF
100n
68n
100p
10n
100p
13.5806MHz
MC33591
1uH
470K
180K
10K
0603
0603
0603
1008
0603
0603
0603
0603
0603
SMD3118
LQFP24
1008
0603
0805
0603
CAPACITOR
CAPACITOR
CAPACITOR
TRIMMER
CAPACITOR
CAPACITOR
CAPACITOR
CAPACITOR
CAPACITOR
XTAL
IC
INDUCTORS
RESISTOR
RESISTOR
RESISTOR
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Bill of Materials
For More Information On This Product,
Go to: www.freescale.com
DRM005
149
Freescale Semiconductor, Inc.
Bill of Materials
D.5 Mother Board
MotherBoard PARTLIST
Title Motherboard
Customer MOTOROLA
Author Andrea Martini
Rev
A0.0
PWS Rev A0.0.0
Date 09/11/00
Freescale Semiconductor, Inc...
Components
DRM005
150
Ref
Value
Package
Function
C34
C51
C52
C57
C58
C59
C60
C61
C62
C63
C64
C65
C66
CN12
CN13
CN14
CN15
CN29
CR1
D1
D2
D3
D4
IC13
IC14
IC15
IC16
1u
100n
1u
100n
470uF
100n
10uF
10uF
1u
1u
1u
1u
1u
FH40
FH40
FH40
PLUG2.5mm
DB9
9.8304MHZ
1SS355
ZRA250F01
MBRD835
MMSZ5225B
MIC4416
MIC5206BMM
MIC5206
MIC4416
0603
0603
0603
0603
8/16-VERT
0603
5/11-VERT
5/11-VERT
0603
0603
0603
0603
0603
CAPACITOR
CAPACITOR
CAPACITOR
CAPACITOR
CAPACITOR
CAPACITOR
CAPACITOR
CAPACITOR
CAPACITOR
CAPACITOR
CAPACITOR
CAPACITOR
CAPACITOR
CONNECTOR
CONNECTOR
CONNECTOR
CONNECTOR
CONNECTOR
OSC
DIODE
REFERENCE
DIODE
ZENER
MOSFET
REGULATOR
REGULATOR
MOSFET
—Continued on next page —
DIP8
SOD323
SOT23
DPACK
SOD123
SOT143
MSOP8
SOT23-5
SOT143
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Bill of Materials
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc.
Freescale Semiconductor, Inc...
Bill of Materials
Mother Board
Ref
Value
Package
Function
IC17
IC29
IC30
IC31
IC33
IC34
IC35
IC36
IC37
MOS1
Q1
R12
R13
R17
R2
R21
R22
R24
R25
R26
R27
R28
R3
R30
R31
R32
R33
R34
R35
R36
R37
R38
R39
R7
R9
SW4
SW5
EA7123I2C
HC908GP32
HN29W128
74HC04D
MAX533BCEE
LMV321
74HC125D
MAX232SO
74HC139D
IRL9024
SMBT3904
10K
10K
10K
56K
10K
10K
1K
1K
10K
100K
100K
10K
10K
10K
10K
10K
10K
10K
470
1K
1K
1K
10K
10K
EC11B15242
SW5511M1X
QFP44
48TSOP
SO14
SSOP16
SC70
SO14
SO16W
SO16
D-PACK
SOT23
0603
0603
0603
0603
0603
0603
0603
0603
0603
0603
0603
0603
0603
0603
0603
0603
0603
0603
0603
0603
0603
0603
0603
0603
Oriz
PIH
LCD
MCU
Memory
LOGIC
DAC
OPERATIONAL
LOGIC
INTERFACE
LOGIC
MOSFET
BJT
RESISTOR
RESISTOR
RESISTOR
RESISTOR
RESISTOR
RESISTOR
RESISTOR
RESISTOR
RESISTOR
RESISTOR
RESISTOR
RESISTOR
RESISTOR
RESISTOR
RESISTOR
RESISTOR
RESISTOR
RESISTOR
RESISTOR
RESISTOR
RESISTOR
RESISTOR
RESISTOR
RESISTOR
SWITCHES
SWITCHES
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
MOTOROLA
Bill of Materials
For More Information On This Product,
Go to: www.freescale.com
DRM005
151
Freescale Semiconductor, Inc.
Freescale Semiconductor, Inc...
Bill of Materials
DRM005
152
Remote Keyless Entry (RKE) Reference Design Using the MC68HC908RF2
Bill of Materials
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Freescale Semiconductor, Inc...
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
HOW TO REACH US:
USA/EUROPE/LOCATIONS NOT LISTED:
Motorola Literature Distribution;
P.O. Box 5405, Denver, Colorado 80217
1-303-675-2140 or 1-800-441-2447
JAPAN:
Motorola Japan Ltd.; SPS, Technical Information Center,
3-20-1, Minami-Azabu Minato-ku, Tokyo 106-8573 Japan
81-3-3440-3569
Freescale Semiconductor, Inc...
ASIA/PACIFIC:
Motorola Semiconductors H.K. Ltd.;
Silicon Harbour Centre, 2 Dai King Street,
Tai Po Industrial Estate, Tai Po, N.T., Hong Kong
852-26668334
TECHNICAL INFORMATION CENTER:
Information in this document is provided solely to enable system and software
implementers to use Motorola products. There are no express or implied copyright
licenses granted hereunder to design or fabricate any integrated circuits or
integrated circuits based on the information in this document.
Motorola reserves the right to make changes without further notice to any products
herein. Motorola makes no warranty, representation or guarantee regarding the
1-800-521-6274
suitability of its products for any particular purpose, nor does Motorola assume any
HOME PAGE:
liability arising out of the application or use of any product or circuit, and specifically
http://www.motorola.com/semiconductors
disclaims any and all liability, including without limitation consequential or incidental
damages. “Typical” parameters which may be provided in Motorola data sheets
and/or specifications can and do vary in different applications and actual
performance may vary over time. All operating parameters, including “Typicals”
must be validated for each customer application by customer’s technical experts.
Motorola does not convey any license under its patent rights nor the rights of
others. Motorola products are not designed, intended, or authorized for use as
components in systems intended for surgical implant into the body, or other
applications intended to support or sustain life, or for any other application in which
the failure of the Motorola product could create a situation where personal injury or
death may occur. Should Buyer purchase or use Motorola products for any such
unintended or unauthorized application, Buyer shall indemnify and hold Motorola
and its officers, employees, subsidiaries, affiliates, and distributors harmless
against all claims, costs, damages, and expenses, and reasonable attorney fees
arising out of, directly or indirectly, any claim of personal injury or death associated
with such unintended or unauthorized use, even if such claim alleges that Motorola
was negligent regarding the design or manufacture of the part.
Motorola and the Stylized M Logo are registered in the U.S. Patent and Trademark
Office. digital dna is a trademark of Motorola, Inc. All other product or service
names are the property of their respective owners. Motorola, Inc. is an Equal
Opportunity/Affirmative Action Employer.
© Motorola, Inc. 2002
DRM005/D
For More Information On This Product,
Go to: www.freescale.com