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I
RB1/SDI/SDA 7 12 RB6/AN5/PGC/T1OSO/T1CKI
RB2/SDO/RX/DT 8 11 RB5/SS/TX/CK
(1)
RB3/PGM/CCP1 9 10 RB4/SCK/SCL
RA2/AN2/CVREF/VREF- 1 20 RA1/AN1
RA3/AN3/VREF+/C1OUT 2 19 RA0/AN0
RA4/AN4/T0CKI/C2OUT 3 18 RA7/OSC1/CLKI
RA5/MCLR/VPP 4 17 RA6/OSC2/CLKO
PIC16F88
VSS 5 16 VDD
AVSS 6 15 AVDD
RB0/INT/CCP1(1) 7 14 RB7/AN6/PGD/T1OSI
RB1/SDI/SDA 8 13 RB6/AN5/PGC/T1OSO/T1CKI
RB2/SDO/RX/DT 9 12 RB5/SS/TX/CK
RB3/PGM/CCP1(1) 10 11 RB4/SCK/SCL
RA3/AN3/VREF+/C1OUT
RA4/AN4/T0CKI/C2OUT
RA2/AN2/CVREF/VREF-
RA1/AN1
RA0/AN0
NC
NC
28
27
26
25
24
23
22
RA5/MCLR/VPP 1 21 RA7/OSC1/CLKI
NC 2 20 RA6/OSC2/CLKO
VSS 3 19 VDD
NC 4 PIC16F88 18 NC
AVSS 5 17 AVDD
NC 6 16 RB7/AN6/PGD/T1OSI
RB0/INT/CCP1(1) 7 15 RB6/AN5/PGC/T1OSO/T1CKI
10
11
12
13
14
8
9
NC
NC
RB1/SDI/SDA
RB3/PGM/CCP1(1)
RB2/SDO/RX/DT
RB5/SS/TX/CK
RB4/SCK/SCL
PIC16F87 4K
PIC16F88 4K
In the configuration memory space, 0x2000-0x201F
are physically implemented. However, only locations
0x2000 through 0x2008 are available. Other locations
are reserved. Locations beyond 0x201F will physically
access user memory (see Figure 3-1).
4K words
0h
2000h ID Location
2001h ID Location
Implemented
2002h ID Location
2003h ID Location
2005h Reserved
Accesses
0x0000 to
2006h Device ID 0x0FFF
2009h
Reserved
3FFFh
Program mode is entered by holding pins RB6 and RB7 The address and program counter are reset to 0x0000
low, while raising MCLR pin from VIL to VIHH (high by resetting the device (taking MCLR below VIL) and
voltage). In this mode, the state of the RB3 pin does not re-entering Programming mode. Program and
effect programming. Low-Voltage ICSP Programming configuration memory may then be read or verified
mode is entered by raising RB3 from VIL to VDD, and using the ‘Read Data’ and ‘Increment Address’
then applying VDD to MCLR. Once in this mode, the commands.
user program memory, as well as the configuration
3.4.1 LOW-VOLTAGE ICSP
memory, can be accessed and programmed in serial
fashion. The mode of operation is serial, and the PROGRAMMING MODE
memory accessed is the user program memory. RB6 Low-voltage ICSP Programming mode allows a
and RB7 are Schmitt Trigger inputs in this mode. PIC16F87/88 device to be programmed using VDD
only. However, when this mode is enabled by a
Note: The Osc must not have 72 osc clocks
Configuration bit (LVP), the PIC16F87/88 device
while the device MCLR is between VIL and
dedicates RB3 to control entry/exit into Programming
VIHH.
mode.
The sequence that enters the device into the
When the LVP bit is set to ‘1’, the Low-voltage ICSP
Programming mode places all other logic into the
Programming entry is enabled. Since the LVP
RESET state (the MCLR pin was initially at VIL). This
Configuration bit allows Low-voltage ICSP
means all I/O are in the RESET state (high-impedance
Programming entry in its erased state, an erased
inputs).
device will have the LVP bit enabled at the factory.
Note: The MCLR pin should be raised from While LVP is ‘1’, RB3 is dedicated to Low-voltage ICSP
below VIL to above the minimum VIHH Programming. The following LVP steps assume the
(VPP), within 250 µs of VDD rise. This LVP bit is set in the Configuration register.
ensures that the device always enters 1. Apply VDD to the VDD pin.
Programming mode before any
2. Drive MCLR low.
instructions that may be in program
memory can be executed. Otherwise, 3. Apply VDD to the RB3/PGM pin.
unintended instruction execution could 4. Apply VDD to the MCLR pin.
occur when the INTRC clock source is All other specifications for High-voltage ICSP apply.
configured as the primary clock. Refer to
To disable Low-voltage ICSP mode, the LVP bit must
Figure 7-1.
be programmed to ‘0’. This must be done while entered
A device RESET will clear the PC and set the address with the High-voltage Entry mode (LVP bit = 1). RB3 is
to ‘0’. The ‘Increment Address’ command will now a general purpose I/O pin.
increment the PC. The ‘Load Configuration’ command
will set the PC to 0x2000. The available commands are
shown in Table 3-1.
The normal sequence for programming four program
memory words at a time is as follows:
1. Set pointer to row location.
2. Issue a ‘Begin Erase’ command.
3. Wait tprog2.
4. Issue an ‘End Programming’ command.
5. Load a word at the current program memory
address using the ‘Load Data’ command.
6. Issue an ‘Increment Address’ command.
7. Load a word at the current program memory
address using the ‘Load Data’ command.
8. Repeat Step 6 and Step 7 two times.
9. Issue a ‘Begin Programming’ command to begin
programming.
10. Wait tprog1.
11. Issue an ‘End Programming’ command.
12. Increment to the next address.
13. Repeat steps 5 through 12 seven times to
Start
Begin
Erase
Command
Wait tprog2
End
Programming
Command
Load Data
Command
Yes
Begin
Programming Only
Command
Wait tprog1
End
Programming
Command
Verify all
Locations
Increment No All
Address Row Locations
Command Done?
Yes
Report Verify No
Error Data Correct?
Increment No All Locations
Address Done?
Command Yes
Yes End
Start
Chip Erase
Sequence
Load Data
Command
Begin
Programming Only
Command
Wait tprog1
End
Programming
Command
Increment No Yes
All Locations
Address
Done?
Command
Verify all
Locations
Report Verify No
Data Correct?
Error
Yes
End
Load Data
Report No Command
Programming Data Correct?
Failure
Yes
Increment No Four Loads
Address
Done?
Address = Command
Yes 0x2003? Yes
Increment Begin
Address No Program Only
Command Command
Increment
Address = Address
No 0x2004? Command
Wait tprog1
Yes
End
Increment Programming
Address Command
Command
End
Increment PROGRAM
Address CONFIG1
Command Start
and
CONFIG2
Load Data
Command
Increment Increment
Program Address
Address
Config1 Command
Command
Begin
Program Only
Command
Yes End
Programming
Command
End
End
CP CCPMX DEBUG WRT1 WRT0 CPD LVP BOREN MCLRE FOSC2 PWRTEN WDTEN FOSC1 FOSC0
bit 13 bit 0
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR 1 = bit is set 0 = bit is cleared x = bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR 1 = bit is set 0 = bit is cleared x = bit is unknown
6.0 CHECKSUM COMPUTATION The Least Significant 16 bits of this sum are the
checksum.
Checksum is calculated by reading the contents of the
The following table describes how to calculate the
PIC16F87/88 memory locations and totaling the
checksum for each device. Note that the checksum
opcodes, up to the maximum user-addressable
calculation differs depending on the code protect
location (e.g., 0xFFF for the PIC16F87/88). Any carry
setting. Since the program memory locations read out
bits exceeding 16 bits are neglected. Finally, the
differently depending on the code protect setting, the
Configuration Word (appropriately masked) is added to
table describes how to manipulate the actual program
the checksum. Checksum computation for each
memory values to simulate the values that would be
member of the PIC16F87/88 devices is shown in
read from a protected device. When calculating a
Table 6-1.
checksum by reading a device, the entire program
The checksum is calculated by summing the following: memory can simply be read and summed. The
• The contents of all program memory locations Configuration Words and ID locations can always be
• The Configuration Words, appropriately masked read.
• Masked ID locations (when applicable) Note that some older devices have an additional value
added in the checksum. This is to maintain compatibility
with older device programmer checksums.
VIHH
MCLR 1 s min
tset0 1 2 3 4 5 6 1 2 3 4 5 15 16
tdly2
RB6
(Clock)
thld0
}
}
100 ns min 100 ns min
FIGURE 7-2: LOAD DATA FOR USER DATA MEMORY COMMAND (PROGRAM)
VIHH
MCLR 1 s min
tset0 1 2 3 4 5 6 1 2 3 4 5 15 16
tdly2
RB6
(Clock)
thld0
}
}
VIHH
MCLR
tdly2
tset0
thld0 1 s min
1 2 3 4 5 6 1 2 3 4 5 15 16
RB6
(Clock)
tdly3
RB7 bit 13
0 0 1 0 0 X bit 0
(Data)
tset1 tdly1
thld1
1 s min
}
}
VIHH
MCLR
tdly2
tset0
thld0 1 s min
1 2 3 4 5 6 1 2 3 4 5 15 16
RB6
(Clock)
tdly3
RB7
1 0 1 0 0 X bit 0 bit 13
(Data)
tset1 tdly1
thld1
1 s min
}
}
Program Mode
Reset
VIHH
MCLR
tdly2
Next Command
1 s min.
1 2 3 4 5 6 1 2
RB6
(Clock)
RB7
0 1 1 0 X X X 0
(Data)
tset1 tdly1
thld1
1 s min.
}
100 ns min.
RB7
0 0 0 1 0 X X 0
(Data)
tset1 ?
thld1
}
100 ns min.
RB7 0 0 0 1 1 X X 0
(Data)
tset1 ?
thld1
}
100 ns min.
1 2 3 4 5 6 1 2 1 2
RB6
(Clock)
RB7
1 0 0 1 X X X 0 X 0
(Data)
tset1 ?
thld1
}
100 ns min.
1 2 3 4 5 6 1 2 1 2
RB6
(Clock)
RB7
1 1 0 1 X X X 0 X 0
(Data)
tset1 ?
thld1
}
100 ns min.
RB7
1 1 1 1 X X X 0
(Data) tdly1
tset1
1 s min.
thld1
}
100 ns min.
VDD
tpu
1 2 3 4 5
RB6
(CLOCK)
RB7
(DATA)
• Microchip believes that its family of products is one of the most secure families 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
knowledge, require using the Microchip products in a manner outside the operating specifications contained in Microchip’s Data
Sheets. Most likely, the person doing so is 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
products. Attempts to break Microchip’s code protection feature may be a violation of the Digital Millennium Copyright Act. If such acts
allow unauthorized access to your software or other copyrighted work, you may have a right to sue for relief under that Act.
01/05/10