Professional Documents
Culture Documents
KEY FEATURES
Author: Steven Dawson • Stand-alone decoder
Microchip Technology Inc. • Compatible with Microchip HCS200, HCS201,
HCS300, HCS301, HCS360, HCS361 and
HCS410 encoders
OVERVIEW • Automatic baud rate detection
• Automatic encoder type detection
This application note fully describes the working of a • Four function outputs
code hopping decoder implemented on a Microchip • Six learnable transmitters
PIC16C56 microcontroller. Background is given on the • RC Oscillator
various KEELOQ® code hopping encoders that can be
used with the decoder, the decoder hardware described,
and descriptions of the various software modules com-
prising the system. The software can be used to imple-
ment a stand-alone decoder or integrated with full
function security systems. The decoder supports the
Microchip HCS200, HCS201, HCS300, HCS301,
HCS360, HCS361 and HCS410 KEELOQ Code Hopping
Encoders.
Notice:
This is a non-restricted version of Application Note AN642 which is available under the KEELOQ
License Agreement. The license agreement can be ordered from the Microchip Literature Center as
DS40149.
RF S0
Receiver RFIN S1
S2
S3
PIC16C56
Learn
CS Indication
EEPROM CLK
DIO
Learn
Init
2te te
1
X A B C
te 2te
PIC16C56
tem. The following section summarizes how the differ- MCLR 4 15 OSC IN
ences in transmitted data are dealt with by the decoder. 5 14
GND VDD
As the serial number information follows after the code hop-
S0 6 13 FUNC OK
ping portion of the transmission, any number of serial num-
ber bits can be received and processed. In the Microchip S1 7 12 EE CS
decoder described 28 bits of the serial number are stored.
S2 8 11 EE CK
The serial number is used to identify the memory block
S3 9 10 EE DIO
used to store the 64-bit decryption key for a particular
encoder because of the relationship between serial num-
Reset
Get Learn
Pointer
MAIN
Delete TX
Yes At Learn
Reset Due To
Failed Learn? Position
WIPE_TX
No
Loop Back
Point
MAIN2
Learn
Pressed?
M_LOOP2-> Learn Routine
TST_LEARN Yes
No
Check For
Encoder TX
RECEIVE
Received 56
Or 66 Bits?
No M_LOOP2
Yes
Transmission
Validation
1. Calibrate on the header low period to determine The diagram below (Figure 5) gives all the major sam-
the actual elemental period for the transmission pling points in the receive algorithm.
being received. The required elemental period is Note: The sample points are labeled in the
10% of the low header period. In the diagram receive routine flow diagrams that follow.
below (Figure 5) the header calibration sample
points are marked 1 through 3. The calibration flow
chart (Figure 6) shows at what points in the source
code samples 1, 2, and 3 are taken.
Elemental periods outside the capture range of the FIGURE 5: SAMPLING POINTS USED IN
algorithm (either too long or too short) should be RECEIVE ALGORITHM
rejected, since they would be due either to noise or Preamble Header Data
to reception of an incomplete signal.
2. Using the determined elemental period, three
samples after the first rising edge following the
header are taken. The first sample is taken half an 12 3 4 5 6 74 5
elemental period after the rising edge (Sample 4);
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 sec-
ond could be either high or low, and the third sam-
ple must be low. If either the first or the third
sample is not as expected, the attempt at captur-
ing a transmission is abandoned. In the diagram
below (Figure 5), the data sample points are
points 4 through 6. The flow chart describing data
reception (Figure 7) shows where in the code the
samples are taken.
3. If all 64 bits have been captured, each with the cor-
rect first and third elements, the transmission can
be assumed to be correct, and decryption can
commence.
High Yes
3
Calibration
Counter/10
RCV6
No
Load
Cal Counter
RCV7
Receive
Data
DL1
Receive
Data
RCV7
Wait Half
Bit Period
DL1
Low
Input?
High
4
Wait Full
Bit Period
DL2
High
Input?
Low
5
Data = 1 Data = 0
Wait Full
Bit Period
DL3
High
7 Input?
Low
High 6
Low Input? No
RCV9/RCV10 Last Bit?
No Yes
Time-out?
Yes
No Received
Invalid 56 Bits?
RMT0
Yes
Reception
Cleanup Complete
RMT2 RMT1
The confidential and proprietary information contained in this section of AN642 has
been removed. The full application note is available under a license agreement and
can be ordered as DS40149 from Microchip Technology Inc.
TIMING PARAMETERS
TABLE 10: TIMING PARAMETERS
Parameter Typical Unit
Output activation duration 524 ms
Output pause if new function code received 131 ms
Erase all duration 8.4 s
Learn mode time-out 33.6 s
Learn successful LED flash duration 4.2 s
Learn successful LED flash rate 3.8 Hz
Learn failure LED on duration 1 s
1 VI G VO
2
AN661
VCC U4 N
DS00661B-page 12
LOW VOLTAGE DETECTOR 3 1N4004/7 C2 C3
APPENDIX A:
J2
R3 VCC
1k 1 D6 LEARN
R8
RF INPUT
R4 D1 S0
U5
14 R5 D3 S1
R1 4 17
10k MCLR V RA0 R6 D4
C 18 S2
3 RA1
T0CKI C RA2 1
2 R7 D2 S3
16 RA3
OSC1 R9 D7 FUNC OK
RB0 6
15 7
CLKOUT RB1
RB2 8
RB3 9
10
APPENDIX SCHEMATIC DIAGRAMS
RB4
G RB5 11
C1 N RB6 12
10 pF D RB7 13
5 VCC VCC
PIC16C56
SCHEMATIC DIAGRAM OF MICROCHIP KEELOQ DECODER
R2 U1
10k 1 CS VCC 8
2 SK NC 7
3 DI NC 6
4 DO GND 5
2
1k
S1 93LC46B
LEARN INIT SERIAL EEPROM
1
2 N 1
3 1N4004/7 C2 C3
GND 100 µF D 100 µF K2 CON1
CON3 D8
VCC
POWER SUPPLY 1N4004/7
J3 RELAY SPST
RB2 V1
RB3 9
10 110VAC
RB4
G RB5 11
C1 12 D9 K1
N RB6
10 pF D RB7 13
VCC
VCC 1N4004/7
PIC16C56 5 RELAY SPST
R2 U1
R4 10k 1 8
1k CS VCC
2 SK NC 7 S1 Q2
3 DI NC 6 NPN
D10 2 4 5
LEARN DO GND
S1
LEARN INIT 93LC46B
SERIAL EEPROM
1 GARAGE LIGHT
DS00661B-page 13
AN661
AN661
NOTES:
• The PICmicro family meets the specifications contained in the Microchip Data Sheet.
• Microchip believes that its family of PICmicro microcontrollers is one of the most secure products 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 knowl-
edge, require using the PICmicro microcontroller in a manner outside the operating specifications contained in the data sheet.
The person doing so may be 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 product.
If you have any further questions about this matter, please contact the local sales office nearest to you.
01/18/02