You are on page 1of 37

Passive Keyless Entry (PKE)

Reference Design
User’s Manual

© 2006 Microchip Technology Inc. DS21986A


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 our
products. Attempts to break Microchip’s code protection feature may be a violation of the Digital Millennium Copyright Act. If such acts
allow 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 device Trademarks


applications and the like is provided only for your convenience The Microchip name and logo, the Microchip logo, Accuron,
and may be superseded by updates. It is your responsibility to dsPIC, KEELOQ, microID, MPLAB, PIC, PICmicro, PICSTART,
ensure that your application meets with your specifications.
PRO MATE, PowerSmart, rfPIC and SmartShunt are
MICROCHIP MAKES NO REPRESENTATIONS OR WAR-
registered trademarks of Microchip Technology Incorporated
RANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED,
in the U.S.A. and other countries.
WRITTEN OR ORAL, STATUTORY OR OTHERWISE,
RELATED TO THE INFORMATION, INCLUDING BUT NOT AmpLab, FilterLab, Migratable Memory, MXDEV, MXLAB,
LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, SEEVAL, SmartSensor and The Embedded Control Solutions
MERCHANTABILITY OR FITNESS FOR PURPOSE. Company are registered trademarks of Microchip Technology
Microchip disclaims all liability arising from this information and Incorporated in the U.S.A.
its use. Use of Microchip devices in life support and/or safety Analog-for-the-Digital Age, Application Maestro, dsPICDEM,
applications is entirely at the buyer’s risk, and the buyer agrees dsPICDEM.net, dsPICworks, ECAN, ECONOMONITOR,
to defend, indemnify and hold harmless Microchip from any and FanSense, FlexROM, fuzzyLAB, In-Circuit Serial
all damages, claims, suits, or expenses resulting from such Programming, ICSP, ICEPIC, Linear Active Thermistor,
use. No licenses are conveyed, implicitly or otherwise, under MPASM, MPLIB, MPLINK, MPSIM, PICkit, PICDEM,
any Microchip intellectual property rights. PICDEM.net, PICLAB, PICtail, PowerCal, PowerInfo,
PowerMate, PowerTool, Real ICE, rfLAB, rfPICDEM, Select
Mode, Smart Serial, SmartTel, Total Endurance, UNI/O,
WiperLock and Zena 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.
© 2006, Microchip Technology Incorporated, Printed in the
U.S.A., All Rights Reserved.
Printed on recycled paper.

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.

DS21986A-page ii © 2006 Microchip Technology Inc.


PKE REFERENCE DESIGN
USER’S MANUAL

Table of Contents
Preface ........................................................................................................................... 1
Chapter 1. System Overview
1.1 Overview ........................................................................................................ 6
1.2 Operational Overview ..................................................................................... 7
1.3 Features ......................................................................................................... 7
1.3.1 LF Initiator ................................................................................................... 7
1.3.2 Key Fob ....................................................................................................... 7
1.3.3 RF Receiver ................................................................................................ 8
1.4 Reference Documents .................................................................................... 8
Chapter 2. Low-Frequency Initiator Module
2.1 Introduction ................................................................................................... 10
2.2 Hardware ...................................................................................................... 10
2.2.1 Microcontroller ........................................................................................... 10
2.2.2 Configurable Inputs ................................................................................... 10
2.2.3 LF Transmitter ........................................................................................... 10
2.2.4 Network Interfaces .................................................................................... 10
2.2.5 Power ........................................................................................................ 10
2.3 Software ....................................................................................................... 12
Chapter 3. PKE Transmitter-Transponder
3.1 Introduction ................................................................................................... 14
3.2 Hardware ...................................................................................................... 14
3.2.1 Transmitter ................................................................................................ 15
3.3 Software ....................................................................................................... 17
3.3.1 Dual Encoder Operation ............................................................................ 20
3.3.2 Code Hopping Code Word Data Format ................................................... 20
3.3.3 EEPROM Organization ............................................................................. 23
Chapter 4. Remote Keyless Entry Receiver-Decoder Module
4.1 Introduction ................................................................................................... 26
4.2 Hardware ...................................................................................................... 26
4.2.1 UHF Receiver ............................................................................................ 26
4.2.2 Microcontroller ........................................................................................... 26
4.2.3 Network Interface ...................................................................................... 27
4.2.4 Power Supply ............................................................................................ 27
4.2.5 Connectors ................................................................................................ 28
4.3 Software ....................................................................................................... 30
4.3.1 Modules Overview ..................................................................................... 30
Worldwide Sales and Service .................................................................................... 33

© 2006 Microchip Technology Inc. DS21986A-page iii


PKE Reference Design User’s Manual
NOTES:

DS21986A-page iv © 2006 Microchip Technology Inc.


PKE REFERENCE DESIGN
USER’S MANUAL

Preface

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.

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.

© 2006 Microchip Technology Inc. DS21986A-page 1


Preface

CONVENTIONS USED IN THIS GUIDE


This manual uses the following documentation conventions:

DOCUMENTATION CONVENTIONS
Description Represents Examples
Code (Courier font):
Plain characters Sample code #define START
Filenames and paths c:\autoexec.bat
Angle brackets: < > Variables <label>, <exp>
Square brackets [ ] Optional arguments MPASMWIN [main.asm]
Curly brackets and pipe Choice of mutually exclusive argu- errorlevel {0|1}
character: { | } ments; An OR selection
Lowercase characters in Type of data “filename”
quotes
Ellipses... Used to imply (but not show) addi- list
tional text that is not relevant to the [“list_option...,
example “list_option”]
0xnnn A hexadecimal number where n is a 0xFFFF, 0x007A
hexadecimal digit
Italic characters A variable argument; it can be either a char isascii (char,
type of data (in lowercase characters) ch);
or a specific example (in uppercase
characters).
Interface (Arial font):
Underlined, italic text A menu selection from the menu bar File > Save
with right arrow
Bold characters A window or dialog button to click OK, Cancel
Characters in angle A key on the keyboard <Tab>, <Ctrl-C>
brackets < >
Documents (Arial font):
Italic characters Referenced books MPLAB® IDE User’s Guide

RECOMMENDED READING
It is recommended that you become familiar with the documents listed below, prior to
using the PKE Reference Design Kit.
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.
AMHRRQ3-433 Telecontrolli Data Sheet (DS.0015-1.pdf)
AMHRR3-433 Telecontrolli Data Sheet (DS.0016-9.pdf)
PIC12F635/PIC16F636/639 Data Sheet (DS41232)
Data sheet for the PIC12F635/PIC16F636/639 8/14-pin Flash-based, 8-bit CMOS
microcontrollers with nanoWatt technology.
PIC16F688 Data Sheet (DS41203)
Data sheet for the PIC16F688 14-pin Flash-based 8-bit CMOS microcontrollers with
nanoWatt technology.

© 2006 Microchip Technology Inc. DS21986A-page 2


PKE Reference Design User’s Manual
MCP201 LIN Transceiver with Voltage Regulator Data Sheet (DS21730)
Data sheet for the MCP201 LIN transceiver. Gives an overview of the device including
modes of operation and electrical characteristics.
Modular PICmicro® Mid-Range MCU Code Hopping Decoder Application Note
AN742 (DS00742)
Application note describes a KEELOQ code hopping decoder implemented on a
Microchip mid-range PICmicro microcontroller.
Using the PIC16F639 MCU for Smart Wireless Applications Application Note
AN959 (DS00959)
Application note describing the PIC16F639 as a suitable microcontroller for
bidirectional communications and low-frequency sensing applications.
HCS365 Data Sheet (DS41109)
Data sheet for the HCS365 KEELOQ code hopping encoder.
Low-Frequency Magnetic Transmitter Design Application Note AN232 (DS00232
Application note covering the basic aspects to consider when designing the transmitter
portion of a LFMC link.
PIC18F2585/2680/4585/4680 Data Sheet (DS39625)
Data sheet for the PIC18F2585/2680/4585/4680 28/40/44-pin enhanced Flash
microcontrollers with ECAN™ technology, 10-bit A/D and nanoWatt technology.
TC4421/TC4422 9A High-Speed MOSFET Drivers Data Sheet (DS21420)
Data sheet for the TC4421/TC4422 9A High-Speed MOSFET Driver. Gives an
overview of the device including electrical characteristics.

DS21986A-page 3 © 2006 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 Guide, 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

© 2006 Microchip Technology Inc. DS21986A-page 4


PKE Reference Design User’s Manual
NOTES:

DS21986A-page 5 © 2006 Microchip Technology Inc.


PKE REFERENCE DESIGN
USER’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 the key to the overall concept with
many scalable features that are end-of-line programmable by customer, dealer or
factory.

FIGURE 1-1: PKE BLOCK DIAGRAM

RF
Transmitter

Encoder
KEY
FOB

Buttons 434 MHz

3-Axis
AFE

Trigger

RF Decoder
125 kHz Receiver
LF LIN Lock
Initiator RKE Drivers
Actuator
Receiver
On-Vehicle

© 2006 Microchip Technology Inc. DS21986A-page 6


PKE Reference Design User’s Manual

1.2 OPERATIONAL OVERVIEW


When the Low-Frequency (LF) Initiator detects a trigger input, a coded 125 kHz
message 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
(433.92 MHz) KEELOQ® encoded message is transmitted. A standard RKE 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 proximity detector sensing a change in a field by a hand approaching
the handle
The application described herein uses a microswitch input for simplicity. As delivered,
the LF initiator will continuously poll for the transponder. This is to facilitate orientation
and range evaluation.
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 and transmits a unique function code.
The RF Receiver/Decoder combination can include a KEELOQ Security IC. Typical
decoders are the HCS500, HCS512 or HCS515. In the case of this design, a
custom-programmed PICmicro® mid-range microcontroller was 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 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

DS21986A-page 7 © 2006 Microchip Technology Inc.


System Overview

1.3.3 RF Receiver
Refer to Microchip Application Note AN742 “Modular PICmicro® Mid-Range MCU Code
Hopping Decoder” (DS00742). 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

1.4 REFERENCE DOCUMENTS


RF Receiver-Decoder
1. “AMHRRQ3-433” Telecontrolli Data Sheet, “DS.0015-1.pdf”
2. “AMHRR3-433” Telecontrolli Data Sheet, “DS.0016-9.pdf”
3. “PIC12F635/PIC16F636/639 Data Sheet” (DS41232), Microchip Technology Inc.
4. “PIC16F688 14-pin Flash-Based 8-Bit Data Sheet” (DS41203), Microchip
Technology Inc.
5. “MCP201 LIN Transceiver with Voltage Regulator Data Sheet” (DS21730),
Microchip Technology Inc.
6. “Modular PICmicro® Mid-Range MCU Code Hopping Decoder”, Application Note
AN742 (DS00742), 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.

© 2006 Microchip Technology Inc. DS21986A-page 8


PKE Reference Design User’s Manual
NOTES:

DS21986A-page 9 © 2006 Microchip Technology Inc.


PKE REFERENCE DESIGN
USER’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 input 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.

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.

© 2006 Microchip Technology Inc. DS21986A-page 10


VR1
LM2937ET-5.0
D1 These two input circuits are set-up for +12-to-GND signals.
1 3
+12 VDC IN OUT VCC To input a +5-to-0 signal, remove R3 or R6,
10MQ100N R1 1K replace R2 or R4 with 1K, and either put a 10K
resistor across D2-D4 OR enable internal pull-ups
FIGURE 2-1:

GND
C1 C2 in the microcontroller.

DS21986A-page 11
10 μF 10 μF
J1
LED1 GRN
1N5819 D2 VCC
25K R2
MCLR 1
J2 2 1N5819 D3 15K R3
VCC VCC
GND 3
RJ11 4
RB7
RB6 5 VCC
6 1N5819 D4
RB3 25K R4
1K R5 YEL LED2
VCC 1N5819 D5 15K R6
R10 120
R7 30K D6 1N4148 +12 VDC
VCC U1 U2
1 21 4 6 J3
C3 20 pF MCLR/VPP RB0/INT0 RXD CANL
22 1 7
RB1/INT1 TXD CANH 2 1
9 23
OSC1/CLKIN RB2/CANTX 4 3
24 2 5
Y1 RB3/CANRX GND REF 6 5
25 3 8
RB4 VCC RS
20.0 MHz 26 CON6A
RB5 VCC R8 4.7K
10 27 MCP2551
OSC2/CLKOUT PIC18F2680 RB6
28
C4 20 pF RB7
J4
11 C6 D7 10MQ100N
RC0/T1OSO/T1CKI C5 1.0 uF 2 1
12
RC1/T1OSI PWM 1.0 uF 4 3
2 13
RA0/AN0 RC2/CCP1 D8 10MQ100N 6 5
3 14
3
7

RA1/AN1 RC3/SCK/SCL
4 15 CON6A
RA2/AN2/VREF- RC4/SDI/SDA
5 16
RA3/AN3/VREF+ RC5/SDO D9 1N4750
6 17
VD D

RA4/T0CLI RC6/TX/CK
VBAT

R9 1K
SCHEMATIC – LOW-FREQUENCY INITIATOR

7 18
RA5/AN4/SS/LVDIN RC7/RX/DT
2
CS/WAKE
4 6
TX LIN
PKE Reference Design User’s Manual

+12 VDC 1
RX
8
C7 FAULT/SLPS
5

3
6
0.1 uF U4 GND
High Voltage
MCP201 U3
TP1

VD D
L1

1
1 5
IN OUT
PWM
10-00189 C8 C9 C10

GND VD D
GND
L2 10 nF
400V
P3476-ND

2
4
TC4422 DO5022P 0.200LS 0.200LS

© 2006 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

125 kHz Base Frequency

UHF Response Slot Challenge Code Portion (16 Bits) Wake-Up 125 kHz Preamble

500 μs
50 ms Least Significant bits of Serial Number 2 ms 2 ms 4 ms
Guard Time (16 Bits)

Transmission Direction LSb First

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 (LSb) 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)

LOGIC ‘0’

LOGIC ‘1’

Bit
Period

© 2006 Microchip Technology Inc. DS21986A-page 12


PKE Reference Design User’s Manual
NOTES:

DS21986A-page 13 © 2006 Microchip Technology Inc.


PKE REFERENCE DESIGN
USER’S MANUAL

Chapter 3. PKE Transmitter-Transponder


3.1 INTRODUCTION
The RKE Key Fob unit is a complete solution for PKE and RKE 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 associated with a specific function code bit, but rather transmits
a user-defined function code stored in EEPROM data memory.
The microcontroller Flash program and EEPROM data memory may be
programmed through J1. This connector is pinout compatible with PICkit™ 1 and
PICkit™ 2 programmers.

© 2006 Microchip Technology Inc. DS21986A-page 14


PKE Reference Design User’s Manual
TABLE 3-1: I/O CONNECTIONS
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

3.2.1 Transmitter
The RF oscillator uses a Surface Acoustic Wave (SAW) resonator that operates at
433.92 MHz.

Note: The design and layout of this transmitter is not sufficient to ensure
compliance with EC or FCC regulations.

The Programming Connector (J1) enables 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

MCLR 1
VCC 2
VSS 3
ICSPDAT 4
ICSPCLK 5
no connection 6

DS21986A-page 15 © 2006 Microchip Technology Inc.


SW4
D1 MA2S784
SW1
Unlock
VBAT VCC
1N4148WS D8 R16 100k SW2
Lock BT1 D2
FIGURE 3-2:

C4 5.1V C5
VCC Hazard 100 nF 1.0 uF
SW3 3V/6V

SW5
Shift
Boot

© 2006 Microchip Technology Inc.


R12 1K

C6 100 nF Active
VCC
VCC LED-GRN
J1

1
U3
1 2 D5 R20 470
+ +
3 4 ICSPDAT 19 16
+ + RA0/C1IN+ RC0/C2IN+ VCC
CSn

VCC
5 6 18 15
+ + RA1/C1IN- RC1/C2IN-
17 14 SCLK/ALERT
RA2/C1OUT/INT RC2
ICSPCLK 4 7 LFDATA R19 470
RA3/MCLR RC3
3 6
RA4/OSC2 RC4/C2OUT VCC
2 5 PWM D4
RA5/OSC1 RC5
PIC16F639 LED-RED
VCC 8 13 Challenge
VDDT VSST
11
LCX
C12 10
LCY
9
LCZ
1.0 uF 12 R2 47K
LCCOM

GND
Q1 C2 L1
NE94433 2.0 pF Antenna
2

20
IN

U2 1 nc R1 47
LCCOM 3 nc
6
VBAT
LX 433.92 MHz SAW 5 nc OUT

LZ
LY 7 nc
R3
R8 220 C3 C1
GND
GND

0 12 pF 470 pF
4
8

LZ1 LY1 LX2


7.1 mH CZ1 7.1 mH CY1 9.0 mH CX1
220 pF 220 pF 264 pF
SCHEMATIC – RF RECEIVER/DECODER USING THE PIC16F639

Do not assemble parts 240 pF + 24 pF


within dotted boxes R9
C11
for RKE-only 10M 1.0 uF
application. Replace
PIC16F639 with
PIC16F636.

DS21986A-page 16
PKE Transmitter-Transponder
PKE Reference Design User’s Manual

3.3 SOFTWARE
The 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 low-frequency
analog front-end of the PIC16F639.

Note 1: The transponder is initially supplied pre-programmed with the KEELOQ


encryption algorithm. The program memory and EEPROM data memory are
read-protected.
2: The software source files supplied on the CD with this transponder have
the KEELOQ encryption routines deleted. If a new hex file is assembled
using these source files and programmed into the microcontroller, the
original KEELOQ hopping code will be overwritten and lost.
3: Contact Microchip Technology for information about KEELOQ Security ICs
and licensing options.
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”.

DS21986A-page 17 © 2006 Microchip Technology Inc.


PKE Transmitter-Transponder
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:
#DEFINE NoEncryption 1

© 2006 Microchip Technology Inc. DS21986A-page 18


PKE Reference Design User’s Manual
FIGURE 3-3: FLOWCHART – DEVICE OPERATION

Start

Sample
Buttons

Receive
Get Config Challenge

LF Yes Valid Yes


Data? Request?

No No

Seed Yes
Read Seed
TX?

No

Increment
Counter

Encrypt

Transmit

Yes
Time Out?

No

No
MTX? Stop

Yes

No Yes
Buttons?

No

Seed Yes Seed Yes


Time? Button?

No No

No New
Buttons?

Yes

DS21986A-page 19 © 2006 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 for KEELOQ encoder compatible transmissions.

© 2006 Microchip Technology Inc. DS21986A-page 20


PKE Reference Design User’s Manual
FIGURE 3-4: CODE WORD DATA FORMAT
With XSER = 0, 16-bit Counter, QUEN = 0

Status Information Fixed Code Portion (32 Bits) Hopping Code Portion (32 Bits)
(3 Bits)
Synchronization
Counter
Counter
CRC VLOW BUT Serial Number BUT Overflow DISC 16 Bits
2 Bits 1 Bit 4 Bits (28 Bits) 4 Bits 2 Bits 10 Bits 15 0

C1 C0 S2 S1 S0 S3 S2 S1 S0 S3 OVR1 OVR0

With XSER = 1, 16-bit Counter, QUEN = 1

Status Information Fixed Code Portion (32 Bits) Hopping Code Portion (32 Bits)
(5 Bits)
Synchronization
Counter
Counter
QUE CRC VLOW Serial Number BUT Overflow DISC 16 Bits
2 Bits 2 Bits 1 Bit (32 Bits) 4 Bits 2 Bits 10 Bits 15 0

Q1 Q0 C1 C0 S2 S1 S0 S3 OVR1 OVR0

With XSER = 0, 20-bit Counter, QUEN = 1

Status Information Fixed Code Portion (32 Bits) Hopping Code Portion (32 Bits)
(5 Bits)
Synchronization
Counter
QUE CRC VLOW BUT Serial Number BUT DISC 20 Bits
2 Bits 2 Bits 1 Bit 4 Bits (28 Bits) 4 Bits 8 Bits 19 0

Q1 Q0 C1 C0 S2 S1 S0 S3 S2 S1 S0 S3

With XSER = 1, 20-bit Counter, QUEN = 0

Status Information Fixed Code Portion (32 Bits) Hopping Code Portion (32 Bits)
(3 Bits)
Synchronization
Counter
CRC VLOW Serial Number BUT DISC 20 Bits
2 Bits 1 Bit (32 Bits) 4 Bits 8 Bits 19 0

C1 C0 S2 S1 S0 S3

Transmission Direction LSb First

DS21986A-page 21 © 2006 Microchip Technology Inc.


PKE Transmitter-Transponder
FIGURE 3-5: CODE WORD DATA FORMAT, NO ENCRYPTION
With XSER = 0, 16-bit Counter, QUEN = 0, S<3:0> not equal ‘0111’

Status Information Fixed Code Portion (64 Bits)


(3 Bits)
Serial Number 1 Serial Number 2
CRC VLOW BUT (28 Bits) BUT USER1 USER0 (16 Bits)
2 Bits 1 Bit 4 Bits 4 Bits 4 Bits 8 Bits

C1 C0 S2 S1 S0 S3 S2 S1 S0 S3 Data 71h Data 72h

With XSER = 1, 16-bit Counter, QUEN = 1, S<3:0> not equal ‘0111’

Status Information Fixed Code Portion (64 Bits)


(5 Bits)
Serial Number 2
QUE CRC VLOW Serial Number BUT USER1 USER0 (16 Bits)
2 Bits 2 Bits 1 Bit (32 Bits) 4 Bits 4 Bits 8 Bits

Q1 Q0 C1 C0 S2 S1 S0 S3 Data 71h Data 72h

With XSER = 0, 16-bit Counter, QUEN = 0, S<3:0> equal ‘0111’

Status Information Fixed Code Portion (64 Bits)


(3 Bits)
Serial Number 1 Serial Number 2
CRC VLOW BUT (28 Bits) BUT (32 Bits)
2 Bits 1 Bit 4 Bits 4 Bits

C1 C0 S2 S1 S0 S3 S2 S1 S0 S3

With XSER = 1, 16-bit Counter, QUEN = 1, S<3:0> equal ‘0111’

Status Information Fixed Code Portion (64 Bits)


(5 Bits)

Serial Number Serial Number 2


QUE CRC VLOW (32 Bits) BUT (32 Bits)
2 Bits 2 Bits 1 Bit 4 Bits

Q1 Q0 C1 C0 S2 S1 S0 S3

Transmission Direction LSb First

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.

© 2006 Microchip Technology Inc. DS21986A-page 22


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)


Address
Symbol Description(1)
(Bits)
KEY1 1E: 64 bits Encoder Key
SEED1 14: 60 bits Encoder Seed Value
SYNC1 00: 20 bits Encoder Synchronization Counter (CNTSEL=1)
00: 18 bits 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 Modulation Value Format
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 Value Time (s)
Word(1) 00b 0.0
01b 0.8
10b 1.6
11b 3.2
BSEL1 3C: --54 ---- Transmission Baud Rate Value TE (μs)
Select(1) 00b 100
01b 200
10b 400
11b 800
(1)
GSEL1 3C: 76-- ---- Guard Time Select Value Time (ms)
00b 0.0
01b 6.4
10b 51.2
11b 102.4
Note 1: All Timing values vary ±10%.

DS21986A-page 23 © 2006 Microchip Technology Inc.


PKE Transmitter-Transponder
TABLE 3-4: ENCODER 2 (SHIFT = 1)
Address
Symbol Description(1)
(Bits)
KEY2 34: 64 bits Encoder Key
SEED2 2A: 60 bits Encoder Seed Value
SYNC2 08: 20 bits Encoder Synchronization Counter (CNTSEL = 1)
08: 18 bits 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 Modulation Value Format
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 Value Time (s)
Word(1) 00b 0.0
01b 0.8
10b 1.6
11b 3.2
BSEL2 3E: --54 ---- Transmission Baud Rate Value TE (μs)
Select(1) 00b 100
01b 200
10b 400
11b 800
(1)
GSEL2 3E: 76-- ---- Guard Time Select Value Time (ms)
00b 0.0
01b 6.4
10b 51.2
11b 102.4
Note 1: All Timing values vary ±10%.

© 2006 Microchip Technology Inc. DS21986A-page 24


PKE Reference Design User’s Manual
TABLE 3-5: DEVICE OPTIONS
Address
Symbol Description(1)
(Bits)
WAKE 3F: ---- --10 Wake-up(1) Value Value
00b No Wake-up
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 2.2 V = 0 3.2V = 1
Select(2)
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
(1)
TSEL 3D: --54 ---- Time-out Select 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.

DS21986A-page 25 © 2006 Microchip Technology Inc.


PKE REFERENCE DESIGN
USER’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 transmissions. Visual indications of function codes, as well as, an in-vehicle
network interface are included.
This module consists of a UHF receiver, microcontroller, power supply, LED indicators
and a network physical interface.

FIGURE 4-1: RKE RECEIVER/DECODER

Microcontroller
Function LEDS
Radio Rec. DataIN
LEARN LED
VLOW LED
LEARN SW Bus
Network
Transceiver

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 is 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 to the
receiver module is connected to the microcontroller PORTA bit 2 INT pin. For more
information on the receiver module, see the Telecontrolli Data Sheets “DS.0015-1.pdf”
and “DS.0016-9.pdf” available on the PKE Reference Design CD-ROM (DS51575).

4.2.2 Microcontroller
a) The microcontroller can be any one of the 14-pin PICmicro® microcontroller
family members, but it is usually a PIC16F636 or a PIC16F688. The
PIC16F636 has 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.

© 2006 Microchip Technology Inc. DS21986A-page 26


PKE Reference Design User’s Manual
TABLE 4-1: I/O CONNECTIONS
PORT Pin Function Notes
Inputs
RA0 Jumper E2 to GND, available to user ICSP™ Data
RA2 RF Data input
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 Transceiver
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.
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.
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 a 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 automo-
tive-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.

DS21986A-page 27 © 2006 Microchip Technology Inc.


Remote Keyless Entry Receiver-Decoder Module

4.2.5 Connectors

FIGURE 4-2: J1 SYSTEM CONNECTOR

no connection 1 4 +12 VDC VBAT


no connection 2 5 LIN Bidirectional BUS

no connection 3 6 Chassis GND

FIGURE 4-3: J2 PROGRAMMING CONNECTOR

MCLR 1
VCC 2
VSS 3
ICSPDAT 4
ICSPCLK 5
no connection 6

FIGURE 4-4: J3 POWER CONNECTOR

CHASSIS GND +12 VDC VBAT

© 2006 Microchip Technology Inc. DS21986A-page 28


J3
ANT1
U1
FIGURE 4-5:

AMRRS3-433 or -315

DS21986A-page 29
VBB
REG1
J1

VC C
GND
ANT
NC
NC
NC
GND
NC
NC
VC C
GND
VC C
TEST
OUT
VC C
LM2937IMP-5.0
1 2
+ + D1 VCC
3 4 1 3

1
2
3
4
5
6
7
8
9
+ + IN OUT

10
11
12
13
14
15
5 6
+ + 1N4004
+ C2 + C3 + R1 VCC

GND
C1 1K
D2 10 uF 10 uF 0.1 uF

2
J2
1N4755 43V 1
LED1 VCC
Green LED 2
3
ON 4
5
VCC 6

R2 R3 1K DS1
10K S0
U2 LED
S1 R4 1K
13 10 R5 1K DS3
RA0/CIN+ RC0/C2IN+
12 9 S1
LED RA1/CIN- RC1/C2IN-
LEARN 11 8 LED
RA2/C1OUT/INT RC2
4 PIC16F636 7
RA3/MCLR RC3 R7 1K DS4
3 6
DS2 1K R6 RA4/OSC2 RC4/C2OUT
2 5 S2
RA5/OSC1 RC5
SCHEMATIC – TRANSPONDER KEY FOB

LED

1
1
Not assembled with PIC16F636 E1 E2 Can be replaced with PIC16F688 for LIN applications R8 1K DS5
VBB S3
C4 C5

2
2
LED
PKE Reference Design User’s Manual

.01 uF 1.0

7
3
DS6
R9 1K
U3 VLOW
LED

VD D

VBAT
2
LINbus CS/WAKE
6 4
LIN TX
1
RX
8
C6 FAULT/SLPS
5
GND R10
D3 220 pF MCP201
100K
Can be replaced with
1N4750 27V MCP202
VCC

© 2006 Microchip Technology Inc.


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 code hopping 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:
File Name Function
CHECKSN.ASM Substituted for KEELOQ® decryption files
FASTDEC.INC(1) KEELOQ® decryption routine
KEYGEN.INC(1) KEELOQ® decryption 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 available on
the KEELOQ decoder license CD-ROM (DS40038) through your local Microchip
Sales Office.
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

© 2006 Microchip Technology Inc. DS21986A-page 30


PKE Reference Design User’s Manual
FIGURE 4-6: MODULES OVERVIEW DIAGRAM

TMR0
Interrupt
Radio Rec RXI.INC

1st Buffer X

BFFULL
Flag
MEM-62X.INC
Learn Receive Buffer CSR
TABLE.INC
Out S0
MID.ASM
- Insert FL62X.ASM
Out S3
Main Loop - Search EEPROM
LED

VLOW

- RD Word
- WR Word

KEYGEN.INC
KEY64.Inc
- Normal KEY GEN
Manufacturer Code - Manufacturer Code Load

-OR- CheckSN.asm(1)
KEELOQ® decoder(1)

FASTDEC.INC
- Decrypt

Note 1: Substitute for KEELOQ decoder decryption files.

DS21986A-page 31 © 2006 Microchip Technology Inc.


Remote Keyless Entry Receiver-Decoder Module
FIGURE 4-7: CODE WORD DATA FORMAT

With XSER = 0, 16-bit Counter, QUEN = 0

Status Information Fixed Code Portion (32 Bits) Hopping Code Portion (32 Bits)
(3 Bits)
Synchronization
Counter
Counter
CRC VLOW BUT Serial Number BUT Overflow DISC 16 Bits
2 Bits 1Bit 4 Bits (28 Bits) 4 Bits 2 Bits 10 Bits 15 0

C1 C0 S2 S1 S0 S3 S2 S1 S0 S3 OVR1 OVR0

Transmission Direction LSb First

FIGURE 4-8: CODE WORD DATA FORMAT, NO ENCRYPTION

With XSER = 0, 16-bit Counter, QUEN = 0, S<3:0> not equal ‘0111’

Fixed Code Portion (64 Bits)


Status Information
(3 Bits)
Serial Number 1 Serial Number 2
CRC VLOW BUT (28 Bits) BUT USER1 USER0 (16 Bits)
2 Bits 1Bit 4 Bits 4 Bits 4 Bits 8 Bits

C1 C0 S2 S1 S0 S3 S2 S1 S0 S3 Data 71h Data 72h

Transmission Direction LSb First

© 2006 Microchip Technology Inc. DS21986A-page 32


WORLDWIDE SALES AND SERVICE
AMERICAS ASIA/PACIFIC ASIA/PACIFIC EUROPE
Corporate Office Australia - Sydney India - Bangalore Austria - Wels
2355 West Chandler Blvd. Tel: 61-2-9868-6733 Tel: 91-80-2229-0061 Tel: 43-7242-2244-399
Chandler, AZ 85224-6199 Fax: 61-2-9868-6755 Fax: 91-80-2229-0062 Fax: 43-7242-2244-393
Tel: 480-792-7200 China - Beijing Denmark - Copenhagen
India - New Delhi
Fax: 480-792-7277 Tel: 86-10-8528-2100 Tel: 45-4450-2828
Tel: 91-11-5160-8631
Technical Support: Fax: 86-10-8528-2104 Fax: 45-4485-2829
Fax: 91-11-5160-8632
http://support.microchip.com
China - Chengdu India - Pune France - Paris
Web Address:
Tel: 86-28-8676-6200 Tel: 91-20-2566-1512 Tel: 33-1-69-53-63-20
www.microchip.com
Fax: 86-28-8676-6599 Fax: 91-20-2566-1513 Fax: 33-1-69-30-90-79
Atlanta
Alpharetta, GA China - Fuzhou Japan - Yokohama Germany - Munich
Tel: 86-591-8750-3506 Tel: 49-89-627-144-0
Tel: 770-640-0034 Tel: 81-45-471- 6166
Fax: 86-591-8750-3521 Fax: 49-89-627-144-44
Fax: 770-640-0307 Fax: 81-45-471-6122
China - Hong Kong SAR Italy - Milan
Boston Korea - Gumi
Tel: 852-2401-1200 Tel: 39-0331-742611
Westborough, MA Tel: 82-54-473-4301
Fax: 852-2401-3431 Fax: 39-0331-466781
Tel: 774-760-0087 Fax: 82-54-473-4302
Fax: 774-760-0088 China - Qingdao Netherlands - Drunen
Korea - Seoul
Tel: 86-532-8502-7355 Tel: 82-2-554-7200 Tel: 31-416-690399
Chicago
Fax: 86-532-8502-7205 Fax: 82-2-558-5932 or Fax: 31-416-690340
Itasca, IL
Tel: 630-285-0071 China - Shanghai 82-2-558-5934 Spain - Madrid
Fax: 630-285-0075 Tel: 86-21-5407-5533 Tel: 34-91-708-08-90
Malaysia - Penang
Fax: 86-21-5407-5066 Tel: 60-4-646-8870 Fax: 34-91-708-08-91
Dallas
Addison, TX China - Shenyang Fax: 60-4-646-5086 UK - Wokingham
Tel: 972-818-7423 Tel: 86-24-2334-2829 Tel: 44-118-921-5869
Philippines - Manila
Fax: 972-818-2924 Fax: 86-24-2334-2393 Fax: 44-118-921-5820
Tel: 63-2-634-9065
Detroit China - Shenzhen Fax: 63-2-634-9069
Farmington Hills, MI Tel: 86-755-8203-2660 Singapore
Tel: 248-538-2250 Fax: 86-755-8203-1760 Tel: 65-6334-8870
Fax: 248-538-2260 Fax: 65-6334-8850
China - Shunde
Kokomo Tel: 86-757-2839-5507 Taiwan - Hsin Chu
Kokomo, IN Fax: 86-757-2839-5571 Tel: 886-3-572-9526
Tel: 765-864-8360 Fax: 886-3-572-6459
China - Wuhan
Fax: 765-864-8387
Tel: 86-27-5980-5300 Taiwan - Kaohsiung
Los Angeles Fax: 86-27-5980-5118 Tel: 886-7-536-4818
Mission Viejo, CA Fax: 886-7-536-4803
China - Xian
Tel: 949-462-9523
Tel: 86-29-8833-7250 Taiwan - Taipei
Fax: 949-462-9608
Fax: 86-29-8833-7256 Tel: 886-2-2500-6610
San Jose Fax: 886-2-2508-0102
Mountain View, CA
Thailand - Bangkok
Tel: 650-215-1444
Tel: 66-2-694-1351
Fax: 650-961-0286
Fax: 66-2-694-1350
Toronto
Mississauga, Ontario,
Canada
Tel: 905-673-0699
Fax: 905-673-6509

10/31/05

DS21986A-page 33 © 2006 Microchip Technology Inc.

You might also like