AN663. Simple Code Hopping Decoder KEY FEATURES OVERVIEW

Similar documents
AN566. Using the PORTB Interrupt on Change as an External Interrupt USING A PORTB INPUT FOR AN EXTERNAL INTERRUPT INTRODUCTION

Connecting Sensor Buttons to PIC12CXXX MCUs

AN528. Implementing Wake-Up on Key Stroke. Implementing Wake-Up on Key Stroke INTRODUCTION IMPLEMENTATION FIGURE 1 - TWO KEY INTERFACE TO PIC16C5X

Optical Pyrometer. Functions

HCS509. KEELOQ Code Hopping Decoder* PACKAGE TYPE FEATURES BLOCK DIAGRAM DESCRIPTION. Security. Operating. Other. Typical Applications

27C64. 64K (8K x 8) CMOS EPROM PACKAGE TYPES FEATURES DESCRIPTION. This document was created with FrameMaker 404

HCS512. Code Hopping Decoder* FEATURES PACKAGE TYPE BLOCK DIAGRAM DESCRIPTION. Security. Operating. Other. Typical Applications. Compatible Encoders

HCS410/WM. Crypto Read/Write Transponder Module FEATURES PACKAGE TYPES BLOCK DIAGRAM HCS410 IMMOBILIZER TRANSPONDER. Security. Operating.

MCP100/101. Microcontroller Supervisory Circuit with Push-Pull Output FEATURES PACKAGES DESCRIPTION BLOCK DIAGRAM

HCS200. KEELOQ Code Hopping Encoder* PACKAGE TYPES FEATURES BLOCK DIAGRAM DESCRIPTION. Security. Operating. Other. Typical Applications PDIP, SOIC


Electromechanical Switch Replacement

TC1225 TC1226 TC1227. Inverting Dual ( V IN, 2V IN ) Charge Pump Voltage Converters FEATURES GENERAL DESCRIPTION TYPICAL APPLICATIONS

HCS300. Code Hopping Encoder* FEATURES PACKAGE TYPES HCS300 BLOCK DIAGRAM DESCRIPTION. Security. Operating. Other. Typical Applications

HCS509. KEELOQ Code Hopping Decoder* FEATURES PACKAGE TYPE BLOCK DIAGRAM DESCRIPTION. Security. Operating. Other. Typical Applications

Electromechanical Timer Replacement Solutions Cubed Real-Time Clock

Using External RAM with PIC17CXX Devices PIC17C42 PIC17C43 PIC17C Microchip Technology Inc. DS91004A-page 1

DatasheetDirect.com. Visit to get your free datasheets. This datasheet has been downloaded by

TB003. An Introduction to KEELOQ Code Hopping INTRODUCTION. Remote Control Systems. The Solution. Code Scanning. Code Grabbing

DatasheetDirect.com. Visit to get your free datasheets. This datasheet has been downloaded by

TCM828 TCM829. Switched Capacitor Voltage Converters FEATURES GENERAL DESCRIPTION APPLICATIONS ORDERING INFORMATION

TC4426 TC4427 TC A DUAL HIGH-SPEED POWER MOSFET DRIVERS GENERAL DESCRIPTION FEATURES ORDERING INFORMATION

HCS200. Code Hopping Encoder FEATURES PACKAGE TYPES BLOCK DIAGRAM DESCRIPTION. Security. Operating. Other. Typical Applications PDIP, SOIC

PIC14C000. Errata Sheet for PIC14C000 Revision A. USING THE I 2 C MODULE IN SMBus MODE USING AN1 AND AN5 AS ANALOG INPUTS

TC4423 TC4424 TC4425 3A DUAL HIGH-SPEED POWER MOSFET DRIVERS GENERAL DESCRIPTION FEATURES ORDERING INFORMATION

HCS201. Code Hopping Encoder

TC643 INTEGRATED FAN / MOTOR DRIVER GENERAL DESCRIPTION FEATURES APPLICATIONS ORDERING INFORMATION

HCS300. KEELOQ Code Hopping Encoder DESCRIPTION FEATURES PACKAGE TYPES HCS300 BLOCK DIAGRAM. Security. Operating. Other. Typical Applications

TC623. 3V, Dual Trip Point Temperature Sensor. Package Type. Features. Applications. General Description. Device Selection Table

AN820. System Supervisors in ICSP TM Architectures CIRCUITRY BACKGROUND INTRODUCTION. MCP120 Output Stage. Microchip Technology Inc.

TC52. Dual Channel Voltage Detector. Features. General Description. Typical Applications. Functional Block Diagram. Device Selection Table

SUPER CHARGE PUMP DC-TO-DC VOLTAGE CONVERTER

M TC3682/TC3683/TC3684

TC1044S. Charge Pump DC-TO-DC Voltage Converter FEATURES GENERAL DESCRIPTION ORDERING INFORMATION

Using the TC1142 for Biasing a GaAs Power Amplifier. CTL High-Side. FET Switch GND V IN V OUT TC GND. Inductorless Boost/Buck Regulator

AN562. Using Endurance Predictive Software. Using the Microchip Endurance Predictive Software INTRODUCTION TOTAL ENDURANCE PREDICTIVE SOFTWARE

AN603. Continuous Improvement THE EEPROM TECHNOLOGY TEAM INTRODUCTION TO MICROCHIP'S CULTURE. Continuous Improvement is Essential

27C K (32K x 8) CMOS EPROM FEATURES PACKAGE TYPES DESCRIPTION

TC51. 1µA Voltage Detector with Output Delay TC51. General Description. Features. Applications. Device Selection Table. Functional Block Diagram

TC mA Charge Pump Voltage Converter with Shutdown. Features. Package Type. Applications. General Description. Device Selection Table

TC57 Series. Linear Regulator Controller GENERAL DESCRIPTION FEATURES TYPICAL APPLICATIONS ORDERING INFORMATION PART CODE TC57 XX 02 ECT XX

PIC16C622A PIC16F628 Migration

TCM680 +5V TO ±10V VOLTAGE CONVERTER GENERAL DESCRIPTION FEATURES APPLICATIONS ORDERING INFORMATION

2-Wire Serial Temperature Sensor and Thermal Monitor

TC4467 TC4468 TC4469 LOGIC-INPUT CMOS QUAD DRIVERS GENERAL DESCRIPTION FEATURES APPLICATIONS ORDERING INFORMATION

HCS362. HCS362 Data Sheet Errata. Clarifications/Corrections to the Data Sheet: 1. Module: Low Voltage Detector LOW VOLTAGE DETECTOR

MCP V 10-Bit A/D Converter with SPI Serial Interface FEATURES PACKAGE TYPES APPLICATIONS FUNCTIONAL BLOCK DIAGRAM DESCRIPTION

TC1221/TC1222. High Frequency Switched Capacitor Voltage Converters with Shutdown in SOT Packages. 6-Pin SOT-23A. Features. General Description

HCS515. Code Hopping Decoder PACKAGE TYPE FEATURES BLOCK DIAGRAM DESCRIPTION. Security. Operating. Other. Typical Applications. Compatible Encoders

MCP V Dual Channel 12-Bit A/D Converter with SPI Serial Interface PACKAGE TYPES FEATURES APPLICATIONS FUNCTIONAL BLOCK DIAGRAM DESCRIPTION

M TC1426/TC1427/TC1428

TC620/TC621. 5V, Dual Trip Point Temperature Sensors. Features. Package Type. Applications. Device Selection Table. General Description

HCS500. Code Hopping Decoder PACKAGE TYPE FEATURES BLOCK DIAGRAM DESCRIPTION. Security. Operating. Other. Typical Applications. Compatible Encoders

AN765. Using Microchip's Micropower LDOs INTRODUCTION APPLICATIONS. Optimizing Output Voltage Accuracy of 1070/1071 Adjustable LDOs

1.5A Dual High-Speed Power MOSFET Drivers. Temp. Range

1.5A Dual Open-Drain MOSFET Drivers. 8-Pin PDIP/SOIC/CERDIP IN A A BOTTOM IN B B TOP A TOP B BOTTOM IN A B TOP IN B

TC Low Power, Quad Input, 16-Bit Sigma-Delta A/D Converter Features Package Type 16-Pin PDIP 16-Pin QSOP TC3402 Applications

PIC16C65A. PIC16C65A Rev. A Silicon Errata Sheet. 2. Module: CCP (Compare Mode) 1. Module: CCP (Compare Mode) SWITCHING

Controlling DC Brush Motor using MD10B or MD30B. Version 1.2. Aug Cytron Technologies Sdn. Bhd.

TC7662A. Charge Pump DC-to-DC Converter. Features. Package Type. General Description. Applications. Device Selection Table. 8-Pin PDIP 8-Pin CERDIP

AN797. TC4426/27/28 System Design Practice INTRODUCTION. FIGURE 1: TC4426 output. FIGURE 2: Output stage IC layout.

MCP3204/ V 4-Channel/8-Channel 12-Bit A/D Converters with SPI Serial Interface FEATURES PACKAGE TYPES APPLICATIONS FUNCTIONAL BLOCK DIAGRAM

rfpic Development Kit 1 Quick Start Guide

TC652 Fan Control Demo Board User s Guide

AN654. PWM, a Software Solution for the PIC16CXXX METHODS INTRODUCTION

AN824. KEELOQ Encoders Oscillator Calibration OVERVIEW WHY CALIBRATION? CALIBRATION BASICS. Microchip Technology Inc.

DatasheetDirect.com. Visit to get your free datasheets. This datasheet has been downloaded by

TB059. Using The MCP2150 Developer s Board With The MCP2155 INTRODUCTION MCP2150 DEVELOPER S BOARD LAYOUT

HCS365. KEELOQ Code Hopping Encoder PACKAGE TYPES FEATURES HCS365 BLOCK DIAGRAM GENERAL DESCRIPTION. Security. Operating. Other. Typical Applications

Radio Encoder / Decoder IC s

TC1029. Linear Building Block Dual Low Power Op Amp. General Description. Features. Applications. Device Selection Table. Functional Block Diagram

Remote Switching. Remote Gates. Paging.

AN606. Low Power Design Using PICmicro Microcontrollers INTRODUCTION DESIGN TECHNIQUES RESISTOR TO LOWER POWER IN RC MODE CONTROL CIRCUIT

HCS512. KEELOQ Code Hopping Decoder DESCRIPTION FEATURES PACKAGE TYPE BLOCK DIAGRAM. Security. Operating. Other. Typical Applications

W588AXXX Data Sheet. 8-BIT MCU WITH VOICE SYNTHESIZER (PowerSpeech TM Series) Table of Contents-

TC mA Fixed Low Dropout Positive Regulator TC2117. General Description. Features. Applications. Typical Application Device Selection Table

Voltage-To-Frequency/Frequency-To-Voltage Converters

Low-Voltage CMOS Logic HD74LV_A/RD74LVC_B Series

8-bit Microcontroller. Application Note. AVR400: Low Cost A/D Converter

UHF ASK/FSK Receiver ATA5721 ATA5722. Features

Application Note AN-301 Qspeed Family

4-Megabit (512K x 8) OTP EPROM AT27C040. Features. Description. Pin Configurations

Linear Building Block Low-Power Comparator with Op Amp and

TC520A. Serial Interface Adapter for TC500 A/D Converter Family. General Description. Features. Applications. Device Selection Table.

8-bit RISC Microcontroller. Application Note. AVR314: DTMF Generator

MIC5528. High Performance 500 ma LDO in Thin and Extra Thin DFN Packages. General Description. Features. Applications.

8-bit RISC Microcontroller. Application Note. AVR182: Zero Cross Detector

AVR1311: Using the XMEGA Timer/Counter Extensions. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Remote Switching. Remote Gates. Paging.

Read-only Transponder TK5530

MV1820. Downloaded from Elcodis.com electronic components distributor

Battery-Voltage. 1-Megabit (64K x 16) Unregulated. High-Speed OTP EPROM AT27BV1024. Features. Description. Pin Configurations

CS T1/E1 Universal Line Interface &20081,&$7, '8&7',9,6,21 352'8&7,1)250$7, pi.fm Page -1 Wednesday, January 21, :48 AM

rfhcs362g/362f KEELOQ Code Hopping Encoder with UHF ASK/FSK Transmitter General: Pin Diagrams Code Hopping Encoder: Security: Applications:

AN763. Latch-Up Protection For MOSFET Drivers INTRODUCTION. CONSTRUCTION OF CMOS ICs PREVENTING SCR TRIGGERING. Grounds. Equivalent SCR Circuit.

R1RP0416D Series. 4M High Speed SRAM (256-kword 16-bit) Description. Features. Ordering Information. REJ03C Z Rev Mar.12.

HCS370. KEELOQ Code Hopping Encoder PACKAGE TYPES FEATURES HCS370 BLOCK DIAGRAM GENERAL DESCRIPTION. Security. Operating. Other. Typical Applications

27LV K (32K x 8) Low-Voltage CMOS EPROM FEATURES PACKAGE TYPES DESCRIPTION PDIP

Features INSTRUCTION DECODER CONTROL LOGIC AND CLOCK GENERATORS EEPROM ARRAY READ/WRITE AMPS DATA IN/OUT REGISTER 16 BITS DATA OUT BUFFER

Flasher, 30 mω Shunt, Pilot Lamp to GND or V Batt U2043B

Transcription:

Simple Code Hopping Decoder AN66 Author: OVERVIEW Steven Dawson This application note fully describes the working of a code hopping decoder implemented on a Microchip PIC6C5 microcontroller. The PIC6C5 is smaller than the PIC6C56 used in the normal decoder (AN6) or the secure learn decoder (AN65). A simplified learning scheme with all encoders sharing a common key and a simplified counter synchronization scheme has been used to reduce the code space requirements. The use of a common key reduces the security of the system. The simple decoder can learn up to 5 encoders. This application note describes the various KEELOQ code hopping encoders that can be used with the decoder, the decoder hardware, and the various software modules comprising the system. The software can be used to implement a stand alone decoder or integrated with full function security systems. The decoder supports the Microchip HCS00, HCS00, HCS0, HCS60, and HCS6 KEELOQ Code Hopping Encoders. KEY FEATURES PIC6C5 Stand alone decoder Compatible with Microchip HCS00, HCS00, HCS0, HCS60, and HCS6 encoders Automatic bit rate detection Automatic encoder type detection Four function outputs Up to 5 learnable transmitters RC Oscillator Single press learn FIGURE : LEARN INIT LEARN IND Vcc MCLR GND S0 S PIC6C5 DECODER 5 6 7 PIC6C5 Simple Decoder 8 7 6 5 RFIN NC OSC OUT OSC IN Vcc NC EE CS S 8 EE CK S 9 0 EE DIO Notice: This is a non-restricted version of Application Note AN659 which is available under the KEELOQ License Agreement. The license agreement can be ordered from the Microchip Literature Center as DS09. KEELOQ is a registered trademark of 997 DS0066A-page

AN66 INTRODUCTION TO KEELOQ ENCODERS All KEELOQ encoders use the KEELOQ code hopping technology to make each transmission by an encoder unique. The encoder transmissions have two parts. The first part changes each time the encoder is activated and is called the hopping code part and is encrypted. The second part is the unencrypted part of the transmission, principally containing the encoder s serial number identifying it to a decoder. Refer to DS900, Introduction to KEELOQ. Hopping Code The hopping code contains function information, a discrimination value, and a synchronization counter. This information is encrypted by an encryption algorithm before being transmitted. A 6-bit encryption key is used by the encryption algorithm. If one bit in the data that is encrypted changes, the result is that an average of half the bits in the output will change. As a result, the hopping code changes dramatically for each transmission and can not be predicted. Function Information The encoder transmits up to four bits of function information. Up to 5 different functions are available. Discrimination Value Stored in the encoder EEPROM, this information can be used to check integrity of decryption operation by a decoder. If known information is inserted into the transmitted string before encryption, the same information can be used at the decoder to check whether the information has been decrypted correctly. bits (including overflow bits) are available in the Microchip HCSXXX encoders. Synchronization Counters The transmitted word contains a 6-bit synchronization counter. The synchronization information is used at the decoder to determine whether a transmission is valid or is a repetition of a previous transmission. Previous codes are rejected to safeguard against code grabbers. The HSC00 and HCS0 encoders transmit two overflow bits which may be used to extend the range of the synchronization counter from 65,56 to 96,608 button operations. The HCS60 and HCS6 encoders transmit one overflow bit which can be used to extend the range of the synchronization counter from 65,56 to,07 button operations. Unencrypted Code Serial Number The encoder s serial number is transmitted every time the button is pressed. The serial number is transmitted unencrypted as part of the transmission and serves to identify the encoder to the decoder. Other Status and Function Information The HCS00, HCS00, and HCS0 encoders include provision for four bits of function information and two status bits in the fixed code portion of its transmission. The two status bits indicate whether a repeated transmission is being sent, and whether the battery voltage is low. The HCS00 does not send repeated transmission information, and the bit is permanently set to 0. The HCS60/6 encoders transmit two bits that are used as a Cyclic Redundancy check. These bits can be used to check the integrity of the reception. Additionally, the HCS60 and HCS6 encoders can extend the length of the serial number from 8 bits to bits, replacing the unencrypted function code. Transmission Format Summary Table contains a summary of the information contained in transmissions from each of the KEELOQ encoders that can be learned by the Microchip decoder. DS0066A-page 997

AN66 FIGURE : DECODER BLOCK DIAGRAM RF Receiver RFIN S0 S S S PIC6C5 EEPROM CS CLK DIO Learn Indication Learn Init TABLE : KEELOQ ENCODER TRANSMISSION SUMMARY The HCS00 transmissions are padded to retain compatibility with the HCS00/0 encoders. User selectable with a -bit serial number or a 8-bit serial number, and unencrypted function bits. The code hopping portion is always transmitted first (LSB to MSB), followed by the fixed portion (LSB to MSB). TABLE : HCS00 AND HCS00/0 TRANSMISSION FORMAT HCS00 HCS00/0 HCS60/6 Total transmission length 66 bits 66 bits 67 bits Hopping code portion (total length) bits bits bits Function bits bits (+ ) bits bits Discrimination bits bits bits bits Synchronization 6 bits 6 bits 6 bits Fixed portion (total length) bits bits 5 bits Serial number 8 bits 8 bits 8/ bits Function bits bits (+ ) bits /0 bits Status bits VLOW bit bit bit RPT 0 bit 0 CRC 0 0 bits Hop Code Serial Number Function Status LSB bits MSB LSB 8 bits MSB bits bits The HCS00 transmissions are padded to retain compatibility with the HCS00/0 encoders. TABLE : HCS60/6 TRANSMISSION FORMAT Hop Code Serial Number Function Status LSB bits MSB LSB 8/ bits MSB /0 bits bits Bits are transmitted from left to right (i.e., the code hopping part first). 997 DS0066A-page

AN66 PWM Format In general, all KEELOQ encoders share a common transmission format: A preamble to improve biasing of decision thresholds in super-regenerative receivers. The preamble consists of alternate on and off periods, each lasting as long as a single elemental period. A calibration header consisting of a low period of 0 elemental periods. Calibration actions should be performed on the low period of the header to ensure correct operation with header chopping. A string of 66 or 67 pulse-width modulated bits, each consisting of three elements. The first element is high, the second contains the data transmitted and is either high or low, the third element is always low. A guard period is usually left between the transmissions. During this period nothing is transmitted by the encoder. Figure shows the sampling points when sampling the data bits. The first and last elements are used exclusively to verify the integrity of the received symbol. The first element (sample point A) is always high, the second (sample point B) is the complement of the data bit being sent, and the final element (sample point C) is always low. Because the period between the low portion of a bit (sample point C) and the rising edge of the following bit (sample point X) can vary, the rising edge of the first element (sample point X) is used to resynchronize the receiving routine to each incoming bit. If random noise is being received, the probability of a set of three samples producing a valid combination is only - = /. For a string of 66 bits, the corresponding figure is - < x 0-0. Integrity checking on incoming signals is important. Code hopping signals require significant processing, as well as EEPROM access, to decrypt. Unnecessary processing can be avoided by not attempting to decrypt incoming codes that have bit errors. FIGURE : KEELOQ PWM TRANSMISSION FORMAT Data Bit Format I Bit Format II Sampling Points 0 t e t e t e t e X A B C t e t e t e 5 t e TABLE : TRANSMISSION FORMATS Encoder Preamble Header Chopping PWM Bit Format I II Hopping Code Length Unencrypted Code Length HCS00 bits bits HCS00/0 bits bits HCS60 bits 5 bits HCS6 bits 5 bits DS0066A-page 997

AN66 DECODER IMPLEMENTATION The decoder is implemented on a PIC6C5 RISC microcontroller and a 9C6 EEPROM as shown in the decoder schematic in Figure A-. However, this solution can be implemented in any PICmicro microcontroller with at least 500 words of program memory. The operating frequency of the controller is MHz. The microcontroller is used to capture transmissions from the various encoders, decrypt transmissions captured, and check the validity of the transmission based on the information in the decrypted transmission and information stored in the EEPROM. If a transmission from a valid encoder is received, the decoder activates the outputs dictated by the transmission. Encoder information, such as serial number and synchronization information is stored externally in an EEPROM. The EEPROM used is a Microchip 9C6 Microwire Serial EEPROM. The information stored in the EEPROM is encrypted to protect the contents. The EEPROM encryption is less secure than the KEELOQ code hopping algorithm. As can be seen from the section on encoder transmissions there are differences in the transmission formats of the different encoders that can be used with the decoder. The following section summarizes how the differences in transmitted data are dealt with by the decoder. As the serial number information follows after the code hopping portion of the transmission, any number of serial number bits can be received and processed. In the Microchip decoder described, the complete serial number (8 bits) is stored. After matching the received and stored serial number, validation of a received transmission consists of two steps. The first includes checking the integrity of the decryption operation. Here the decoder compares the least significant 8-bits of the discrimination value received with the least significant 8-bits of the serial number. The discrimination value stored with the HCS00/0/60/6 includes overflow bits and user bits. The second portion of validation involves checking synchronization information for that particular encoder. The synchronization counter transmitted by all encoders is 6 bits long. Two copies of the full synchronization counter are stored for all valid encoders. The storing of two copies of the synchronization information protects the decoder from loosing synchronization with an encoder if one of the counters is corrupted. TABLE 5: MICROCHIP DECODER FUNCTIONAL INPUTS AND OUTPUTS Mnemonic Pin Number Input / Output Function RF IN 8 I Demodulated PWM signal from RF receiver. The decoder uses this input to receive encoder transmissions. LEARN INIT I Input to initiate learning, active low. LEARN IND O Output to show the status of the learn process (in an integrated system this will be combined with the system status indicator). S0, S, S, S 6, 7, 8, 9 O Function outputs corresponds to encoder input pins. Microwire is registered trademark of Motorola. 997 DS0066A-page 5

AN66 PROGRAM FLOW The software for the Microchip decoder has been written for the PIC6C5 microcontroller. The compiler used is MPASM version 0.0.0. The operating frequency of the PIC6C5 is MHz. The clock speed should be kept as close as possible to MHz as the reception routine (RECEIVE) is dependent on the MHz clock for correct functioning. Other decoder functions that rely on a MHz clock speed are the hold times of the various outputs and time-outs. The main program flow is described here. Detailed descriptions of individual functions can be found further in the application note. After startup, the encoder enters the main loop where it spends most of its time. The main loop checks to see if the learn button is being activated. If so, the decoder enters the learn mode described in the Learn in AN659. If learn has not been initiated, the microcontroller checks for transmissions from encoders (RECEIVE) as described on page 7. If a transmission from an encoder has successfully been received, the microcontroller validates the transmission received as described in the Transmission Validation section in AN659. If the transmission received is a valid transmission from an encoder learned into the system, the system sets the appropriate outputs (M_OUTPUT). FIGURE : Reset RESET Initialize Ports and Variables Entry to Main Loop M_LOOP Clear the LED MICROCHIP DECODER MAIN PROGRAM FLOW Learn button pressed? Learn Routine LEARN Update Timer TST_RTCC Handle Timer TST_TIMER Received Transmission? RECEIVE Transmission Validation Microwire is a registered trademark of Motorola. DS0066A-page 6 997

AN66 FUNCTIONAL MODULES Reception The reception routine (RECEIVE) is based on a reliable algorithm which has successfully been used in previous implementations of KEELOQ decoders. Automatic bit rate detection is used to compensate for variations in bit rate of different encoders of a specific type, as well as the differences in bit rate between different encoders (HCS00, HCS00, and HCS60). The reception routine is able to receive 6-bit transmissions. The decoder only uses the first 60 bits received. The remaining bits are ignored. The reception algorithm performs a number of functions when an output is detected from the receiver. Figure 5 gives all the major sampling points in the reception algorithm. The reception algorithm calibrates on the low period of the header to determine the actual elemental period for the transmission being received. The required elemental period is 0% of the low header period. In Figure 5 the header calibration sample points are marked through. The calibration flow chart (Figure 6) shows at what points in the program samples,, and are taken. Elemental periods outside the capture range of the algorithm (either too long or too short) are rejected, since they are due either to noise or to reception of an incomplete signal. Using the determined elemental period, three samples after the first rising edge (sample ) following the header are taken. The first sample is taken half an elemental period after the rising edge (Sample ); the second, one elemental period later (Sample 5), and the third, another one elemental period later (Sample 6). The first sample must be high, the second could be either high or low, and the third sample must be low. If either the first or the third sample is not as expected, the attempt at capturing a transmission is abandoned. In Figure 5, the data sample points are points through 6. The flow chart describing data reception (Figure 7) shows where in the code the samples are taken. If all 6 bits have been captured, each with the correct first and third elements, the transmission can be assumed to be correct, and decryption can commence. The receiving routine should be called often enough to ensure that the high portion in the header is not missed (Sample, Figure 5). FIGURE 5: SAMPLING POINTS USED IN RECEIVE ALGORITHM In systems where the reception routine is called to check if there is activity on the receiver input, the routine should poll the input for a valid transmission for at least the time taken to complete one transmission if activity is detected on the input line. This makes provision for the reception routine being called while a transmission is in progress. Having missed the first header, the first transmission will be invalid and be discarded. The decoder should continue sampling the input through the guard time in order to catch the next header and transmission (i.e., for a decoder designed to capture HCS00 transmissions the time spent polling for a valid transmission should be at least 00 ms if activity is detected in the input line). Reception Algorithm Flow Chart The flow chart in Figure 6 describes the calibration routine which is used to determine the actual transmission rate of the encoder so that the decoder can compensate for deviations from nominal timing. There are four different exit points, each of which should branch to a point in the program where housekeeping and input monitoring can be resumed. There is only one exit point for a valid calibration operation (RCV7). At this point, it is assumed that a valid header has been received and that a string of data bits will follow. The second flow chart (Figure 7) handles the reception of bits once the calibration routine has been successfully completed. The data bits are all sampled three times each to ensure that a noise free transmission has been received. The reception routine uses the calibrated elemental period, determined in the calibration routine, to ensure that the samples are correctly spaced. The routine resynchronizes itself on the rising flank of each bit. Only 60 bits of the data received are used by the decoder described, the decoder ignores the unencrypted function code and the status bits. If the control samples in a given bit are sampled correctly (i.e., the first element is high and the last element is low), the routine checks whether 66 bits have been received correctly. If not, the routine returns to the calling procedure. Preamble Header Data 5 6 7 5 997 DS0066A-page 7

AN66 FIGURE 6: CALIBRATION FLOW CHART Calibrate RECEIVE Input? LOW Invalid Header RMT_0 HIGH Reset Time-out Counter Input? RCV HIGH Time-Out? LOW Clear Calibration Counter RCV Input? RCV LOW Too Long? RCV HIGH Calibration Counter/0 RCV6 Too Short? RCV6 Invalid Header RMT_0 Load Cal Counter RCV7 Receive Data DL DS0066A-page 8 997

AN66 FIGURE 7: DATA RECEPTION FLOW CHART Receive Data RCV7 Wait Half Bit Period DL Input SAMPLE LOW HIGH Wait Full Bit Period DL 5 Input SAMPLE HIGH LOW Data = Data = 0 Set Up DL Timer RCV Wait Full Bit Period DL HIGH 7 Input RCV8/RCV9/ RVC0 Input SAMPLE HIGH LOW LOW 6 Time-out? Last Bit? Invalid Received 56 Bits? RMT0 Cleanup RMT Reception Complete RMT 997 DS0066A-page 9

AN66 VALIDATION SYNCHRONIZATION FUNCTION INTERPRETATION OUTPUT ACTIVATION KEY GENERATION DECRYPTION LEARN ROM MEMORY MAP EEPROM MEMORY MAP RAM MEMORY MAP The confidential and proprietary information contained in this section of AN659 has been removed. The full application note is available under a license agreement and can be ordered as DS09 from DS0066A-page 0 997

AN66 DEVICE PIUTS The device used in the application note is a PIC6C5 PDIP or SOIC. TABLE 6: DEVICE PIUTS PIN PIC6C5 Function Decoder Function PIN PIC6C5 Function Decoder Function Port A Bit LEARN Input 8 Port A Bit RF Input Port A Bit LEARN Indicator 7 Port A Bit 0 Not used TIMER0 Connect to VDD 6 Osc In RC osc ( MHz) MCLR Brown out detect 5 Osc Out 5 GND Ground VDD +5V supply 6 Port B Bit 0 S0 Port B Bit 7 Not Used 7 Port B Bit S Port B Bit 6 CS (9C6, pin )) 8 Port B Bit S Port B Bit 5 CLK (9C6, pin ) 9 Port B Bit S 0 Port B Bit DIO (9C6, pin & ) TIMING PARAMETERS TABLE 7: TIMING PARAMETERS Parameter Typical Unit Output activation duration 5 ms Output pause if new function code received ms Erase all duration 8. s Learn mode time-out.6 s Learn failure LED on duration s SOURCE CODE LISTING A diskette is supplied containing source code for the Microchip decoder in the file SIMDEC**.ASM. The code has been compiled using MPASM v0.0.0. Certain functions are dependent on the oscillator speed for correct functioning. Examples of time dependent functions include RECEIVE and TST_TIMER. The PIC6C5 Microcontroller should run at MHz. TABLE 8: LIST OF IMPORTANT FUNCTIONS Function Name Description DECRYPT Decryption routine for Hop Code. EEREAD The data in the EEPROM at ADDRESS is read to TMP and TMP (Note). EEWRITE The data in TMP, and TMP is written to the EEPROM at ADDRESS (Note). M_DIS Check discrimination value. M_CNT Check synchronization (counter) values. RECEIVE Start of the RF reception routine. LEARN Learn mode. TST_RTCC Check Timer0 and update CNT_LW and CNT_HI. TST_TIMER Check CNT_LW and CNT_HI and do whatever real-time tasks that are required. Note: TMP, TMP and ADDRESS are user defined registers. 997 DS0066A-page

DS0066A-page 997 Vcc U LOW VOLTAGE DETECTOR VI G VO ND R 0K C 0pF R 00R MCLR V C T0CKI C 6 OSC 5 CLKOUT PIC6C5 G N D 5 U5 RA0 7 RA 8 RA RA RB0 RB 7 6 RB 8 RB 9 RB 0 RB5 RB6 RB7 R 7K V GND J RF INPUT S LEARN INIT J CON D5 N00/7 C 00uF POWER SUPPLY U LM7805 VI G N D SERIAL EEPROM R8 VO R R5 R6 R7 U CS 8 SK NC 7 DI NC DO GND 5 6 9C6 D6 D D D D Vcc C 00uF LEARN S0 S S S APPENDIX A: SCHEMATIC DIAGRAMS FIGURE A-: SCHEMATIC DIAGRAM OF MICROCHIP KEELOQ DECODER AN66

997 DS0066A-page V GND J CON V D5 N00/7 U LOW VOLTAGE DETECTOR VI G VO N D R 00R Vcc R 0k C 0 pf Power Supply U5 MCLR V RA0 7 CC RA 8 T0CKI RA 6 RA OSC 5 RB0 6 CLKOUT RB 7 RB 8 RB 9 G RB 0 RB5 N RB6 D RB7 PIC6C5 5 LEARN U LM7805 VI G VO C N 00 µf D R k D0 S0 S R 7k RF INPUT S LEARN INIT C 00 µf ANTENNA Vcc U CS 8 SK NC 7 DI NC 6 DO GND 5 9C6 SERIAL EEPROM J 5 6 7 8 9 0 5 RF RECEIVER MODULE S D6 R6 00R N00/7 D8 N00/7 N00/7 R7 M C5 0 µf S0 D9 V V MOTOR CONTROL OUT K Q NPN Door Motor RELAY SPST K Garage light L GARAGE LIGHT RELAY SPST Q NPN J CON V 0V AC FIGURE A-: TYPICAL GARAGE DOOR OPENER SCHEMATIC AN66

DS0066A-page 997 Vcc BT 6V S S C 00 nf U S0 S0 S S S S S S PGM CLK HCS00 8 LED 7 PWM GND 5 6 LED PWM PGM DATA J PROGRAMMING PADS D LED R 7k 06 RF CIRCUITRY (MHz) U SAW 57 R00 Q BFR9A SOT R 0R C.pF 0805 NP0 C pf 0805 NP0 L 0mm PCB TRACK R 7R 06 C 00 pf 0805 FIGURE A-: HCS00/00/0/60/6 TRANSMITTER DESIGN AN66

WORLDWIDE SALES & SERVICE AMERICAS Corporate Office 55 West Chandler Blvd. Chandler, AZ 85-699 Tel: 60-786-700 Fax: 60-786-777 Technical Support: 60 786-767 Web: http://www.microchip.com Atlanta 500 Sugar Mill Road, Suite 00B Atlanta, GA 050 Tel: 770-60-00 Fax: 770-60-007 Boston 5 Mount Royal Avenue Marlborough, MA 075 Tel: 508-80-9990 Fax: 508-80-8575 Chicago Pierce Road, Suite 80 Itasca, IL 60 Tel: 60-85-007 Fax: 60-85-0075 Dallas 65 Dallas Parkway, Suite 86 Dallas, TX 750-8809 Tel: 97-99-777 Fax: 97-99-8588 Dayton Two Prestige Place, Suite 50 Miamisburg, OH 5 Tel: 97-9-65 Fax: 97-9-975 Los Angeles 80 Von Karman, Suite 090 Irvine, CA 96 Tel: 7-6-888 Fax: 7-6-8 New York 50 Motor Parkway, Suite 6 Hauppauge, NY 788 Tel: 56-7-505 Fax: 56-7-55 San Jose 07 North First Street, Suite 590 San Jose, CA 95 Tel: 08-6-7950 Fax: 08-6-7955 Toronto 595 Airport Road, Suite 00 Mississauga, Ontario LV W, Canada Tel: 905-05-679 Fax: 905-05-65 ASIA/PACIFIC Hong Kong Microchip Asia Pacific RM 80B, Tower Two Metroplaza Hing Fong Road Kwai Fong, N.T., Hong Kong Tel: 85--0-00 Fax: 85--0- India Microchip Technology India No. 6, Legacy, Convent Road Bangalore 560 05, India Tel: 9-80-9-006 Fax: 9-80-9-006 Korea Microchip Technology Korea 68-, Youngbo Bldg. Floor Samsung-Dong, Kangnam-Ku Seoul, Korea Tel: 8--55-700 Fax: 8--558-59 Shanghai Microchip Technology RM 06 Shanghai Golden Bridge Bldg. 077 Yan an Road West, Hongiao District Shanghai, PRC 005 Tel: 86--675-5700 Fax: 86-675-5060 Singapore Microchip Technology Taiwan Singapore Branch 00 Middle Road #0-0 Prime Centre Singapore 88980 Tel: 65--8870 Fax: 65--8850 Taiwan, R.O.C Microchip Technology Taiwan 0F-C 07 Tung Hua North Road Taipei, Taiwan, ROC Tel: 886-77-775 Fax: 886--55-09 EUROPE M All rights reserved. 997, Microchip Technology Incorporated, USA. 5/97 United Kingdom Arizona Microchip Technology Ltd. Unit 6, The Courtyard Meadow Bank, Furlong Road Bourne End, Buckinghamshire SL8 5AJ Tel: -68-85077 Fax: -68-85059 France Arizona Microchip Technology SARL Zone Industrielle de la Bonde Rue du Buisson aux Fraises 900 Massy, France Tel: --69-5-6-0 Fax: --69-0-90-79 Germany Arizona Microchip Technology GmbH Gustav-Heinemann-Ring 5 D-879 Müchen, Germany Tel: 9-89-67-0 Fax: 9-89-67-- Italy Arizona Microchip Technology SRL Centro Direzionale Colleone Palazzo Taurus V. Le Colleoni 00 Agrate Brianza Milan, Italy Tel: 9-9-689999 Fax: 9-9-689988 JAPAN Microchip Technology Intl. Inc. Benex S- 6F -8-0, Shin Yokohama Kohoku-Ku, Yokohama Kanagawa Japan Tel: 8--57-666 Fax: 8--57-6 5/8/97 Information contained in this publication regarding device applications and the like is intended for suggestion only and may be superseded by updates. No representation or warranty is given and no liability is assumed by Microchip Technology Incorporated with respect to the accuracy or use of such information, or infringement of patents or other intellectual property rights arising from such use or otherwise. Use of Microchip s products as critical components in life support systems is not authorized except with express written approval by Microchip. No licenses are conveyed, implicitly or otherwise, under any intellectual property rights. The Microchip logo and name are registered trademarks of in the U.S.A. and other countries. All rights reserved. All other trademarks mentioned herein are the property of their respective companies. 997