English
Language : 

PIC16LF145X Datasheet, PDF (31/38 Pages) Microchip Technology – PIC16(L)F145X Memory Programming Specification
PIC16(L)F145X
EXAMPLE 7-4:
PIC16LF1459
CHECKSUM COMPUTED WITH PROGRAM CODE PROTECTION ENABLED
(CP = 0), PIC16LF1459, 00AAh AT FIRST AND LAST ADDRESS
Configuration Word 1
3F7Fh(1)
Configuration Word 1 mask
Configuration Word 2
Configuration Word 2 mask
User ID (8000h)
User ID (8001h)
User ID (8002h)
User ID (8003h)
3E7Fh
3FFFh(3)
3FF3h(4)
000Eh(5)
0008h(5)
0005h(5)
0008h(5)
Sum of User IDs
= (000Eh and 000Fh) << 12 + (0008h and 000Fh) << 8 +
(0005h and 000Fh) << 4 + (0008h and 000Fh)(6)
= E000h + 0800h + 0050h + 0008h
Checksum
= E858h
= (3F7Fh and 3E7Fh) + (3FFFh and 3FF3h) + Sum of User IDs(7)
= 3E7Fh +3FF3h + E858h
= 66CAh
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 (000Eh), AND
the address to (000Fh), thus masking the MSB. This gives you the value 000Eh, then shift left 12 bits,
giving you E000h. Do the same procedure for the 16-bit value of the second user ID location (0008h),
except shift left 8 bits. Also, do the same for the third user ID location (0005h), 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 E858h.
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) + E858h = 66CAh.
Then, truncate to 16 bits, thus having a final value of 66CAh.
 2011-2012 Microchip Technology Inc.
Advance Information
DS41620C-page 31