English
Language : 

HCS365 Datasheet, PDF (11/34 Pages) Microchip Technology – KEELOQ Code Hopping Encoder
HCS365
3.2 Code Word Format
A KEELOQ code word consists of 32 bits of hopping
code data, 32 bits of fixed code data, and between 3 to
5 bits of status information. Various code word formats
are shown in Figure 3-1 and Figure 3-2.
3.2.1 HOPPING CODE PORTION
The hopping code portion is calculated by encrypting
the counter, discrimination value, and function code
with the Encoder Key (KEY). The hopping code is cal-
culated when a button press is debounced and remains
unchanged until the next button press.
The counter can be either a 16- or 20-bit counter. The
Configuration Option Counter Select (CNTSEL) value
will determine this. The counter select option must be
the same for both Encoder 1 and Encoder 2. If the 16-bit
counter is selected, the discrimination value is 10 bits
long and there are 2 counter overflow bits (OVR0,
OVR1). Set both bits in production and OVR0 will be
cleared on the first counter overflow and OVR1 on the
second.
If the counter is 20 bits, the discrimination value is 8 bits
long and there are no overflow bits. The rest of the 32
bits are made up of the function code also known as the
button inputs.
The discrimination value can be programmed with any
value to serve as a post decryption check on the
decoder end. In a typical system, this will be pro-
grammed with the 8 or 10 Least Significant bits of the
serial number. This will be stored by the receiver sys-
tem after a transmitter has been learned. The discrimi-
nation bits are part of the information that is to form the
encrypted portion of the transmission.
3.2.2 FIXED CODE PORTION
The 32 bits of fixed code consist of 28 bits of the serial
number (SER) and a copy of the 4-bit function code.
This can be changed to contain the whole 32-bit serial
number by setting the Extended Serial Number (XSER)
configuration option to a 1. If more than one button is
pressed, the function codes are logically OR’ed
together. The function code is repeated in the
encrypted and unencrypted data of a transmission.
TABLE 3-4: FUNCTION CODES
Button
S0
S1
S2
S3
Function Code
xx1x2
x1xx2
1xxx2
xxx12
3.2.3 STATUS INFORMATION
The status bits will always contain the output of the Low
Voltage (VLOW) detector and Cyclic Redundancy
Check (CRC). If Queue (QUEN) is enabled, button
queue information will be included in the code words.
FIGURE 3-1: CODE WORD DATA FORMAT (16-BIT COUNTER)
With XSER=0, 16-bit Counter, QUEN=0
Status Information
(3 Bits)
Fixed Code Portion (32 Bits)
CRC
2 Bits
VLOW BUT
1-Bit 4 Bits
SERIAL NUMBER
(28 Bits)
Hopping Code Portion (32 Bits)
Counter
BUT Overflow
4 Bits 2 Bits
DISC
10 Bits
Synchronization
Counter
16 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
(5 Bits)
Fixed Code Portion (32 Bits)
QUE CRC VLOW
2 Bits 2 Bits 1-Bit
SERIAL NUMBER
(32 Bits)
Hopping Code Portion (32 Bits)
Counter
BUT Overflow
4 Bits 2 Bits
DISC
10 Bits
Synchronization
Counter
16 Bits
15
0
Q1 Q0 C1 C0
S2 S1 S0 S3 OVR1 OVR0
Transmission Direction LSB First
© 2002 Microchip Technology Inc.
Preliminary
DS41109D-page 11