English
Language : 

PIC16LF145X Datasheet, PDF (30/38 Pages) Microchip Technology – PIC16(L)F145X Memory Programming Specification
PIC16(L)F145X
7.3.2
PROGRAM CODE PROTECTION
ENABLED
With the program code protection enabled, the
checksum is computed in the following manner: The
Least Significant nibble of each user ID is used to
create a 16-bit value. The masked value of user ID
location 8000h is the Most Significant nibble. This sum
of user IDs is summed with the Configuration Words (all
unimplemented Configuration bits are masked to ‘0’).
EXAMPLE 7-3:
CHECKSUM COMPUTED WITH PROGRAM CODE PROTECTION ENABLED
(CP = 0), PIC16F1459, BLANK DEVICE
PIC16F1459
Configuration Word 1
Configuration Word 1 mask
Configuration Word 2
3F7Fh(1)
3E7Fh(2)
3FFFh(3)
Configuration Word 2 mask
3FF3h(4)
User ID (8000h)
User ID (8001h)
User ID (8002h)
User ID (8003h)
0006h(5)
0007h(5)
0001h(5)
0002h(5)
Sum of User IDs = (0006h and 000Fh) << 12 + (0007h and 000Fh) << 8 +
(0001h and 000Fh) << 4 + (0002h and 000Fh)(6)
= 6000h + 0700h + 0010h + 0002h
Checksum
= 6712h
= (3F7Fh and 3E7Fh) + (3FFFh and 3FF3h) + Sum of User IDs(7)
= 3E7Fh +3FF3h + 6712h
= E584h
Note 1:
2:
3:
4:
5:
6:
7:
This value is obtained by making all bits of the Configuration Word 1 a ‘1’, but the code-protect bit is ‘0’
(thus, enabled), then converting it to hex, thus having a value of 3F7Fh.
This value is obtained by making all used bits of the Configuration Word 1 a ‘1’, but the code-protect bit
is ‘0’ (thus, enabled), then converting it to hex, thus having a value of 3E7Fh.
This value is obtained by making all bits of the Configuration Word 2 a ‘1’, then converting it to hex, thus
having a value of 3FFFh.
This value is obtained by making all used bits of the Configuration Word 2 a ‘1’, then converting it to hex,
thus having a value of 3FF3h.
These values are picked at random for this example; they could be any 16-bit value.
In order to calculate the sum of user IDs, take the 16-bit value of the first user ID location (0006h), AND
the address to (000Fh), thus masking the MSB. This gives you the value 0006h, then shift left 12 bits,
giving you 6000h. Do the same procedure for the 16-bit value of the second user ID location (0007h),
except shift left 8 bits. Also, do the same for the third user ID location (0001h), except shift left 4 bits. For
the fourth user ID location do not shift. Finally, add up all four user ID values to get the final sum of user
IDs of 6712h.
This value is obtained by ANDing the Configuration Word value with the Configuration Word Mask Value
and adding it to the sum of user IDs: (3F7Fh AND 3E7Fh) + (3FFFh AND 3FF3h) + 6712h = E584h.
Then, truncate to 16 bits, thus having a final value of E584h.
DS41620C-page 30
Advance Information
 2011-2012 Microchip Technology Inc.