AN1266. KEELOQ with XTEA Microcontroller-Based Code Hopping Encoder INTRODUCTION DUAL ENCODER OPERATION BACKGROUND FUNCTIONAL INPUTS AND

Similar documents
AN1259. KEELOQ Microcontroller-based Code Hopping Encoder INTRODUCTION DUAL ENCODER OPERATION TRANSMITTER OVERVIEW FUNCTIONAL INPUTS AND OUTPUTS

AN1328. KEELOQ with XTEA Microcontroller-Based Transmitter with Acknowledge INTRODUCTION DUAL TRANSMITTER OPERATION BACKGROUND RECEIVER ACKNOWLEDGE

AN1321. KEELOQ Microcontroller-Based Transmitter with Acknowledge DUAL TRANSMITTER OPERATION INTRODUCTION RECEIVER ACKNOWLEDGE SAMPLE BUTTONS/WAKE-UP

MTCH810. Haptics Controller Product Brief. Description: Features: Pin Description: Package Type: DESCRIPTION MTCH810

TC53. Voltage Detector. Not recommended for new designs Please use MCP111/2 TC53. General Description: Features: Typical Applications:

MTCH112. Dual Channel Proximity Touch Controller Product Brief FEATURES PACKAGE TYPE SOIC, DFN GENERAL DESCRIPTION 8-PIN SOIC, DFN DIAGRAM FOR MTCH112

AN1476. Combining the CLC and NCO to Implement a High Resolution PWM BACKGROUND INTRODUCTION EQUATION 2: EQUATION 1: EQUATION 3:

AN1322. PIC MCU KEELOQ /AES Receiver System with Acknowledge TRANSMITTER LEARNING INTRODUCTION SYSTEM OVERVIEW RECEIVER FUNCTIONALITY

AN1312. Deviations Sorting Algorithm for CSM Applications INTRODUCTION DESCRIPTION. The Second Concept Most Pressed Button

AN1085. Using the Mindi Power Management Simulator Tool INTRODUCTION ACCESSING MINDI ON MICROCHIP S WEB SITE

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

TABLE 1: REGISTERS ASSOCIATED WITH SLOPE COMPENSATOR MODULE

TB3121. Conducted and Radiated Emissions on 8-Bit Mid-Range Microcontrollers INTRODUCTION ELECTROMAGNETIC COMPATIBILITY CONDUCTED EMISSIONS

PIC16(L)F72X Family Silicon Errata and Data Sheet Clarification

Low Cost Single Trip Point Temperature Sensor. Part Number Voltage Operation Package Ambient Temperature

PIC16F506. PIC16F506 Rev. C0 Silicon Errata and Data Sheet Clarification. Silicon Errata Issues

AN1291. Low-Cost Shunt Power Meter using MCP3909 and PIC18F25K20 OVERVIEW HARDWARE DESCRIPTION

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

New Peripherals Tips n Tricks

2, 5 and 8-Channel Proximity/Touch Controller Product Brief

PIC16F506. PIC16F506 Rev. B1 Silicon Errata and Data Sheet Clarification. Silicon Errata

MCP2515. MCP2515 Rev. B Silicon Errata. 3. Module: CAN Module. 1. Module: Oscillator Module. 4. Module: CAN Module. 2. Module: RAM Module

Low-Power Techniques for LCD Applications RTH = (2R*R)/(2R+R) RTH = 2R 2 /3R RTH = 2R/3 RSW = 4.7K RCOM = 0.4K

PIC16F87/88. PIC16F87/88 Rev. B1 Silicon Errata. 1. Module: Internal RC Oscillator

TC mA CMOS LDO TC1108. General Description. Features. Applications. Typical Application. Device Selection Table. Package Type SOT-223

TC1272A. 3-Pin Reset Monitor. General Description. Features. Applications. Package Type. Typical Application Circuit TC1272A TC1272A.

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

Voltage Detector. TC54VC only

PIC18F2420/2520/4420/4520

TC4426AM/TC4427AM/TC4428AM

PIC18F24J10/25J10/44J10/45J10

TC mA Fixed Output CMOS LDO. Features. Package Type. Applications. Device Selection Table. General Description. Typical Application

PIC16F818/819. PIC16F818/819 Rev. B0 Silicon Errata Sheet

TCM828/TCM829. Switched Capacitor Voltage Converters. Features. Description. Applications. Package Type. Typical Application Circuit

High-Speed N-Channel Power MOSFET

TC59. Low Dropout, Negative Output Voltage Regulator TC59. Features. General Description. Applications. Functional Block Diagram

AN1213. Powering a UNI/O Bus Device Through SCIO INTRODUCTION CIRCUIT FOR EXTRACTING POWER FROM SCIO

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

High-Speed N-Channel Power MOSFET. PDFN 5 x 6 S

Programmable Gain Amplifier (PGA)

PIC12(L)F1822/PIC16(L)F1823

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

TC1240/TC1240A. Positive Doubling Charge Pumps with Shutdown in a SOT-23 Package. Features. General Description. Applications

AN1332. Current Sensing Circuit Concepts and Fundamentals CURRENT SENSING RESISTOR INTRODUCTION. Description. Microchip Technology Inc.

AN1292 Tuning Guide 1.1 SETTING SOFTWARE PARAMETERS. STEP 1 Fill in the tuning_params.xls Excel spreadsheet with the following parameters:

Configurable Logic Cell Tips n Tricks

High-Speed N-Channel Power MOSFET

TC57. Line Regulator Controller TC57. General Description. Features. Applications. Functional Block Diagram. Device Selection Table.

TC32M. ECONOMONITOR 3-Pin System Supervisor with Power Supply Monitor and Watchdog. Features: General Description: Applications:

High-Speed N-Channel Power MOSFET

TC682. Inverting Voltage Doubler. General Description: Features: Applications: Functional Block Diagram. Device Selection Table. Package Type TC682

TC1047/TC1047A. Precision Temperature-to-Voltage Converter. General Description. Applications. Block Diagram. Features.

PIC32MX450F256L 100-pin to 100-pin TQFP USB Plug-In Module (PIM) Information Sheet

TC1275/TC1276/TC1277. Obsolete Device. 3-Pin Reset Monitors for 3.3V Systems. Features. General Description. Applications. Device Selection Table

TB3126. PIC16(L)F183XX Data Signal Modulator (DSM) Technical Brief INTRODUCTION

PIC24FJ128GC010 FAMILY

High-Precision 16-Bit PWM Technical Brief MODE<1:0> PWM Control Unit. Offset Control OFM<1:0> E R U/D PWMxTMR. PHx_match. Comparator.

TB090. MCP2030 Three-Channel Analog Front-End Device Overview INTRODUCTION MCP2030. Youbok Lee, Ph.D. Microchip Technology Inc.

PIC16F/LF1826/1827 Family Silicon Errata and Data Sheet Clarification. (1) Revision ID for Silicon Revision (2)

TC7660. Charge Pump DC-to-DC Voltage Converter. Package Types. Features. General Description. Applications. Functional Block Diagram TC7660

TC mA CMOS LDO with Shutdown ERROR Output and Bypass. Features. General Description. Applications. Typical Application. Device Selection Table

Section 45. High-Speed Analog Comparator

PIC12LF1840T39A. PIC12LF1840T39A Product Brief. High-Performance RISC CPU: Low-Power Features: RF Transmitter: Flexible Oscillator Structure:

PIC16F818/819. PIC16F818/819 Rev. A4 Silicon Errata Sheet. 2. Module: PORTB FIGURE 1: 1. Module: Internal RC Oscillator

RE46C100. Piezoelectric Horn Driver Circuit HORNS HRNEN HORNB. Package Types. Features: General Description: Functional Block Diagram

Integrated Temperature Sensor & Brushless DC Fan Controller with FanSense Detect & Over-Temperature

DN2470. N-Channel, Depletion-Mode, Vertical DMOS FET. Features. Description. Applications

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

AN1739. Improving Battery Run Time with Microchip s 4 µa Quiescent Current MCP16251/2 Boost Regulator PRIMARY BATTERY CONSIDERATIONS INTRODUCTION

TB3103. Buck Converter Using the PIC16F753 Analog Features PERFORMANCE SPECIFICATIONS INTRODUCTION ELECTRICAL SPECIFICATIONS

TC1121. Obsolete Device. 100mA Charge Pump Voltage Converter with Shutdown. Features: Package Type. Applications: General Description:

TC Bit Digital-to-Analog Converter with Two-Wire Interface TC1320. General Description. Features. Applications.

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

PIC16(L)F1782/ Pin 8-Bit Advanced Analog Flash Microcontroller Product Brief. High-Performance RISC CPU: Analog Peripheral Features:

PIC16(L)F1526/1527 Family Silicon Errata and Data Sheet Clarification DEV<8:0>

HV825. High-Voltage EL Lamp Driver IC. General Description. Features. Applications. Typical Application Circuit

MCP1401/02. Tiny 500 ma, High-Speed Power MOSFET Driver. General Description. Features. Applications. Package Types

DN2450. N-Channel, Depletion-Mode, Vertical DMOS FET. Features. Description. Applications

PIC16F716 Silicon Errata and Data Sheet Clarification. (1) Revision ID for Silicon Revision (2)

TC913A/TC913B. Dual Auto-Zeroed Operational Amplifiers. Features: Package Type. General Description: Applications: Device Selection Table

PIC18F1XK22/LF1XK22 Family Silicon Errata and Data Sheet Clarification

TC1232. Microprocessor Monitor. General Description: Features: Block Diagram. Package Types. Device Features

TC7660S. Super Charge Pump DC-to-DC Voltage Converter. Features: Package Types. General Description: Applications:

RE46C317/18. Piezoelectric Horn Driver with Boost Converter. Features: Description: Applications: Package Types. Typical Application

PIC12F1822/16F182X. 8/14/20-Pin 8-Bit Flash Microcontroller Product Brief. High-Performance RISC CPU: Peripheral Features:

MTD6501C/D/G. 3-Phase Brushless DC Sinusoidal Sensorless Fan Motor Driver. Features. Description. Package Types

TB3073. Implementing a 10-Bit Digital Potentiometer using a Quad 8-Bit Digital Potentiometer Technical Brief INTRODUCTION.

TC1070/TC1071/TC ma, 100 ma and 150 ma Adjustable CMOS LDOs with Shutdown. Features: Description: Applications: Typical Application

9A High-Speed MOSFET Drivers. 8-Pin 6x5 DFN-S (2) INPUT EP 9

PIC12(L)F1501/PIC16(L)F150X

GS004. Driving an ACIM with the dspic DSC MCPWM Module INTRODUCTION MCPWM MODULE FILTERED BY THE MOTOR'S WINDINGS

TC1410/TC1410N. 0.5A High-Speed MOSFET Drivers. Features. General Description. Package Type. Applications. 8-Pin MSOP/PDIP/SOIC TC1410N TC1410

AN2092. Using the Temperature Indicator Module INTRODUCTION. Constants. Application Limits. Equations. Variables. Microchip Technology Inc.

MCP1406/07. 6A High-Speed Power MOSFET Drivers. General Description. Features. application.

IR Remote Control Transmitter. Packet Packet Packet 24.9 ms Packet continues to repeat while a button is pressed 114 ms

AN1202. Capacitive Sensing with PIC10F IMPLEMENTATION INTRODUCTION + - BASIC OSCILLATOR SCHEMATIC. Microchip Technology Inc.

ISOLATOR UNIT SPECIFICATION Isolator Unit DANGER INTRODUCTION DEVICE SUPPORT HARDWARE SETUP

ATA6570. ATA6570 Silicon Errata and Data Sheet Clarification. 2. Module: CAN Bus Wake-Up Detection System Reinitialization

Capacitive Multibutton Configurations Q3*RD_CM1CON0 C1ON (1) C1POL

dspic33ep256mc506 Plug-In Module (PIM) Information Sheet for Internal Op amp Configuration

Transcription:

KEELOQ with XTEA Microcontroller-Based Code Hopping Encoder Authors: INTRODUCTION This application note describes the design of a microcontroller-based KEELOQ Hopping Encoder using the XTEA encryption algorithm. This encoder is implemented on the Microchip PIC16F636 microcontroller. A description of the encoding process, the encoding hardware and description of the software modules are included within this application note. The software was designed to emulate an HCS365 dual encoder. As it is, this design can be used to implement a secure system transmitter that will have the flexibility to be designed into various types of KEELOQ receiver/ decoders. BACKGROUND XTEA stands for Tiny Encryption Algorithm Version 2. This encryption algorithm is an improvement over the original TEA algorithm. It was developed by David Wheeler and Roger Needham of the Cambridge Computer Laboratory. XTEA is practical both for its security and the small size of its algorithm. XTEA security is achieved by the number of iterations it goes through. The implementation in this KEELOQ Hoppping Decoder uses 32 iterations. If a higher level of security is needed, 64 iterations can be used. For a more detailed description of the XTEA encryption algorithm please refer to AN953, Data Encryption Routines for the PIC18. TRANSMITTER OVERVIEW As this is an emulation of the HCS365, the transmitter has the following key features: Security: Enrique Aleman Michael Stuckey Microchip Technology Inc. Two programmable 32-bit serial numbers Two programmable 128-bit encryption keys Two programmable 64-bit seed values Each transmitter is unique 104-bit transmission code length 64-bit hopping code Operation: 2.0-5.5V operation Four button inputs 15 functions available Four selectable baud rates Selectable minimum code word completion Battery low signal transmitted to receiver Nonvolatile synchronization data PWM, VPWM, PPM, and Manchester modulation Button queue information transmitted Dual Encoder functionality DUAL ENCODER OPERATION This firmware contains two transmitter configurations with separate serial numbers, encoder keys, discrimination values, counters and seed values. This means that the transmitter can be used as two independent systems. The SHIFT(S3) input pin is used to select between encoder configurations. A low on this pin will select Encoder 1, and a high will select Encoder 2. FUNCTIONAL INPUTS AND OUTPUTS The software implementation makes use of the following pin designations: TABLE 1: Label Pin Number FUNCTIONAL INPUTS AND OUTPUTS Input/ Output Function S0 2 (RA5) Input Switch Input S0 S1 3 (RA4) Input Switch input S1 S2 4 (RA3) Input Switch Input S2 S3 5 (RA2) Input Switch Input S3 RF_OUT 6 (RA1) Output Encoded transmitter signal output LED 7 (RA0) Output LED On/Off 2009-2011 Microchip Technology Inc. DS01266B-page 1

OPERATION FLOW DIAGRAM FIGURE 1: START Debounce Button Inputs OPERATION FLOW DIAGRAM SAMPLE BUTTONS/WAKE-UP Upon power-up, the transmitter verifies the state of the buttons inputs and determines if a button is pressed. If no button pressed is detected, the transmitter will go to Sleep mode. The transmitter will wake-up whenever a button is pressed. Wake-up is achieved by configuring the input port to generate an interrupt-on-change. After the wake event, the input buttons are debounced for 20 ms to make a determination on which buttons have been pressed. The button input values are then placed in the transmission buffer, in the appropriate section. Read Configuration from EEPROM Sample Buttons/ Set Function_TX Increment Counter Encrypt Data A LOAD SYSTEM CONFIGURATION After waking up and debouncing the input switches, the firmware will read the system Configuration bytes. These Configuration bytes will determine what data and modulation format will be for the transmission. All the system Configuration bytes are stored in the EEPROM. Below is the EEPROM mapping for the PIC16F636 transmitter showing the configuration and data bits stored. Load Transmit Buffer/ MTX/ Time - Out Timer Reset Transmit Button Time -Out? NO New Button Pressed? YES A NO YES Button Still Pressed? NO MTX = 0? NO MTX = MTX-1 YES SLEEP DS01266B-page 2 2009-2011 Microchip Technology Inc.

TABLE 2: Offset EEPROM MAPPING FOR THE PIC16F636 TRANSMITTER Bits Bytes 7 6 5 4 3 2 1 0 MNEMONIC 0x00 Sync Counter, Byte 0, Transmitter 0, Copy A EE_CNT0A 0x01 Sync Counter, Byte 1, Transmitter 0, Copy A 0x02 Sync Counter, Byte 2, Transmitter 0, Copy A 0x03 Sync Counter, Byte 3, Transmitter 0, Copy A 0x04 Sync Counter, Byte 0, Transmitter 0, Copy B EE_CNT0B 0x05 Sync Counter, Byte 1, Transmitter 0, Copy B 0x06 Sync Counter, Byte 2, Transmitter 0, Copy B 0x07 Sync Counter, Byte 3, Transmitter 0, Copy B 0x08 Sync Counter, Byte 0, Transmitter 0, Copy C EE_CNT0C 0x09 Sync Counter, Byte 1, Transmitter 0, Copy C 0x0A Sync Counter, Byte 2, Transmitter 0, Copy C 0x0B Sync Counter, Byte 3, Transmitter 0, Copy C 0x0C 0x0D Sync Counter, Byte 0, Transmitter 1, Copy A EE_CNT1A 0x0E Sync Counter, Byte 1, Transmitter 1, Copy A 0x0F Sync Counter, Byte 2, Transmitter 1, Copy A 0x10 Sync Counter, Byte 3, Transmitter 1, Copy A 0x11 Sync Counter, Byte 0, Transmitter 1, Copy B EE_CNT1B 0x12 Sync Counter, Byte 1, Transmitter 1, Copy B 0x13 Sync Counter, Byte 2, Transmitter 1, Copy B 0x14 Sync Counter, Byte 3, Transmitter 1, Copy B 0x15 Sync Counter, Byte 0, Transmitter 1, Copy C EE_CNT1C 0x16 Sync Counter, Byte 1, Transmitter 1, Copy C 0x17 Sync Counter, Byte 2, Transmitter 1, Copy C 0x18 Sync Counter, Byte 3, Transmitter 1, Copy C 0x19 0x1A Serial Number, Byte 0, Transmitter 0 EE_SER 0x1B Serial Number, Byte 1, Transmitter 0 0x1C Serial Number, Byte 2, Transmitter 0 0x1D Serial Number, Byte 3, Transmitter 0 0x1E Seed Value, Byte 0, Transmitter 0 EE_SEED 0x1F Seed Value, Byte 1, Transmitter 0 0x20 Seed Value, Byte 2, Transmitter 0 0x21 Seed Value, Byte 3, Transmitter 0 0x22 Seed Value, Byte 4, Transmitter 0 0x23 Seed Value, Byte 5, Transmitter 0 0x24 Seed Value, Byte 6, Transmitter 0 0x25 Seed Value, Byte 7, Transmitter 0 0x26 STRTSEL_0 QUEN_0 XSER_0 HEADER_0 TMOD_0:1 TMOD_0:0 TX0_CFG0 0x27 User Value, Byte 0, Transmitter 0 EE_DISC 0x28 User Value, Byte 1, Transmitter 0 0x29 User Value, Byte 2, Transmitter 0 0x2A User Value, Byte 3, Transmitter 0 0x2B Encryption Key, Byte 0, Transmitter 0 EE_KEY 0x2C Encryption Key, Byte 1, Transmitter 0 0x2D Encryption Key, Byte 2, Transmitter 0 2009-2011 Microchip Technology Inc. DS01266B-page 3

TABLE 2: EEPROM MAPPING FOR THE PIC16F636 TRANSMITTER (CONTINUED) 0x2E Encryption Key, Byte 3, Transmitter 0 0x2F Encryption Key, Byte 4, Transmitter 0 0x30 Encryption Key, Byte 5, Transmitter 0 0x31 Encryption Key, Byte 6, Transmitter 0 0x32 Encryption Key, Byte 7, Transmitter 0 0x33 Encryption Key, Byte 8, Transmitter 0 0x34 Encryption Key, Byte 9, Transmitter 0 0x35 Encryption Key, Byte 10, Transmitter 0 0x36 Encryption Key, Byte 11, Transmitter 0 0x37 Encryption Key, Byte 12, Transmitter 0 0x38 Encryption Key, Byte 13, Transmitter 0 0x39 Encryption Key, Byte 14, Transmitter 0 0x3A Encryption Key, Byte 15, Transmitter 0 0x3B Serial Number, Byte 0, Transmitter 1 B_EE_SER 0x3C Serial Number, Byte 1, Transmitter 1 0x3D Serial Number, Byte 2, Transmitter 1 0x3E Serial Number, Byte 3, Transmitter 1 0x3F Seed Value, Byte 0, Transmitter 1 B_EE_SEED 0x40 Seed Value, Byte 1, Transmitter 1 0x41 Seed Value, Byte 2, Transmitter 1 0x42 Seed Value, Byte 3, Transmitter 1 0x43 Seed Value, Byte 4, Transmitter 1 0x44 Seed Value, Byte 5, Transmitter 1 0x45 Seed Value, Byte 6, Transmitter 1 0x46 Seed Value, Byte 7, Transmitter 1 0x47 STRTSEL_1 QUEN_1 XSER_1 HEADER_1 TMOD_1:1 TMOD_1:0 TX1_CFG1 0x48 User Value, Byte 0, Transmitter 1 B_EE_DISC 0x49 User Value, Byte 1, Transmitter 1 0x4A User Value, Byte 2, Transmitter 1 0x4B User Value, Byte 3, Transmitter 1 0x4C Encryption Key, Byte 0, Transmitter 1 B_EE_KEY 0x4D Encryption Key, Byte 1, Transmitter 1 0x4E Encryption Key, Byte 2, Transmitter 1 0x4F Encryption Key, Byte 3, Transmitter 1 0x50 Encryption Key, Byte 4, Transmitter 1 0x51 Encryption Key, Byte 5, Transmitter 1 0x52 Encryption Key, Byte 6, Transmitter 1 0x53 Encryption Key, Byte 7, Transmitter 1 0x54 Encryption Key, Byte 8, Transmitter 1 0x55 Encryption Key, Byte 9, Transmitter 1 0x56 Encryption Key, Byte 10, Transmitter 1 0x57 Encryption Key, Byte 11, Transmitter 1 0x58 Encryption Key, Byte 12, Transmitter 1 0x59 Encryption Key, Byte 13, Transmitter 1 0x5A Encryption Key, Byte 14, Transmitter 1 0x5B Encryption Key, Byte 15, Transmitter 1 0x5C GSEL_0 BSEL_0 SDTM_0 SDMD_0 SDLM_0 TX0_CFG1 0x5D LEDOS_1 LEDBL_1 TSEL RFENO INDESEL MTX SYSCFG1 0x5E GSEL_1 BSEL_1 SDTM_1 SDMD_1 SDLM_1 TX1_CFG1 0x5F LEDOS_0 LEDBL_0 PLLSEL VLOWSEL VLOWL CNTSEL WAKE SYSCFG0 DS01266B-page 4 2009-2011 Microchip Technology Inc.

CONFIGURATION WORDS DESCRIPTION TABLE 3: TX0_CFG0 (FOR TRANSMITTER 0, FOR TRANSMITTER 1 USE TX1_CFG0) BIT Field Description Values 0 Not used 1 Not used 2 3 TMOD:0 TMOD:1 Transmission Modulation Format 00 = PWM 01= Manchester 10 = VPWM 11 = PPM 4 HEADER Time Length of Transmission Header 0 = 4*Te 1 = 10*Te 6 QUEN Queue Counter Enable 0 = Disable 1 = Enable 7 STRTSEL Start/Stop Pulse Enable 0 = Disable 1 = Enable TABLE 4: TX0_CFG1 (FOR TRANSMITTER 0, FOR TRANSMITTER 1 USE TX1_CFG1) BIT Field Description Values 0 SDLM Limited Seed Enable 0 = Disable 1 = Enable 1 SDMD Seed Mode 0 = User 1 = Production 2 3 SDTM <3:2> Time Before Seed Code Word 00 = 0.0 sec 01= 0.8 sec 10 = 1.6 sec 11 = 3.2 sec 4 BSEL <5:4> Transmission Baud Rate Select 00 = 100 µs 01 = 200 µs 5 10 = 400 µs 11 = 800 µs 6 GSEL <7:6> Guard Time Select 00 = 0.0 ms 01 = 6.4 ms 7 10 = 51.2 ms 11 = 102.4 ms 2009-2011 Microchip Technology Inc. DS01266B-page 5

TABLE 5: SYSCFG0 BIT Field Description Values 0 1 WAKE <1:0> Wake-up 00 = No wake-up 01 = 75ms 50% 10 = 50ms 33% 11 = 100ms 16.6% 3 VLOWL Low-Voltage Latch Enable 0 = Disable 1 = Enable 4 VLOWSEL Transmission Baud Rate Select 0 = 2.2V 1 = 3.2V 5 PLLSEL PLL interface Select 0 = ASK 1 = FSK 6 LEDBL_0 Low-Voltage LED Blink 0 = Continuous 1 = Once 7 LEDOS_0 LED On Time Select 0 = 50 ms 1 = 100 ms TABLE 6: SYSCFG1 BIT Field Description Values 0 1 MTX <1:0> Maximum Code Words 00 = 1 01 = 2 10 = 4 11 = 8 2 INDESEL Dual Encoder Enable 0 = Disable 1 = Enable 3 RFEN0 RF Enable Output Select 0 = Disable 1 = Enable 4 5 TSEL Time-out Select 00 = Disabled 01 = 0.8 sec 10 = 3.2 sec 11 = 25.6 sec 6 LEDBL_1 Low-Voltage LED Blink 0 = Continuous 1 = Once 7 LEDOS_1 LED On Time Select 0 = 50 ms 1 = 100 ms EE_SER AND B_EE_SER These locations store the 4 bytes of the 32-bit serial number for transmitter 1 and transmitter 2. There are 32 bits allocated for the serial number and the serial number is meant to be unique for every transmitter. EE_SEED AND B_EE_SEED This is the 64-bit seed code that will be transmitted when seed transmission is selected. EE_SEED for transmitter 0 and B_EE_SEED for transmitter 1. This allows for the implementation of the secure learning scheme. EE_KEY AND B_EE_KEY 128-BIT ENCRYPTION KEY) The 128-bit encryption key is used by the transmitter to create the encrypted message transmitted to the receiver. This key is created using a key generation algorithm. The inputs to the key generation algorithm are the secret manufacturer s code, the serial number, and/or the SEED value. The user may elect to use the algorithm supplied by Microchip or to create their own method of key generation. DS01266B-page 6 2009-2011 Microchip Technology Inc.

COUNTER-CODE DESCRIPTION The following addresses save the counter checksum values. The counter value is stored in the Counter locations (COUNTA, COUNTB, COUNTC described on the EEPROM table. This code is contained in module CounterCode.inc. CODE TRANSMISSION FORMAT The following is the data stream format transmitted (Table 7): BUTTON PRESS DURING TRANSMIT If the device is in the process of transmitting and detects that a new button is pressed, the current transmission will be aborted, a new code word will be generated based on the new button information and transmitted. If all the buttons are released, a minimum number of code words will be completed. If the time for transmitting the minimum code words is longer than the time-out time, or the button is pressed for that long, the device will time-out. TABLE 7: CRC (2 bits) KEELOQ /XTEA PACKET FORMAT: VLOW (1 bit) Plaintext (40 bits) A KEELOQ/XTEA transmission consists of 64 bits of hopping code data, 36 bits of fixed code data and 3 bits of status information. HOPPING CODE PORTION Function Code (4 bits) The hopping code portion is calculated by encrypting the counter, discrimination value, and function code with the Encoder Key (KEY). A new hopping code is calculated every time a button press is pressed. The discrimination value can be programmed with any fixed value to serve as a post decryption check on the receiver end. Serial Number (32 bits) Function Code (8 bits) Encrypted (64 bits) User (24 bits) FIXED CODE PORTION Counter (32 bits) Data transmitted LSb first The 40 bits of fixed consist of 32 bits of serial number and four bits of the 8-bit function code. Each code word contains a preamble, header and data, and is separated from another code by guard time. The Guard Time Select (GSEL) configuration option can select a time period of 0ms, 6.4ms, 51.2ms or 102.4ms. All other timing specifications are based on the timing element (Te). This Te can be set to 100 µs, 200 µs, 400 µs or 800 µs with the Baud Rate Select (BSEL) configuration. The calibration header time can be set to 4*Te or 10*Te with the Header Select (HEADER) configuration option. The firmware has four different transmission modulation formats available. The Modulation select (TMOD) Configuration Option is used to select between: Pulse-Width Modulation (PWM) Figure 2 Manchester (MAN) Figure 3 Variable Pulse-Width Modulation (VPWM) Figure 4 Pulse Position Modulation (PPM) Figure 5 2009-2011 Microchip Technology Inc. DS01266B-page 7

FIGURE 2: PULSE-WIDTH MODULATION (PWM) FIGURE 3: MANCHESTER (MAN) FIGURE 4: VARIABLE PULSE-WIDTH MODULATION (VPWM) DS01266B-page 8 2009-2011 Microchip Technology Inc.

FIGURE 5: PULSE POSITION MODULATION (PPM) If the Start/Stop Pulse Enable (STEN) configuration option is enabled, the software will place a leading and trailing 1 on each code word. This bit is necessary for modulation formats such as Manchester and PPM to interpret the first and last data bit. A receiver wake-up sequence can be transmitted before the transmission starts. The wake-up sequence is configured with the Wake-up (WAKE) configuration option and can be disabled or set to 50 ms, 75 ms, or 100 ms of pulses of Te width. FIRMWARE MODULES The following files make up the KEELOQ transmitter firmware: - XTEA_KLQ 16F636.asm: this file contains the main loop routine as well as the wake-up, debounce, read configuration, load transmit buffer and transmit routines. - XTEA_Encrypt.inc: this file runs the XTEA encryption algorithm. - XTEA_eeprom.inc: this file contains the EEPROM data as specified on the EEPROM data map. - CounterCode.inc: Calculates the checksums and confirms the validity of the counter. Because of statutory export license restrictions on encryption software, the source code listings for the XTEA algorithms are not provided here. These applications may be ordered from Microchip Technology Inc. through its sales offices, or through the corporate web site: www.microchip.com. CONCLUSION This KEELOQ/XTEA transmitter firmware has all the features of a standard hardware encoder. What makes this firmware implementation useful is that it gives the designer the power and flexibility of modifying the encoding and/or transmission formats and parameters to suit their security system. REFERENCES C. Gübel, AN821, Advanced Encryption Standard Using the PIC16XXX (DS00821), Microchip Technology Inc. 2002. D. Flowers, AN953, Data Encryption Routines for the PIC18 (DS00953), Microchip Technology Inc., 2005. 2009-2011 Microchip Technology Inc. DS01266B-page 9

ADDITIONAL INFORMATION Microchip s Secure Data Products are covered by some or all of the following: Code hopping encoder patents issued in European countries and U.S.A. Secure learning patents issued in European countries, U.S.A. and R.S.A. REVISION HISTORY Revision B (June 2011) Added new section Additional Information Minor formatting and text changes were incorporated throughout the document DS01266B-page 10 2009-2011 Microchip Technology Inc.

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 applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer s risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights. Trademarks The Microchip name and logo, the Microchip logo, dspic, KEELOQ, KEELOQ logo, MPLAB, PIC, PICmicro, PICSTART, PIC 32 logo, rfpic and UNI/O are registered trademarks of Microchip Technology Incorporated in the U.S.A. and other countries. FilterLab, Hampshire, HI-TECH C, Linear Active Thermistor, MXDEV, MXLAB, SEEVAL 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, chipkit, chipkit logo, CodeGuard, dspicdem, dspicdem.net, dspicworks, dsspeak, ECAN, ECONOMONITOR, FanSense, HI-TIDE, In-Circuit Serial Programming, ICSP, Mindi, MiWi, MPASM, MPLAB Certified logo, MPLIB, MPLINK, mtouch, Omniscient Code Generation, PICC, PICC-18, PICDEM, PICDEM.net, PICkit, PICtail, REAL ICE, rflab, Select Mode, Total Endurance, TSHARC, UniWinDriver, 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. 2009-2011, Microchip Technology Incorporated, Printed in the U.S.A., All Rights Reserved. Printed on recycled paper. ISBN: 978-1-61341-268-8 Microchip received ISO/TS-16949:2002 certification for its worldwide headquarters, design and wafer fabrication facilities in Chandler and Tempe, Arizona; Gresham, Oregon and design centers in California and India. The Company s quality system processes and procedures are for its PIC MCUs and dspic DSCs, 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. 2009-2011 Microchip Technology Inc. DS01266B-page 11

Worldwide Sales and Service AMERICAS Corporate Office 2355 West Chandler Blvd. Chandler, AZ 85224-6199 Tel: 480-792-7200 Fax: 480-792-7277 Technical Support: http://www.microchip.com/ support Web Address: www.microchip.com Atlanta Duluth, GA Tel: 678-957-9614 Fax: 678-957-1455 Boston Westborough, MA Tel: 774-760-0087 Fax: 774-760-0088 Chicago Itasca, IL Tel: 630-285-0071 Fax: 630-285-0075 Cleveland Independence, OH Tel: 216-447-0464 Fax: 216-447-0643 Dallas Addison, TX Tel: 972-818-7423 Fax: 972-818-2924 Detroit Farmington Hills, MI Tel: 248-538-2250 Fax: 248-538-2260 Indianapolis Noblesville, IN Tel: 317-773-8323 Fax: 317-773-5453 Los Angeles Mission Viejo, CA Tel: 949-462-9523 Fax: 949-462-9608 Santa Clara Santa Clara, CA Tel: 408-961-6444 Fax: 408-961-6445 Toronto Mississauga, Ontario, Canada Tel: 905-673-0699 Fax: 905-673-6509 ASIA/PACIFIC Asia Pacific Office Suites 3707-14, 37th Floor Tower 6, The Gateway Harbour City, Kowloon Hong Kong Tel: 852-2401-1200 Fax: 852-2401-3431 Australia - Sydney Tel: 61-2-9868-6733 Fax: 61-2-9868-6755 China - Beijing Tel: 86-10-8569-7000 Fax: 86-10-8528-2104 China - Chengdu Tel: 86-28-8665-5511 Fax: 86-28-8665-7889 China - Chongqing Tel: 86-23-8980-9588 Fax: 86-23-8980-9500 China - Hangzhou Tel: 86-571-2819-3180 Fax: 86-571-2819-3189 China - Hong Kong SAR Tel: 852-2401-1200 Fax: 852-2401-3431 China - Nanjing Tel: 86-25-8473-2460 Fax: 86-25-8473-2470 China - Qingdao Tel: 86-532-8502-7355 Fax: 86-532-8502-7205 China - Shanghai Tel: 86-21-5407-5533 Fax: 86-21-5407-5066 China - Shenyang Tel: 86-24-2334-2829 Fax: 86-24-2334-2393 China - Shenzhen Tel: 86-755-8203-2660 Fax: 86-755-8203-1760 China - Wuhan Tel: 86-27-5980-5300 Fax: 86-27-5980-5118 China - Xian Tel: 86-29-8833-7252 Fax: 86-29-8833-7256 China - Xiamen Tel: 86-592-2388138 Fax: 86-592-2388130 ASIA/PACIFIC India - Bangalore Tel: 91-80-3090-4444 Fax: 91-80-3090-4123 India - New Delhi Tel: 91-11-4160-8631 Fax: 91-11-4160-8632 India - Pune Tel: 91-20-2566-1512 Fax: 91-20-2566-1513 Japan - Yokohama Tel: 81-45-471-6166 Fax: 81-45-471-6122 Korea - Daegu Tel: 82-53-744-4301 Fax: 82-53-744-4302 Korea - Seoul Tel: 82-2-554-7200 Fax: 82-2-558-5932 or 82-2-558-5934 Malaysia - Kuala Lumpur Tel: 60-3-6201-9857 Fax: 60-3-6201-9859 Malaysia - Penang Tel: 60-4-227-8870 Fax: 60-4-227-4068 Philippines - Manila Tel: 63-2-634-9065 Fax: 63-2-634-9069 Singapore Tel: 65-6334-8870 Fax: 65-6334-8850 Taiwan - Hsin Chu Tel: 886-3-6578-300 Fax: 886-3-6578-370 Taiwan - Kaohsiung Tel: 886-7-213-7830 Fax: 886-7-330-9305 Taiwan - Taipei Tel: 886-2-2500-6610 Fax: 886-2-2508-0102 Thailand - Bangkok Tel: 66-2-694-1351 Fax: 66-2-694-1350 EUROPE Austria - Wels Tel: 43-7242-2244-39 Fax: 43-7242-2244-393 Denmark - Copenhagen Tel: 45-4450-2828 Fax: 45-4485-2829 France - Paris Tel: 33-1-69-53-63-20 Fax: 33-1-69-30-90-79 Germany - Munich Tel: 49-89-627-144-0 Fax: 49-89-627-144-44 Italy - Milan Tel: 39-0331-742611 Fax: 39-0331-466781 Netherlands - Drunen Tel: 31-416-690399 Fax: 31-416-690340 Spain - Madrid Tel: 34-91-708-08-90 Fax: 34-91-708-08-91 UK - Wokingham Tel: 44-118-921-5869 Fax: 44-118-921-5820 China - Zhuhai Tel: 86-756-3210040 Fax: 86-756-3210049 05/02/11 DS01266B-page 12 2009-2011 Microchip Technology Inc.