© 2005 Microchip Technology Inc. DS00000A
Passive Keyless Entry (PKE)Reference Design
User’s Manual
Note the following details of the code protection feature on Microchip devices:
• Microchip products meet the specification contained in their particular Microchip Data Sheet.
• Microchip believes that its family of products is one of the most secure families of its kind on the market today, when used in the intended manner and under normal conditions.
• There are dishonest and possibly illegal methods used to breach the code protection feature. All of these methods, to our knowledge, require using the Microchip products in a manner outside the operating specifications contained in Microchip’s Data Sheets. Most likely, the person doing so is engaged in theft of intellectual property.
• Microchip is willing to work with the customer who is concerned about the integrity of their code.
• Neither Microchip nor any other semiconductor manufacturer can guarantee the security of their code. Code protection does not mean that we are guaranteeing the product as “unbreakable.”
Code protection is constantly evolving. We at Microchip are committed to continuously improving the code protection features of ourproducts. Attempts to break Microchip’s code protection feature may be a violation of the Digital Millennium Copyright Act. If such actsallow unauthorized access to your software or other copyrighted work, you may have a right to sue for relief under that Act.
Information contained in this publication regarding deviceapplications and the like is provided only for your convenienceand may be superseded by updates. It is your responsibility toensure that your application meets with your specifications.MICROCHIP MAKES NO REPRESENTATIONS OR WAR-RANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED,WRITTEN OR ORAL, STATUTORY OR OTHERWISE,RELATED TO THE INFORMATION, INCLUDING BUT NOTLIMITED TO ITS CONDITION, QUALITY, PERFORMANCE,MERCHANTABILITY OR FITNESS FOR PURPOSE.Microchip disclaims all liability arising from this information andits use. Use of Microchip’s products as critical components inlife support systems is not authorized except with expresswritten approval by Microchip. No licenses are conveyed,implicitly or otherwise, under any Microchip intellectual propertyrights.
DS00000A-page ii
Trademarks
The Microchip name and logo, the Microchip logo, Accuron, dsPIC, KEELOQ, microID, MPLAB, PIC, PICmicro, PICSTART, PRO MATE, PowerSmart, rfPIC, and SmartShunt are registered trademarks of Microchip Technology Incorporated in the U.S.A. and other countries.
AmpLab, FilterLab, Migratable Memory, MXDEV, MXLAB, PICMASTER, SEEVAL, SmartSensor and The Embedded Control Solutions Company are registered trademarks of Microchip Technology Incorporated in the U.S.A.
Analog-for-the-Digital Age, Application Maestro, dsPICDEM, dsPICDEM.net, dsPICworks, ECAN, ECONOMONITOR, FanSense, FlexROM, fuzzyLAB, In-Circuit Serial Programming, ICSP, ICEPIC, Linear Active Thermistor, MPASM, MPLIB, MPLINK, MPSIM, PICkit, PICDEM, PICDEM.net, PICLAB, PICtail, PowerCal, PowerInfo, PowerMate, PowerTool, rfLAB, rfPICDEM, Select Mode, Smart Serial, SmartTel, Total Endurance and WiperLock are trademarks of Microchip Technology Incorporated in the U.S.A. and other countries.
SQTP is a service mark of Microchip Technology Incorporated in the U.S.A.
All other trademarks mentioned herein are property of their respective companies.
© 2005, Microchip Technology Incorporated, Printed in the U.S.A., All Rights Reserved.
Printed on recycled paper.
© 2005 Microchip Technology Inc.
Microchip received ISO/TS-16949:2002 quality system certification for its worldwide headquarters, design and wafer fabrication facilities in Chandler and Tempe, Arizona and Mountain View, California in October 2003. The Company’s quality system processes and procedures are for its PICmicro® 8-bit MCUs, KEELOQ® code hopping devices, Serial EEPROMs, microperipherals, nonvolatile memory and analog products. In addition, Microchip’s quality system for the design and manufacture of development systems is ISO 9001:2000 certified.
PKE REFERENCE DESIGNUSER’S MANUAL
Table of Contents
Preface ........................................................................................................................... 1
Chapter 1. System Overview1.1 Overview ........................................................................................................ 51.2 Operational Overview ..................................................................................... 61.3 Features ......................................................................................................... 6
1.3.1 LF Initiator ................................................................................................... 61.3.2 Key Fob ....................................................................................................... 61.3.3 RF Receiver ................................................................................................ 6
1.4 Reference Documents .................................................................................... 7
Chapter 2. Low Frequency Initiator Module2.1 Introduction ..................................................................................................... 92.2 Hardware ........................................................................................................ 9
2.2.1 Microcontroller ............................................................................................. 92.2.2 Configurable Inputs ..................................................................................... 92.2.3 LF Transmitter ............................................................................................. 92.2.4 Network Interfaces ...................................................................................... 92.2.5 Power .......................................................................................................... 9
2.3 Software ....................................................................................................... 11
Chapter 3. PKE Transmitter-Transponder3.1 Introduction ................................................................................................... 133.2 Hardware ...................................................................................................... 13
3.2.1 Transmitter ................................................................................................ 14
3.3 Software ....................................................................................................... 163.3.1 Dual Encoder Operation ............................................................................ 193.3.2 Code Hopping Code Word Data Format ................................................... 193.3.3 EEPROM Organization ............................................................................. 22
Chapter 4. Remote Keyless Entry Receiver-Decoder Module4.1 Introduction ................................................................................................... 274.2 Hardware ...................................................................................................... 27
4.2.1 UHF Receiver ............................................................................................ 274.2.2 Microcontroller ........................................................................................... 274.2.3 Network Interface ...................................................................................... 284.2.4 Power Supply ............................................................................................ 284.2.5 Connectors ................................................................................................ 29
4.3 Software ....................................................................................................... 314.3.1 Modules Overview ..................................................................................... 31
Worldwide Sales and Service .................................................................................... 36
© 2005 Microchip Technology Inc. DS00000A-page iii
PKE Reference Design User’s Manual
DS00000A-page iv © 2005 Microchip Technology Inc.
PKE REFERENCE DESIGNUSER’S MANUAL
Preface
INTRODUCTION
This chapter contains general information that will be useful to know before using the PKE Reference Design. Items discussed in this chapter include:
• Document Layout• Conventions Used in this Guide• Recommended Reading• The Microchip Web Site• Customer Support
DOCUMENT LAYOUT
This document describes a Passive Keyless Entry (PKE) system upgrade to an existing Remote Keyless Entry (RKE) application. The manual layout is as follows:
• Chapter 1. “System Overview” – Describes the PKE system upgrade to an existing Remote Keyless Entry (RKE) application overview.
• Chapter 2. “Low Frequency Initiator Module” – Describes the Low Frequency Magnetic Transmitter.
• Chapter 3. “PKE Transmitter-Transponder” – Describes the Remote Keyless Entry unit as a solution for Passive and RKE Keyless Entry applications.
• Chapter 4. “Remote Keyless Entry Receiver-Decoder Module” – Describes the Remote Keyless Entry Receiver-Decoder module as a target board for RKE and PKE message transmissions.
NOTICE TO CUSTOMERS
All documentation becomes dated, and this manual is no exception. Microchip tools and documentation are constantly evolving to meet customer needs, so some actual dialogs and/or tool descriptions may differ from those in this document. Please refer to our web site (www.microchip.com) to obtain the latest documentation available.
Documents are identified with a “DS” number. This number is located on the bottom of each page, in front of the page number. The numbering convention for the DS number is “DSXXXXXA”, where “XXXXX” is the document number and “A” is the revision level of the document.
For the most up-to-date information on development tools, see the MPLAB® IDE on-line help. Select the Help menu, and then Topics to open a list of available on-line help files.
© 2005 Microchip Technology Inc. DS00000A-page 1
PKE Reference Design User’s Manual
CONVENTIONS USED IN THIS GUIDE
This manual uses the following documentation conventions:
DOCUMENTATION CONVENTIONS
RECOMMENDED READING
It is recommended that you become familiar with the documents listed below, prior to using the PICDEM Mechatronics Demo Board.
PICkit™ 2 Microcontroller Programmer User’s Guide (DS51553)
Consult this document for instructions on how to use the PICkit 2 Microcontroller Programmer hardware and software.
Microchip Web Site
The Microchip web site (www.microchip.com) contains a wealth of documentation. Individual data sheets, application notes, tutorials and user’s guides are all available for easy download. All documentation is in Adobe® Acrobat® (pdf) format.
Please complete the enclosed Warranty Registration Card and mail it promptly. Sending in the Warranty Registration Card entitles users to receive new product updates. Interim software releases are available at the Microchip web site.
Description Represents Examples
Code (Courier font):
Plain characters Sample codeFilenames and paths
#define STARTc:\autoexec.bat
Angle brackets: < > Variables <label>, <exp>
Square brackets [ ] Optional arguments MPASMWIN [main.asm]
Curly brackets and pipe character: |
Choice of mutually exclusive argu-ments; An OR selection
errorlevel 0|1
Lowercase characters in quotes
Type of data “filename”
Ellipses... Used to imply (but not show) addi-tional text that is not relevant to the example
list [“list_option..., “list_option”]
0xnnn A hexadecimal number where n is a hexadecimal digit
0xFFFF, 0x007A
Italic characters A variable argument; it can be either a type of data (in lowercase characters) or a specific example (in uppercase characters).
char isascii (char, ch);
Interface (Arial font):
Underlined, italic text with right arrow
A menu selection from the menu bar File > Save
Bold characters A window or dialog button to click OK, Cancel
Characters in angle brackets < >
A key on the keyboard <Tab>, <Ctrl-C>
Documents (Arial font):
Italic characters Referenced books MPLAB® IDE User’s Guide
DS00000A-page 2 © 2005 Microchip Technology Inc.
Preface
THE MICROCHIP WEB SITE
Microchip provides online support via our web site at www.microchip.com. This web site is used as a means to make files and information easily available to customers. Accessible by using your favorite Internet browser, the web site contains the following information:
• Product Support – Data sheets and errata, application notes and sample programs, design resources, user’s guides and hardware support documents, latest software releases and archived software
• General Technical Support – Frequently Asked Questions (FAQs), technical support requests, online discussion groups, Microchip consultant program member listing
• Business of Microchip – Product selector and ordering guides, latest Microchip press releases, listing of seminars and events, listings of Microchip sales offices, distributors and factory representatives
CUSTOMER SUPPORT
Users of Microchip products can receive assistance through several channels:
• Distributor or Representative• Local Sales Office• Field Application Engineer (FAE)• Technical Support• Development Systems Information Line
Customers should contact their distributor, representative or field application engineer (FAE) for support. Local sales offices are also available to help customers. A listing of sales offices and locations is included in the back of this document.
Technical support is available through the web site at: http://support.microchip.com
© 2005 Microchip Technology Inc. DS00000A-page 3
PKE Reference Design User’s Manual
NOTES:
DS00000A-page 4 © 2005 Microchip Technology Inc.
PKE REFERENCE DESIGNUSER’S MANUAL
Chapter 1. System Overview
1.1 OVERVIEW
This manual describes a Passive Keyless Entry (PKE) system upgrade to an existing Remote Keyless Entry (RKE) application.
The key fob design contains a PIC16F639 with a integrated three-axis Analog Front-End (AFE).
The Low Frequency Initiator is implemented in a PIC18F2680.
This design has been optimized to integrate into an existing model platform without substantial modification. Operational flexibility is key to overall concept with many scalable features that can be customer, dealer, or factory end-of-line programmable.
FIGURE 1-1: PKE BLOCK DIAGRAM
LFInitiator
Trigger
KEYFOB
3-Axis
RF
Transmitter
Encoder
RKEReceiver
AFE
RFReceiver
Decoder
Drivers
Buttons
On-Vehicle
LIN LockActuator
© 2005 Microchip Technology Inc. DS00000A-page 5
PKE Reference Design User’s Manual
1.2 OPERATIONAL OVERVIEW
When the Low Frequency (LF) Initiator detects a trigger input a coded 125 kHz mes-sage is transmitted. Any transponder within range of this signal, receives this message and validates the coded data field. If the Initiator is recognized, a RF (432.92 MHz) KEELOQ® encoded message is transmitted. A standard Remote Keyless Entry receiver, decodes this packet and, if recognized, the appropriate action is taken.
To reduce current consumption, the LF Initiator does not poll for transponders continuously. A trigger event wakes the initiator from Sleep or Power-down (see Figure 1-1). The trigger input can be any type or source such as:
• Commanded over one of the networks.• Infra-red under door handle.• Simple microswitch activated by the door handle mechanism.• Capacitive detector sensing a change in a field by a hand approaching the handle.• Proximity detector.
The application described herein uses a microswitch input for simplicity.
The transponder key fob can operate as a regular push button RKE fob. When a valid LF field message is sensed, the microcontroller responds as if a sixth phantom button were pushed.
The RF Receiver/Decoder combination can include KEELOQ® compatible device. Typical devices are HCS500, HCS512 or HCS515. In the case of this design, a custom-programmed PICmicro® mid-range microcontroller is used.
1.3 FEATURES
1.3.1 LF Initiator
Refer to Microchip Application Note AN232 “Low Frequency Magnetic Transmitter Design” (DS00232). Features of the LF Initiator are as follows:
• Commanded by various types of inputs• Simple momentary switch• Proximity detector• Serial-numbered challenge• CAN and LIN Network network support
1.3.2 Key Fob
Refer to Microchip Application Note AN959 “Using the PIC16F639 MCU for Smart Wireless Applications” (DS00959). Features of the key fob are as follows:
• Functionally compatible with Microchip's HCS365 encoder• Supports up to five push button inputs• Two LED outputs for valid button and valid low-frequency challenge indication
1.3.3 RF Receiver
Refer to Microchip Application Note AN743 “Modular PICmicro® Mid-Range MCU CodeHopping Decoder” (DS00743). Features of the RF Receiver are as follows:
• Supports two manufacturer's codes• Compatible with Microchip's HCS200, HCS201, HCS300, HCS301, HCS360 and
HCS361 encoders• Automatic baud rate detection• Automatic Normal or Secure learn detection• Six learnable transmitters
DS00000A-page 6 © 2005 Microchip Technology Inc.
System Overview
1.4 REFERENCE DOCUMENTS
RF Receiver-Decoder
1. Telecontrolli Data Sheet, “DS.0016-9.pdf”2. “PIC12F635/PIC16F636/639 Data Sheet” (DS41232), Microchip Technology Inc.3. “PIC16F688 14-pin Flash-Based 8-Bit Data Sheet” (DS41203), Microchip
Technology Inc.4. “MCP201 LIN Transceiver with Voltage Regulator Data Sheet” (DS21730),
Microchip Technology Inc.5. “Modular PICmicro® Mid-Range MCU Code Hopping Decoder” Application Note
AN743 (DS00743), Microchip Technology Inc.
RKE/PKE Key Fob
1. “PIC12F635/PIC16F636/639 Data Sheet” (DS41232), Microchip Technology Inc.2. “Using the PIC16F639 MCU for Smart Wireless Applications” Application Note
AN959 (DS00959), Microchip Technology Inc.3. “HCS365 Data Sheet” (DS41109), Microchip Technology Inc.4. “Low Frequency Magnetic Transmitter Design” Application Note AN232
(DS00232), Microchip Technology Inc.
LF Initiator
1. “PIC18F2585/2680/4585/4680 Data Sheet” (DS39625), Microchip Technology Inc.
2. “TC4421/TC4422 9A High-Speed MOSFET Drivers Data Sheet” (DS21420), Microchip Technology Inc.
3. “Low Frequency Magnetic Transmitter Design” Application Note AN232 (DS00232), Microchip Technology Inc.
© 2005 Microchip Technology Inc. DS00000A-page 7
PKE Reference Design User’s Manual
NOTES:
DS00000A-page 8 © 2005 Microchip Technology Inc.
PKE REFERENCE DESIGNUSER’S MANUAL
Chapter 2. Low Frequency Initiator Module
2.1 INTRODUCTION
The LF transmitter is derived from the design described in Application Note AN232, ”Low Frequency Magnetic Transmitter Design” (DS00232).
2.2 HARDWARE
2.2.1 Microcontroller
A PIC18F2680 was selected for the LF controller based on the wide range of peripherals available on the chip. The PIC18F2680 has both a CAN controller and a LIN-compatible EAUSART to interface to in-vehicle networks. The Capture/Compare/PWM module lends itself to generation of the 125 kHz square wave needed as the LF carrier.
2.2.2 Configurable Inputs
Two 12V tolerant inputs are provided for triggers. Both of these PCB circuits can be reconfigured for a variety of inputs types. Refer to the schematic in Figure 2-1. For example, if one of the inputs is a momentary switch to ground:
1. Substitute a 0Ω resistor for R2.2. Remove R3 and D3.3. Replace D2 with a 30K resistor.
See Figure 2-1 for schematic details of the LF Initiator.
2.2.3 LF Transmitter
A high-current MOSFET driver (TC4422) is driven by the PWM output of the microcontroller, and in turn, drives the resonant tank circuit consisting of TX coil (L1) and C2. This output circuit generates a magnetic field with a voltage of up to 320V peak-to-peak.
2.2.4 Network Interfaces
Network connectivity is provided by a MCP201 LIN transceiver and a MCP2551 CAN transceiver.
2.2.5 Power
Power can be supplied through either J1 power jack, J3 CAN plug, or J4 LIN connection. Voltage should be in the range of 8-18 VDC. The automotive-grade voltage regulator is reverse-battery, transient and load-dump protected.
To reduce power consumption in key-off situations, the ‘power-on’ LED may be removed.
© 2005 Microchip Technology Inc. DS00000A-page 9
PKE Reference Design User’s Manual
FIGURE 2-1: SCHEMATIC — LOW FREQUENCY INITIATOR
PW
M
PW
M
VC
C
VC
C
VC
C
VC
C
+1
2V
DC
VC
C
VC
C
+12V
DC
VC
C+
12V
DC
40
0V
P3
47
6-N
D
Hig
h V
olt
ag
e
These tw
o input circuits a
re s
et-
up for
+12-t
o-G
ND
sig
nals
.
To input a +
5-t
o-0
sig
nal,
Rem
ove R
3 o
r R
6, R
epla
ce
R2 o
r R
4 w
ith1K
, a
nd
either
put a 1
0K
resis
tor
acro
ss D
2 -
D4 O
R e
nable
inte
rnal pull-
ups in the
mic
rocontr
olle
r
R6
15K
R6
15K
R1
01
20
R1
01
20
L2
DO
5022P
L2
DO
5022P
D3
1N
5819
D3
1N
5819
C7
0.1
uF
C7
0.1
uF
Y1
20.0
MH
z
Y1
20.0
MH
z
R5
1K
R5
1K
D5
1N
5819
D5
1N
5819
D8
10
MQ
10
0N
D8
10
MQ
10
0N
D7
10
MQ
10
0N
D7
10
MQ
10
0N
D2
1N
5819
D2
1N
5819
CA
NH
7
GN
D2
CA
NL
6
VC
C3
TX
D1
RX
D4
RE
F5
RS
8
U2 M
CP
2551
U2 M
CP
2551
C8
10nF
C8
10nF
LE
D2
YE
LLE
D2
YE
L
D4
1N
5819
D4
1N
5819
J1
J1
R8
4.7
KR
84
.7K
C4
20pF
C4
20pF
C5
1.0
uF
C5
1.0
uF
C9
0.2
00LS
C9
0.2
00LS
D6
1N
4148
D6
1N
4148
1 3 5
2 4 6
J4
CO
N6
AJ4
CO
N6
A
C3
20pF
C3
20pF
C10
0.2
00LS
C10
0.2
00LS
MC
LR
1
VC
C2
GN
D3
RB
74
RB
65
RB
36
J2
RJ11
J2
RJ11
IN1
OU
T3
GND2
VR
1LM
2937E
T-5
.0V
R1
LM
2937E
T-5
.0
C6
1.0
uF
C6
1.0
uF
1
TP
1T
P1
R7
30K
R7
30K
R2
25K
R2
25K
R1
1K
R1
1K
1 3 5
2 4 6
J3
CO
N6
AJ3
CO
N6
A
MC
LR
/Vpp
1
OS
C1/C
LK
IN9
OS
C2/C
LK
OU
T10
RA
0/A
N0
2
RA
1/A
N1
3
RA
2/A
N2/V
ref-
4
RA
3/A
N3/V
ref+
5
RA
4/T
0C
LI
6
RA
5/A
N4/S
S/L
VD
IN7
RB
0/I
NT
021
RB
1/I
NT
122
RB
2/C
AN
TX
23
RB
3/C
AN
RX
24
RB
425
RB
526
RB
627
RB
728
RC
0/T
1O
SO
/T1C
KI
11
RC
1/T
1O
SI
12
RC
2/C
CP
113
RC
3/S
CK
/SC
L14
RC
4/S
DI/
SD
A15
RC
5/S
DO
16
RC
6/T
X/C
K17
RC
7/R
X/D
T18
U1
PIC
18F
2680
U1
PIC
18F
2680
C1
10uF
C1
10uF
R4
25K
R4
25K
3 VDD
6 VDD
2GND
4GND
5O
UT
IN1
U4
TC
4422
U4
TC
4422
D1
10M
Q100N
D1
10M
Q100N
D9
1N
47
50
D9
1N
47
50
L1
10-0
0189
L1
10-0
0189
LIN
6
RX
1T
X4
CS
/WA
KE
2
GN
D5
VBAT7
VDD3
FA
ULT
/SL
PS
8
MC
P201
U3
MC
P201
U3
R3
15K
R3
15K
LE
D1
GR
NLE
D1
GR
N
C2
10uF
C2
10uF
R9
1K
R9
1K
DS00000A-page 10 © 2005 Microchip Technology Inc.
Low Frequency Initiator Module
2.3 SOFTWARE
The LF message shown in Figure 2-2 is transmitted when the trigger event is detected. As shown, the module will wait up to 50 ms after the challenge for a response from the RF Receiver module. This notification is sent over the LIN data line. If no response is received, the module will send the same message two more times, and then enter power-down awaiting another trigger.
FIGURE 2-2: LF CHALLENGE DATA FORMAT
The LF challenge message consists of a 125 kHz carrier modulated as follows:
1: A 4 ms ON to settle the receiving AGC:
2: 500 µs OFF.
3: 2 ms ON followed by a 2 ms OFF to enable the receiver output filter. This pattern is dependant on the configuration setting of the receiving AFE.
4: 16 least significant bits of the module serial number, PWM encoded (see Figure 2-3).
5: 50 ms OFF, waiting for a valid response from the RF receiver.
The challenge code portion of the message is to ensure that only previously learned transponders are hailed. All others will remain silent. This challenge code may be expanded or reduced by changes to the firmware to address individual application requirements. For this design, 16 bits were deemed sufficient.
FIGURE 2-3: CODE WORD DATA TRANSMISSION FORMAT (PWM)
Transmission Direction LSB First
Challenge Code Portion (16 Bits)
Least significant bits of Serial Number(16 Bits)
4 ms
125 kHz Base Frequency
UHF Response Slot Wake-Up 125 kHz Preamble
500
µS
2 ms 2 ms 50 msGuard Time
LOGIC ‘0’
LOGIC ‘1’
BitPeriod
© 2005 Microchip Technology Inc. DS00000A-page 11
PKE Reference Design User’s Manual
NOTES:
DS00000A-page 12 © 2005 Microchip Technology Inc.
PKE REFERENCE DESIGNUSER’S MANUAL
Chapter 3. PKE Transmitter-Transponder
3.1 INTRODUCTION
The Remote Keyless Entry unit is a complete solution for Passive and RKE Keyless Entry applications in a key fob type, form factor. The board was designed to accept a PIC16F636 or a PIC16F639 microcontroller. With minor modifications, it will also support a PIC12F635.
Some features of this design are:
• Up to five push button inputs• One or two LED outputs• 433.92 MHz transmitter• 3-axis Low Frequency receiver
3.2 HARDWARE
A PIC16F636, installed pin 1 justified at location U1, will support RKE applications. Since the PIC16F636 shares the same pinout as the PIC16F639 on its upper most pins, the only function lost is the on-chip Low Frequency Analog Front-End.
For PKE applications, a PIC16F639 and the associated low frequency receiver coils are installed.
The four buttons (S1-S4) on the transmitters are connected to the appropriate inputs on the microcontroller (S1-S4). The user may activate any combination of encoder inputs transmitting any of the 15 possible function codes. The RFEN output option is not used by the demonstration transmitter and should be disabled as this function shares its output with a button input. If RFEN is enabled, the button input will be lost. See Section 3.3 “Software”.
Button S5 is not directly mapped as a function code bit. The software associates this input with a user-defined code from EEPROM data memory to transmit.
The microcontroller Flash program and EEPROM data memory may be programmed through J1. This connector is pinout compatible with PICkit™ 1 and PICkit™ 2 pro-grammers. Microchip’s MPLAB ICD 2 may, alternatively, be used with an appropriately pinned cable (not supplied).
© 2005 Microchip Technology Inc. DS00000A-page 13
PKE Reference Design User’s Manual
TABLE 3-1: I/O CONNECTIONS
3.2.1 Transmitter
The RF oscillator uses a Surface Acoustic Wave (SAW) resonator to operate at 433.92 MHz.
The Programming Connector (J1) enables the transmitter’s direct connection to the programmer board for In-Circuit Serial Programming™ (ICSP™). The transmitter can therefore be re-configured or re-programmed without removing the microcontroller from the board.
FIGURE 3-1: J1 PROGRAMMING CONNECTOR
PORT Pin Function Notes
Inputs
RA0 Switch 5 ICSP Data
RA1 LF Data Input ICSP Clock
RA2 Switch 3
RA3 Switch 2 ICSP MCLR
RA4 Switch 1
RA5 Switch 4
Outputs
RC0 RF Active LED
RC4 LF Challenge LED
RC5 RF Data Out
Others
RC1 Internally connected on PIC16F639 not used on PIC16F636
RC2 Internally connected on PIC16F639 not used on PIC16F636
RC3 Internally and externally connected on PIC16F639 not used on PIC16F636
Note: This is not sufficient to ensure compliance with EC or FCC regulations.
123456
MCLR
VCC
ICSPDAT
no connection
VSS
ICSPCLK
DS00000A-page 14 © 2005 Microchip Technology Inc.
PKE Transmitter-Transponder
FIGURE 3-2: SCHEMATIC — RF RECEIVER/DECODER IN PIC16F636
CS
n
ICS
PC
LK
LF
DA
TA
ICS
PD
AT
LC
CO
MLX
LY
PW
M
SC
LK
/ALE
RT
LZ
VC
C
VC
C
VC
C
VC
C
VC
C
VB
AT
VB
AT
VC
C
VC
C
Un
lock
Lo
ck
Sh
ift
Ha
za
rd
Bo
ot
Active
Ch
alle
ng
e
Do
no
t a
sse
mb
le p
art
sw
ith
in d
ott
ed
bo
xe
sfo
r R
KE
-on
lya
pp
lica
tio
n.
Re
pla
ce
PIC
16
F6
39
with
PIC
16
F6
36
.
24
0p
F +
24
pF
220
R3
220
R3
220pF
CZ
1220pF
CZ
1
3V
/6V
BT
1
3V
/6V
BT
1
C12
1.0
uF
C12
1.0
uF
SW
2S
W2
7.1
mH
LY
1
7.1
mH
LY
1
10M
R9
10M
R9
C6
100nF
C6
100nF
R16
100k
R16
100k
NE
94433
Q1
NE
94433
Q1
D8
1N
4148W
SD
81N
4148W
S
9.0
mH
LX
2
9.0
mH
LX
2
R12
1K
R12
1K
100nF
C4
100nF
C4
SW
5S
W5
5.1
V
D2
5.1
V
D2
4GND
8GND
2 IN
1n
c3
nc
5n
c7
nc
6O
UT
433.9
2M
Hz S
AWU
2
433.9
2M
Hz S
AWU
2
470
R20
470
R20
264pF
CX
1264pF
CX
1
1.0
uF
C5
1.0
uF
C5
12pF
C3
12pF
C3
LE
D-R
ED
D4 L
ED
-RE
D
D4
0R8
0R8
LE
D-G
RN
D5
LE
D-G
RN
D5
47K
R2
47K
R2
1.0
uF
C11
1.0
uF
C11
SW
1S
W1
470
R19
470
R19
47
R1
47
R1
SW
3S
W3
SW
4S
W4
7.1
mH
LZ
1
7.1
mH
LZ
1
MA
2S
784
D1
MA
2S
784
D1
220pF
CY
1220pF
CY
1
+1
+3
+5
+2
+4
+6
J1
J1
Ante
nna
L1
Ante
nna
L1 4
70pF
C1
470pF
C1
RA
0/C
1IN
+1
9
RA
1/C
1IN
-1
8
RA
2/C
1O
UT
/IN
T1
7
RA
3/M
CL
R4
RA
4/O
SC
23
RA
5/O
SC
12
VD
DT
8
LC
X1
1
LC
Y1
0
LC
Z9
LC
CO
M1
2
RC
0/C
2IN
+1
6
RC
1/C
2IN
-1
5
RC
21
4
RC
37
RC
4/C
2O
UT
6
RC
55
VS
ST
13
VCC1
GND20
U3
PIC
16
F6
39
U3
PIC
16
F6
39
2.0
pF
C2
2.0
pF
C2
© 2005 Microchip Technology Inc. DS00000A-page 15
PKE Reference Design User’s Manual
3.3 SOFTWAREThe transponder firmware is functionally based on the Microchip HCS365 KEELOQ® encoder. See the “HCS365 Data Sheet” (DS41109) for more information. Additional routines have been added to initialize and interface to the internal LF Analog Front-End of the PIC16F639.
The transponder key fob operates as a standard 5-button RKE fob, when not being challenged by a Low Frequency Initiator signal. The microcontroller responds as if a sixth or a phantom button were pushed, when a valid LF field message is sensed and verified.
The Transponder will normally be in a low-power Sleep mode. When a switch input is taken low or a LF challenge is received, the device will wake-up and go through debounce delay of 20 ms before the switch value is latched. The device will then read the configuration options and depending on the configuration options, it will determine what the data and modulation format will be for the transmission. The transmission will consist of a stream of code words. The code words are transmitted after the button is pressed and as long as the buttons are held down or a time out occurs. The code word format can be either a code hopping format or a seed format.
The time-out time can be selected with the Time-out Select (TSEL) configuration option. This option allows the time out to be disabled or set to 0.8s, 3.2s or 25.6s. When a time out occurs, the device will go into Sleep mode to protect the battery from draining when a button gets stuck.
If during the transmit process, a new button is detected, the current code word will be aborted, a new code word will be transmitted and the time-out counter will reset. If all the buttons are released, a minimum number of code words will still be completed. The minimum code words can be set to 1, 2, 4 or 8 using the minimum code words (MTX) configuration option. If the time for transmitting the minimum code words is longer than the time-out time, the device will not complete the minimum code words.
A summary table of all the options is given in Section 3.3.3 “EEPROM Organization”.
The software includes four assemble-time conditional options. These options are enabled by removing the semi-colon in column 1 of the code line.
Select Processor, enable only one below:#DEFINE P12F635 1 ;Sets environment for PIC12F635#DEFINE P16F636 1 ;Sets environment for PIC16F636#DEFINE P16F639 1 ;Sets environment for PIC16F639
Select PORTA buttons to be connected to ground with internal pull-ups OR, connected to VCC with internal pull-downs:
#DEFINE pullup 1 ;Set to select pull-ups on PORT A.;For pull-downs, comment out.
Since the In-Circuit Emulator does not support Sleep:#DEFINE ICEmul 1 ;Is set, device will not SLEEP, but will
;loop forever
Select option not to Encrypt:
Note 1: The transponder is initially supplied pre-programmed with KEELOQ® encryption algorithm. The program and EEPROM data memory are read-protected.
2: The software source files supplied on the CD with this transponder has the KEELOQ® routines deleted. If a new hex file is assembled using these source files and programmed into the microcontroller, the original KEELOQ® code will be overwritten and lost.
3: Contact Microchip Technology for information about KEELOQ® and licensing options.
DS00000A-page 16 © 2005 Microchip Technology Inc.
PKE Transmitter-Transponder
#DEFINE NoEncryption 1
© 2005 Microchip Technology Inc. DS00000A-page 17
PKE Reference Design User’s Manual
FIGURE 3-3:FLOW CHART — DEVICE OPERATION
Start
Sample
Increment
Seed
Time Out?
Encrypt
No
No
Yes
Get Config
TX?
Counter
Transmit
MTX?
NoButtons?
SeedTime?
Read Seed
Stop
Yes
Yes
No
Yes
No
No
Yes
YesYes SeedButton?
No
NewButtons?
No
LF
No
YesData?
Receive
Valid
No
YesRequest?
Buttons
Challenge
DS00000A-page 18 © 2005 Microchip Technology Inc.
PKE Transmitter-Transponder
3.3.1 Dual Encoder Operation
The Transponder contains two transmitter Configuration Words, serial numbers, encoder keys, discrimination values, counters and seed values. This means that the Transponder can be used as two independent encoders. The code word is calculated using one of two possible encoder configurations. Most options for code word and modulation formats can be different from Encoder 1 and Encoder 2, but LED and RF transmitter options have to be the same. The Shift input pin is used to select between the encoder configurations. A low on the Shift pin will select Encoder 1 and a high will select Encoder 2.
3.3.2 Code Hopping Code Word Data Format
A code hopping code word consists of 32 bits of code hopping data, 32 bits of fixed code and between 3 and 5 bits of status information. Various code word formats are shown in Figure 3-4.
© 2005 Microchip Technology Inc. DS00000A-page 19
PKE Reference Design User’s Manual
FIGURE 3-4: CODE WORD DATA FORMAT
Fixed Code Portion (32 Bits)
CRC2 Bits
VLOW1-Bit
Serial Number(28 Bits)
C1 C0 S2 S1 S0 S3
BUT4 Bits
CounterOverflow
2 BitsDISC
10 Bits
Synchronization
16 BitsCounter
15 0
S1S2 S0 S3 OVR1 OVR0
Transmission Direction LSB First
Hopping Code Portion (32 Bits)
With XSER = 0, 16-bit Counter, QUEN = 0
Status Information(3 Bits)
BUT4 Bits
Fixed Code Portion (32 Bits)
QUE2 Bits
CRC2 Bits
VLOW1-Bit
Serial Number(32 Bits)
Q1 Q0 C1 C0
BUT4 Bits
CounterOverflow
2 BitsDISC
10 Bits
Synchronization
16 BitsCounter
15 0
S2 S1 S0 S3 OVR1 OVR0
Hopping Code Portion (32 Bits)
With XSER = 1, 16-bit Counter, QUEN = 1
Status Information(5 Bits)
Fixed Code Portion (32 Bits)
QUE2 Bits
CRC2 Bits
VLOW1-Bit
Serial Number(28 Bits)
Q1 Q0 C1 C0 S2 S1 S0 S3
BUT4 Bits
DISC8 Bits
Synchronization
20 BitsCounter
19 0
S2 S1 S0 S3
Hopping Code Portion (32 Bits)
With XSER = 0, 20-bit Counter, QUEN = 1
Status Information(5 Bits)
BUT4 Bits
Fixed Code Portion (32 Bits)
CRC2 Bits
VLOW1-Bit
Serial Number(32 Bits)
C1 C0
BUT4 Bits
DISC8 Bits
Synchronization
20 BitsCounter
19 0
S2 S1 S0 S3
Hopping Code Portion (32 Bits)
With XSER = 1, 20-bit Counter, QUEN = 0
Status Information(3 Bits)
DS00000A-page 20 © 2005 Microchip Technology Inc.
PKE Transmitter-Transponder
FIGURE 3-5: CODE WORD DATA FORMAT, NO ENCRYPTION
TABLE 3-2: FUNCTION CODES
Button Function
S0 F[xx1x]
S1 F[x1xx]
S2 F[1xxx]
S3 F[xxx1]
S4 User Programmable
LF Challenge User Programmable
Note 1: The function code is repeated in the encrypted and unencrypted data of a transmission.
Fixed Code Portion (64 Bits)
CRC2 Bits
VLOW1-Bit
Serial Number 1(28 Bits)
C1 C0 S2 S1 S0 S3
BUT4 Bits
S1S2 S0 S3
Transmission Direction LSB First
With XSER = 0, 16-bit Counter, QUEN = 0, S<3:0> not equal ‘0111’
Status Information(3 Bits)
BUT4 Bits
Serial Number 2(16 Bits)
Fixed Code Portion (64 Bits)
QUE2 Bits
CRC2 Bits
VLOW1-Bit
Serial Number(32 Bits)
Q1 Q0 C1 C0
BUT4 Bits
S2 S1 S0 S3
With XSER = 1, 16-bit Counter, QUEN = 1, S<3:0> not equal ‘0111’
Status Information(5 Bits)
USER14 Bits
USER08 Bits
Data 71h Data 72h
Serial Number 2(16 Bits)USER1
4 BitsUSER08 Bits
Data 71h Data 72h
Fixed Code Portion (64 Bits)
CRC2 Bits
VLOW1-Bit
Serial Number 1(28 Bits)
C1 C0 S2 S1 S0 S3
BUT4 Bits
S1S2 S0 S3
With XSER = 0, 16-bit Counter, QUEN = 0, S<3:0> equal ‘0111’
Status Information(3 Bits)
BUT4 Bits
Serial Number 2(32 Bits)
Fixed Code Portion (64 Bits)
QUE2 Bits
CRC2 Bits
VLOW1-Bit
Serial Number(32 Bits)
Q1 Q0 C1 C0
BUT4 Bits
S2 S1 S0 S3
With XSER = 1, 16-bit Counter, QUEN = 1, S<3:0> equal ‘0111’
Status Information(5 Bits)
Serial Number 2(32 Bits)
© 2005 Microchip Technology Inc. DS00000A-page 21
PKE Reference Design User’s Manual
3.3.3 EEPROM Organization
A summary of the Transponder EEPROM organization is shown in Tables 3-3, 3-4 and 3-5. The address column shows the starting address of the option and its length, or bit position. Options larger than 8 bits are stored with the MSB at the given address, and enough consecutive 8-bit blocks are reserved for the entire option size. Options such as SEED, which has a length that is not an exact multiple of 8 bits, are stored right justified in the reserved space, such that additional smaller options, like SDBT, may be stored in the same address as the MSB.
TABLE 3-3: ENCODER 1 (SHIFT = 0)
SymbolAddress
(Bits)Description(1)
KEY1 1E: 64 bits Encoder Key
SEED1 14: 60 bits Encoder Seed Value
SYNC1 00: 20 bits00: 18 bits
Encoder Synchronization Counter (CNTSEL=1)Encoder Synchronization Counter (CTNSEL = 0) plus overflow
SER1 10: 32 bits Encoder Serial Number
DISC1 1C: 10 bits Encoder Discrimination value
MSEL1 1C: ---- 3--2 Transmission ModulationFormat
Value Format
00b PWM
01b Manchester
10b VPWM
11b PPM
HSEL1 1C: ---4 ---- Header Select 4 TE = 0 10 TE = 1
XSER1 1C: --5- ---- Extended Serial Number 28 bits = 0 32 bits = 1
QUEN1 1C: -6-- ---- Queue counter Enable Disable = 0 Enable = 1
STEN1 1C: 7--- ---- Start/Stop Pulse Enable Disable = 0 Enable = 1
LEDBL1 3F: -6-- ---- Low Voltage LED Blink Never = 0 Once = 1
LEDOS1 3F: 7--- ---- LED On Time Select(1) 50 ms = 0 100 ms = 1
SDLM1 3C: ---- ---0 Limited Seed Disable = 0 Enable = 1
SDEN1 3C: ---- --1- Seed Enable Disable = 0 Enable = 1
SDMD1 00: 7--- ---- Seed Mode User = 0 Production = 1
SDBT1 14: 7654 ---- Seed Button Code
SDTM1 3C: ---- 32-- Time Before Seed code word(1)
Value Time (s)
00b 0.0
01b 0.8
10b 1.6
11b 3.2
BSEL1 3C: --54 ---- Transmission Baud Rate Select(1)
Value TE (µs)
00b 100
01b 200
10b 400
11b 800
GSEL1 3C: 76-- ---- Guard Time Select(1) Value Time (ms)
00b 0.0
01b 6.4
10b 51.2
11b 102.4
Note 1: All Timing values vary ±10%.2: Voltage thresholds are ±100mV.
DS00000A-page 22 © 2005 Microchip Technology Inc.
PKE Transmitter-Transponder
TABLE 3-4: ENCODER 2 (SHIFT = 1)
SymbolAddress
(Bits)Description(1)
KEY2 34: 64 bits Encoder Key
SEED2 2A: 60 bits Encoder Seed Value
SYNC2 08: 20 bits08: 18 bits
Encoder Synchronization Counter (CNTSEL = 1)Encoder Synchronization Counter (CTNSEL = 0) plus overflow
SER2 26: 32 bits Encoder Serial Number
DISC2 32: 10 bits Encoder Discrimination value
MSEL2 32: ---- 3--2 Transmission ModulationFormat
Value Format
00b PWM
01b Manchester
10b VPWM
11b PPM
HSEL2 32: ---4 ---- Header Select 4 TE = 0 10 TE = 1
XSER2 32: --5- ---- Extended Serial Number 28 bits = 0 32 bits = 1
QUEN2 32: -6-- ---- Queue counter Enable Disable = 0 Enable = 1
STEN2 32: 7--- ---- Start/Stop Pulse Enable Disable = 0 Enable = 1
LEDBL2 3D: -6-- ---- Low Voltage LED Blink Never = 0 Once = 1
LEDOS2 3D: 7--- ---- LED On Time Select(1) 50 ms = 0 100 ms = 1
SDLM2 3E: ---- ---0 Limited Seed Disable = 0 Enable = 1
SDEN2 3E: ---- --1- Seed Enable Disable = 0 Enable = 1
SDMD2 08: 7--- ---- Seed Mode User = 0 Production = 1
SDBT2 2A: 7654 ---- Seed Button Code
SDTM2 3E: ---- 32-- Time Before Seed code word(1)
Value Time (s)
00b 0.0
01b 0.8
10b 1.6
11b 3.2
BSEL2 3E: --54 ---- Transmission Baud Rate Select(1)
Value TE (µs)
00b 100
01b 200
10b 400
11b 800
GSEL2 3E: 76-- ---- Guard Time Select(1) Value Time (ms)
00b 0.0
01b 6.4
10b 51.2
11b 102.4
Note 1: All Timing values vary ±10%.2: Voltage thresholds are ±100mV.
© 2005 Microchip Technology Inc. DS00000A-page 23
PKE Reference Design User’s Manual
TABLE 3-5: DEVICE OPTIONS
SymbolAddress
(Bits)Description(1)
WAKE 3F: ---- --10 Wakeup(1) Value Value
00b No Wakeup
01b 75 ms 50%
10b 50 ms 33.3%
11b 100 ms 16.6%
CNTSEL 3F: ---- -2-- Counter Select 16 bits = 0 20 bits = 1
VLOWL 3F: ---- 3--- Low Voltage Latch Enable Disable = 0 Enable = 1
VLOWSEL 3F: ---4 ---- Low Voltage Trip Point Select(2)
2.2 V = 0 3.2V = 1
PLLSEL 3F: --5- ---- PLL Interface Select ASK = 0 FSK = 1
MTX 3D: ---- --10 Minimum code words Value Value
00b 1
01b 2
10b 4
11b 8
SLEEP 3D: ---- 3--- Sleep Output Enable Disable = 0 Enable = 1
WAIT 3D: ---- -2-- Wait for Step-Up Regulator Disable = 0 Enable = 1
TSEL 3D: --54 ---- Time-out Select(1) Value Time(s)
00b Disabled
01b 0.8
10b 3.2
11b 25.6
S4CODE 40: --54 32-- Switch 4 Button Code
S5CODE 41: --54 32-- Switch 5 Button Code
PKECODE 42: --54 32-- PKE Challenge Received Code
Note 1: All Timing values vary ±10%.2: Voltage thresholds are ±100 mV.
DS00000A-page 24 © 2005 Microchip Technology Inc.
PKE Transmitter-Transponder
NOTES:
© 2005 Microchip Technology Inc. DS00000A-page 25
PKE Reference Design User’s Manual
DS00000A-page 26 © 2005 Microchip Technology Inc.
PKE REFERENCE DESIGNUSER’S MANUAL
Chapter 4. Remote Keyless Entry Receiver-Decoder Module
4.1 INTRODUCTION
The Remote Keyless Entry Receiver-Decoder module serves as a target board for RKE and PKE message transmissions. Visual indications of function codes, as well as, in-vehicle network interface are included.
This module consists of a UHF receiver, microcontroller, power supply, LED indicators, and network physical interface.
FIGURE 4-1: RKE RECEIVER/DECODER
4.2 HARDWARE
4.2.1 UHF Receiver
The RF input is an AM super-regenerative compact hybrid module, which is used to capture undecoded data from an AM Transmitter. This module has very high frequency stability over a wide operating temperature and tolerant of mechanical vibrations or manual handling. A laser-trimmed on board inductor, removes the need for any adjustable components. Either 433.92 MHz or 315 MHz may be supplied with the board. A CMOS/TTL output supports data rates up to 2000 Hz. This input is connected to the microcontroller PORTA bit 2 INT pin. For more information on the receiver module, see Telecontrolli Data Sheet “DS.0016-9.pdf” for additional information.
4.2.2 Microcontroller
The microcontroller can be any one of the 14-pin PICmicro® family members, but is usually either a PIC16F636 or a PIC16F688. The PIC16F636 has an on-chip KEELOQ® encoder/decoder hardware, while the PIC16F688 has an Enhanced Addressable USART (EAUSART) that supports the Local Interconnect Network (LIN) and SAE J2602 protocol. In addition to the RF Data input described above, the following table shows the I/O port connections.
DataINRadio Rec.
Microcontroller
LEARN SW
Function LEDS
TransceiverBus
Network
LEARN LEDVLOW LED
© 2005 Microchip Technology Inc. DS00000A-page 27
Remote Keyless Entry Receiver-Decoder Module
TABLE 4-1: I/O CONNECTIONS
The microcontroller Flash program and EEPROM data memory may be programmed through J2. This connector is pinout compatible with PICkit™ 1 and PICkit™ 2 programmers. Microchip ICD2 may, alternatively, be used with an appropriately pinned cable (not supplied).
See the “PIC12F635/16F636/639 Data Sheet” (DS41232) or the “PIC16F688 Data Sheet” (DS41203) for additional information.
4.2.3 Network Interface
This section of the board may not be populated, depending upon the end application. If this section needs to be assembled, a complete bill of materials is available.
A MCP201 (or MCP202) LIN Bus Transceiver is used for the physical slave bus driver to connect to a LIN or J2602-compatible network. A Zener diode protects the LIN bus pin from transient voltages. The capacitor between the LIN bus pin and ground should have its value adjusted for the particular network topology. A large pull-up resistor on the FAULT/SLPS pin ensures that the device resets to a standard slope control profile.
See the “MCP201 LIN Transceiver with Voltage Regulator Data Sheet” (DS21730) for more information.
4.2.4 Power Supply
Power can be supplied to the board by way of either J3 (5.5 mm x 2.5 mm) power jack or through J1 (AMP 770969). Voltage should be in the range of 8-18 VDC. The automotive-grade voltage regulator is reverse-battery, transient and load-dump protected.
To reduce power consumption in key-off situations, the ‘power-on’ LED may be removed.
PORT Pin Function Notes
Inputs
RA0 Jumper E2 to GND, available to user ICSP Data
RA2 RF Data imput
RA3 LEARN push button input ICSP MCLR
Outputs
RA4 LEARN mode active LED
RA5 VLOW LED
RC0 S0 Function LED
RC1 S1 Function LED
RC2 S2 Function LED
RC3 S3 Function LED
Network Tranceiver
RA1 Chip Select output ICSP Clock
RC4 TX output
RC5 RX input
Note: When programming the module, remove Jumpers 1 and 2. Replace after verification.
© 2005 Microchip Technology Inc. DS00000A-page 28
Remote Keyless Entry Receiver-Decoder Module
4.2.5 Connectors
FIGURE 4-2: J1 SYSTEM CONNECTOR
FIGURE 4-3: J2 PROGRAMMING CONNECTOR
FIGURE 4-4: J3 POWER CONNECTOR
1
2
3
4
5
6
no connection
no connection
no connection
+12 VDC VBAT
LIN BI-Directional BUS
Chassis GND
123456
MCLR
VCC
ICSPDAT
no connection
VSS
ICSPCLK
+12 VDC VBATCHASSIS GND
© 2005 Microchip Technology Inc. DS00000A-page 29
Remote Keyless Entry Receiver-Decoder Module
FIGURE 4-5: SCHEMATIC — TRANSPONDER KEY FOB
LIN
bu
s
VC
C
VC
C VB
B
VC
C
VC
C
VB
B
VC
C
S0
S1
S3
S2
VL
OW
LE
AR
N
ON
Can b
e r
epla
ced w
ith P
IC16F
688 for
LIN
applic
ations
Can b
e r
epla
ced w
ith
MC
P202
or
-315
AM
P7
70
96
9
Not assem
ble
d w
ith P
IC16F
636
C4
.01
uF
C4
.01
uF
R4
1K
R4
1K
DS
4
LE
DDS
4
LE
D
R3
1K
R3
1K
+
C1
10
uF
+
C1
10
uF
R8
1K
R8
1K
DS
3
LE
DDS
3
LE
D
R1
1K
R1
1K
R6
1K
R6
1K
R2
10
KR
21
0K
D1
1N
40
04D
1
1N
40
04
LIN
6
RX
1T
X4
CS
/WA
KE
2
GN
D5
VBAT7
VDD3
FA
UL
T/S
LP
S8
MC
P201
U3
MC
P201
U3
AN
T1
AN
T1
S1
S1
+1
+3
+5
+2
+4
+6
J1
J1
R7
1K
R7
1K
D2
1N
47
55
43
V
D2
1N
47
55
43
V
+C
3
0.1
uF
+C
3
0.1
uF
R1
0
10
0K
R1
0
10
0K
1 2 3 4 5 6J2
J2
C6
22
0p
F
C6
22
0p
F
DS
2
LE
D
DS
2
LE
D1 2
E1
E1
DS
6
LE
D
DS
6
LE
D
DS
1
LE
D
DS
1
LE
D
D3
1N
47
50
27
V
D3
1N
47
50
27
V
R9
1K
R9
1K
LE
D1
Gre
en
LE
DL
ED
1G
ree
n L
ED
C5
1.0
uF
C5
1.0
uF
IN1
OU
T3
GND2
RE
G1
LM
29
37
IMP
-5.0
RE
G1
LM
29
37
IMP
-5.0
VCC1
GND2
ANT3
NC4
NC5
NC6
GND7
NC8
NC9
VCC10
GND11
VCC12
TEST13
OUT14
VCC15
U1
AM
RR
S3
-43
3
U1
AM
RR
S3
-43
3
1 2
E2
E2
DS
5
LE
DDS
5
LE
D
RA
5/O
SC
12
RA
4/O
SC
23
RA
3/M
CL
R4
RA
2/C
1O
UT
/IN
T1
1R
A1
/CIN
-1
2R
A0
/CIN
+1
3R
C0
/C2
IN+
10
RC
4/C
2O
UT
6
RC
55
RC
37
RC
1/C
2IN
-9
RC
28
U2
PIC
16F
636
U2
PIC
16F
636
+C
2
10
uF
+C
2
10
uF
R5
1K
R5
1K
J3
J3
© 2005 Microchip Technology Inc. DS00000A-page 30
Remote Keyless Entry Receiver-Decoder Module
4.3 SOFTWARE
The firmware is derived from Microchip Application Note AN743, “Modular PICmicro® Mid-Range MCU Code Hopping Decoder” (DS00743). Originally written for a PIC16CE624, the code has been ported to the PIC16F6XX family of devices.
The program implements a KEELOQ® code-hopping decoder. The software has been designed as a set of almost independent modules (standard assembly include files "*.INC"). For clarity and ease of maintenance, each module covers a single simple function and can be replaced to accommodate different behavior and/or support a different set of peripherals (memories, timers, etc.).
The set of modules presented in this application note implements the following features:
• Interrupt driven Radio Receiver (PWM) routine• Uses internal EEPROM memory to learn up to 16 transmitters• Supports Normal Learn mode• Compatible with all existing KEELOQ® hopping-code encoders with PWM
transmission format selected, operating in “medium mode” (Te = 200 µs)• Uses internal 8 MHz oscillator (self calibrating during receive)
4.3.1 Modules Overview
The code presented in this application note is composed of the following basic modules:
The software has been modified to include four assemble-time conditional options.
Select Processor, enable only one below:
#DEFINE P12F635 1 ;Sets environment for PIC12F635#DEFINE P16F636 1 ;Sets environment for PIC16F636
Select PORTA push buttons to be connected to ground with internal pull-ups OR, connected to VCC with internal pull-downs:
#DEFINE pullup 1 ;Set to select pull-ups on PORT A.;For pull-downs, comment out
Since the In-Circuit-Emulator can not properly handle Sleep.
#DEFINE ICEmul 1 ;Is set, device will not SLEEP, but will;loop forever
Select option not to Encrypt
#DEFINE NoEncryption 1
File Name Function
CHECKSN.ASM Substituted for KEELOQ® decryption files
FASTDEC.INC(1) KEELOQ® decrypt routine
KEYGEN.INC(1) KEELOQ® key generation routines implementing Normal Mode
MEM-63X.INC encapsulates PIC16F636 EEPROM drivers
MID.ASM the actual initialization and main loop
RXI.INC interrupt driven receiver
TABLE.INC transmitters table memory management (linear list)
Note 1: These files are not included in the general distribution set. They are avail-able on the KEELOQ® decoder license CD-ROM from Microchip, DS40148 .
© 2005 Microchip Technology Inc. DS00000A-page 31
Remote Keyless Entry Receiver-Decoder Module
FIGURE 4-6: MODULES OVERVIEW DIAGRAM
TMR0
RXI.INC
1st Buffer X
BFFULL Flag
Radio Rec
Receive Buffer CSR
MID.ASM
Main Loop
Interrupt
Learn
Out S0
Out S3
LED
VLOW
KEY64.Inc
Manufacturer Code
KEYGEN.INC
- Normal KEY GEN- Manufacturer Code Load
CheckSN.asm(1)
TABLE.INC
- Insert- Search
MEM-62X.INC
- RD Word- WR Word
EEPROM
KEELOQ(1)
FL62X.ASM
FASTDEC.INC
- Decrypt
-OR-
Note 1: Substitute for KEELOQ® decryption files.
© 2005 Microchip Technology Inc. DS00000A-page 32
Remote Keyless Entry Receiver-Decoder Module
FIGURE 4-7: CODE WORD DATA FORMAT
FIGURE 4-8: CODE WORD DATA FORMAT, NO ENCRYPTION
Fixed Code Portion (32 Bits)
CRC2 Bits
VLOW1-Bit
Serial Number(28 Bits)
C1 C0 S2 S1 S0 S3
BUT4 Bits
CounterOverflow
2 BitsDISC
10 Bits
Synchronization
16 BitsCounter
15 0
S1S2 S0 S3 OVR1 OVR0
Transmission Direction LSB First
Hopping Code Portion (32 Bits)
With XSER = 0, 16-bit Counter, QUEN = 0
Status Information(3 Bits)
BUT4 Bits
Fixed Code Portion (64 Bits)
CRC2 Bits
VLOW1-Bit
Serial Number 1(28 Bits)
C1 C0 S2 S1 S0 S3
BUT4 Bits
S1S2 S0 S3
Transmission Direction LSB First
With XSER = 0, 16-bit Counter, QUEN = 0, S<3:0> not equal ‘0111’
Status Information(3 Bits)
BUT4 Bits
Serial Number 2(16 Bits)USER1
4 BitsUSER08 Bits
Data 71h Data 72h
© 2005 Microchip Technology Inc. DS00000A-page 33
Remote Keyless Entry Receiver-Decoder Module
NOTES:
© 2005 Microchip Technology Inc. DS00000A-page 34
Remote Keyless Entry Receiver-Decoder Module
NOTES:
© 2005 Microchip Technology Inc. DS00000A-page 35
DS00000A-page 36 © 2005 Microchip Technology Inc.
AMERICASCorporate Office2355 West Chandler Blvd.Chandler, AZ 85224-6199Tel: 480-792-7200 Fax: 480-792-7277Technical Support: http://support.microchip.comWeb Address: www.microchip.com
AtlantaAlpharetta, GA Tel: 770-640-0034 Fax: 770-640-0307
BostonWestborough, MA Tel: 774-760-0087 Fax: 774-760-0088
ChicagoItasca, IL Tel: 630-285-0071 Fax: 630-285-0075
DallasAddison, TX Tel: 972-818-7423 Fax: 972-818-2924
DetroitFarmington Hills, MI Tel: 248-538-2250Fax: 248-538-2260
KokomoKokomo, IN Tel: 765-864-8360Fax: 765-864-8387
Los AngelesMission Viejo, CA Tel: 949-462-9523 Fax: 949-462-9608
San JoseMountain View, CA Tel: 650-215-1444Fax: 650-961-0286
TorontoMississauga, Ontario, CanadaTel: 905-673-0699 Fax: 905-673-6509
ASIA/PACIFICAustralia - SydneyTel: 61-2-9868-6733 Fax: 61-2-9868-6755
China - BeijingTel: 86-10-8528-2100 Fax: 86-10-8528-2104
China - ChengduTel: 86-28-8676-6200 Fax: 86-28-8676-6599
China - FuzhouTel: 86-591-8750-3506 Fax: 86-591-8750-3521
China - Hong Kong SARTel: 852-2401-1200 Fax: 852-2401-3431
China - QingdaoTel: 86-532-502-7355 Fax: 86-532-502-7205
China - ShanghaiTel: 86-21-5407-5533 Fax: 86-21-5407-5066China - ShenyangTel: 86-24-2334-2829Fax: 86-24-2334-2393
China - ShenzhenTel: 86-755-8203-2660 Fax: 86-755-8203-1760
China - ShundeTel: 86-757-2839-5507 Fax: 86-757-2839-5571
China - WuhanTel: 86-27-5980-5300Fax: 86-27-5980-5118
China - XianTel: 86-29-8833-7250Fax: 86-29-8833-7256
ASIA/PACIFICIndia - BangaloreTel: 91-80-2229-0061 Fax: 91-80-2229-0062
India - New DelhiTel: 91-11-5160-8631Fax: 91-11-5160-8632
India - PuneTel: 91-20-2566-1512Fax: 91-20-2566-1513
Japan - YokohamaTel: 81-45-471- 6166 Fax: 81-45-471-6122
Korea - SeoulTel: 82-2-554-7200 Fax: 82-2-558-5932 or 82-2-558-5934
Malaysia - PenangTel: 604-646-8870Fax: 604-646-5086
Philippines - ManilaTel: 011-632-634-9065Fax: 011-632-634-9069
SingaporeTel: 65-6334-8870 Fax: 65-6334-8850
Taiwan - HsinchuTel: 886-3-572-9526Fax: 886-3-572-6459
Taiwan - KaohsiungTel: 886-7-536-4818Fax: 886-7-536-4803
Taiwan - TaipeiTel: 886-2-2500-6610 Fax: 886-2-2508-0102
Thailand - BangkokTel: 66-2-694-1351Fax: 66-2-694-1350
EUROPEAustria - WeisTel: 43-7242-2244-399Fax: 43-7242-2244-393Denmark - CopenhagenTel: 45-4450-2828 Fax: 45-4485-2829
France - ParisTel: 33-1-69-53-63-20 Fax: 33-1-69-30-90-79
Germany - MunichTel: 49-89-627-144-0 Fax: 49-89-627-144-44
Italy - Milan Tel: 39-0331-742611 Fax: 39-0331-466781
Netherlands - DrunenTel: 31-416-690399 Fax: 31-416-690340
Spain - MadridTel: 34-91-352-30-52Fax: 34-91-352-11-47
UK - WokinghamTel: 44-118-921-5869Fax: 44-118-921-5820
WORLDWIDE SALES AND SERVICE
07/01/05