
PIC12C67X and PIC12CE67X
DS40175A-page 10
1998 Microchip Technology Inc.
3.2
Checksum
3.2.1
CHECKSUM CALCULATIONS
Checksum is calculated by reading the contents of the
PIC12C67X and PIC12CE67X memory locations and
adding the opcodes up to the maximum user address-
able location, excluding the oscillator calibration loca-
tion in the last address, e.g., 0x3FE for the
PIC12C671/CE673. Any carry bits exceeding 16-bits
are neglected. Finally, the configuration word (appropri-
ately masked) is added to the checksum. Checksum
computation for each member of the PIC12C67X and
PIC12CE67X devices is shown in Table 3-2.
The checksum is calculated by summing the following:
The contents of all program memory locations
The configuration word, appropriately masked
Masked ID locations (when applicable)
The least significant 16 bits of this sum is the check-
sum.
The following table describes how to calculate the
checksum for each device. Note that the checksum cal-
culation differs depending on the code protect setting.
Since the program memory locations read out differ-
ently depending on the code protect setting, the table
describes how to manipulate the actual program mem-
ory values to simulate the values that would be read
from a protected device. When calculating a checksum
by reading a device, the entire program memory can
simply be read and summed. The configuration word
and ID locations can always be read.
Note that some older devices have an additional value
added in the checksum. This is to maintain compatibil-
ity with older device programmer checksums.
TABLE 3-2:
CHECKSUM COMPUTATION
Legend: CFGW = Configuration Word
SUM[a:b] = [Sum of locations a through b inclusive]
SUM_ID = ID locations masked by 0xF then made into a 16-bit value with ID0 as the most significant nibble.
For example,
ID0 = 0x12, ID1 = 0x37, ID2 = 0x4, ID3 = 0x26, then SUM_ID = 0x2746.
*Checksum = [Sum of all the individual expressions]
MODULO
[0xFFFF]
+ = Addition
& = Bitwise AND
Device
Code
Protect
Checksum*
Blank
Value
Ox25E6 at
0 and max
address
070D
0013
071C
030D
0F23
FC13
031C
PIC12C671
PIC12CE673
OFF
1/2
ALL
OFF
1/2
3/4
ALL
SUM[0x000:0x3FE] + CFGW & 0x3FFF
SUM[0x000:0x1FF] + CFGW & 0x3FFF + SUM_ID
CFGW & 0x3FFF + SUM_ID
SUM[0x000:0x7FE] + CFGW & 0x3FFF
SUM[0x000:0x3FF] + CFGW & 0x3FFF + SUM_ID
SUM[0x000:0x1FF] + CFGW & 0x3FFF + SUM_ID
CFGW & 0x3FFF + SUM_ID
3B3F
4E5E
3B4E
373F
5D6E
4A5E
374E
PIC12C672
PIC12CE674