InCircuitSerialProgramming PDF
InCircuitSerialProgramming PDF
(ICSP™) Guide
In-Circuit Serial Programming and ICSP are trademarks of Microchip Technology Inc. SQTP is a service mark of Microchip Technology Inc.
45
40
Typical
Typical
Programming Time (Seconds)
35 Flash
FLASH MCU
MCU
30
25
20
15
10 Microchip
Microchip
OTP
OTPMCU
MCU
5
0
0 1K 2K 4K 8K 16K
280
260
240
140
120
100
80
60 Microchip
Microchip
40 OTP MCU
OTP MCU
20
0
0 1K 2K 4K 8K 16K
VDD
VSS
GP0
GP1
To application circuit
Isolation circuits
PICmicro, PRO MATE and PICSTART are registered trademarks of Microchip Technology Inc.
In-Circuit Serial Programming and ICSP are trademarks of Microchip Technology Inc.
PROGRAMMING ENVIRONMENT
The programming environment will affect the type of
programmer used, the programmer cable length, and
the application circuit interface. Some programmers
are well suited for a manual assembly line while others
are desirable for an automated assembly line. A gang
programmer should be chosen for programming multi-
ple MCUs at one time. The physical distance between
the programmer and the application circuit affects the
load capacitance on each of the programming signals.
This will directly affect the drive strength needed to pro-
vide the correct signal rise rates and current. Finally,
the application circuit interface to the programmer
depends on the size constraints of the application cir-
cuit itself and the assembly line. A simple header can
be used to interface the application circuit to the pro-
grammer. This might be more desirable for a manual
assembly line where a technician plugs the
programmer cable into the board.
A different method is the uses spring loaded test pins
(often referred as pogo-pins). The application circuit
has pads on the board for each of the programming sig-
nals. Then there is a movable fixture that has pogo pins
PROGRAM MEMORY
UNPROGRAMMED
0X040 MAIN1
MAIN1 ROUTINE
0X080
UNPROGRAMMED
PROGRAM MEMORY
UNPROGRAMMED
0X040
MAIN1
MAIN1 ROUTINE
0X080
UNPROGRAMMED
0X10E MAIN2
MAIN2 ROUTINE
0X136
VCC 15V
R15
VDD_OUT
1 TO CIRCUIT
R4 Q3
2N3906
R17
10k 100
9 U1C
U1D R18 VCC
Preliminary
13 R19 8
14 10
12 TLE2144A 100 Q4
100 2N2222
VDD_IN TLE2144A D2
C4 6.2V
APPENDIX A: SAMPLE DRIVER BOARD SCHEMATIC
FROM 1NF
PROGRAMMER R21
100k R22
5k C6
0.1µF
DS91017B-page 2-7
TB017
NOTES:
In-Circuit Serial Programming™ (ICSP) is a great way 1. Isolation of the MCLR/VPP pin from the rest of
to reduce your inventory overhead and time-to-market the circuit.
for your product. By assembling your product with a 2. Isolation of pins RB6 and RB7 from the rest of
blank Microchip microcontroller (MCU), you can stock the circuit.
one design. When an order has been placed, these 3. Capacitance on each of the VDD, MCLR/VPP,
units can be programmed with the latest revision of RB6, and RB7 pins.
firmware, tested, and shipped in a very short time. This 4. Minimum and maximum operating voltage for
method also reduces scrapped inventory due to old VDD.
firmware revisions. This type of manufacturing system 5. PICmicro Oscillator.
can also facilitate quick turnarounds on custom orders
6. Interface to the programmer.
for your product.
The MCLR/VPP pin is normally connected to an RC cir-
Most people would think to use ICSP with PICmicro®
cuit. The pull-up resistor is tied to VDD and a capacitor
OTP MCUs only on an assembly line where the device
is tied to ground. This circuit can affect the operation of
is programmed once. However, there is a method by
ICSP depending on the size of the capacitor. It is, there-
which an OTP device can be programmed several
fore, recommended that the circuit in Figure 1 be used
times depending on the size of the firmware. This
when an RC is connected to MCLR/VPP. The diode
method, explained later, provides a way to field
should be a Schottky-type device. Another issue with
upgrade your firmware in a way similar to EEPROM- or
MCLR/VPP is that when the PICmicro MCU device is
Flash-based devices.
programmed, this pin is driven to approximately 13V
HOW DOES ICSP WORK? and also to ground. Therefore, the application circuit
Now that ICSP appeals to you, what steps do you take must be isolated from this voltage provided by the
to implement it in your application? There are three programmer.
main components of an ICSP system: Application
Circuit, Programmer and Programming Environment.
Vdd
Vss
RB7
RB6
To application circuit
Isolation circuits
VCC 15V
1
R2 Q1 TO CIRCUIT
APPENDIX A:
DS91013B-page 2-14
2N3906
R9
33k 100
1 U1A
U1B 2 R9 VCC
6 R10 1
7 3
5 100 Q2
100 4 TLE2144A 2N2222
VPP_IN TLE2144A D1
C1 12.7V
FROM 1NF
PROGRAMMER R12
100k R13
5k C3
0.1µF
R15
VDD_OUT
1 TO CIRCUIT
R4 Q3
2N3906
R17
10k 100
9 U1C
U1D R18 VCC
Preliminary
13 R19 8
14 10
12 TLE2144A 100 Q4
100 2N2222
VDD_IN TLE2144A D2
C4 6.2V
FROM 1NF
SAMPLE DRIVER BOARD SCHEMATIC
PROGRAMMER R21
100k R22
5k C6
0.1µF
Boot
Data L Code
Data H
TX In-Circuit
Programming
USART RX Level Converter Connector
Vdd 7805
2N3905 13V
MCLR
Serial Port RX
TX
RX MAX232
Serial Port TX
Vss
ICSP Boot Code interrupt occurs. This delay ensures that the program-
ming pulse width of 1 ms (max.) is met. Once a location
The boot code is normally programmed, into the
is written, RA2 is driven high to disable further writes
PIC17CXXX device using a PRO MATE® or
and a verify operation is done using the Table read
PICSTART® Plus or any third party programmer. As
instruction. If the result is good, an acknowledge is sent
depicted in the flowchart in Figure 5, on power-up, or a
to the host. This process is repeated till all desired loca-
reset, the program execution always vectors to the boot
tions are programmed.
code. The boot code is normally located at the bottom
of the program memory space e.g. 0x700 for a In normal operation, when the ICSP header is not con-
PIC17C42A (Figure 4). nected, the boot code would still execute and the
PIC17CXXX would send out a request to the host.
Several methods could be used to reset the
However it would not get a response from the host, so
PIC17CXXX when the ICSP header is connected to the
it would abort the boot code and start normal code
system board. The simplest method, as shown in
execution.
Figure 3, is to derive the system 5V, from the 13V sup-
plied by the ICSP header. It is quite common in manu-
facturing lines, to have system boards programmed FIGURE 4: BOOT CODE EXAMPLE FOR
with only the boot code ready and available for testing, PIC17C42A
calibration or final programming. The ICSP header
would thus supply the 13V to the system and this 13V Program Memory
would then be stepped down to supply the 5V required Reset Vector
to power the system. Please note that the 13V supply
should have enough drive capability to supply power to
the system as well as maintain the programming volt-
age of 13V.
The first action of the boot code (as shown in flowchart
Figure 5) is to configure the USART to a known baud
rate and transmit a request sequence to the ICSP host
system. The host immediately responds with an
acknowledgment of this request. The boot code then
gets ready to receive ICSP data. The host starts send-
ing the data and address byte sequences to the
0x700
PIC17CXXX. On receiving the address and data
information, the 16-bit address is loaded into the Boot Code
TBLPTR registers and the 16-bit data is loaded into the 0x7FF
TABLAT registers. The RA2 pin is driven low to enable
13V at MCLR. The PIC17CXXX device then executes
a table write instruction. This instruction in turn causes
a long write operation, which disables further code exe-
cution. Code execution is resumed when an internal
Start
Configure USART
and send request
No No
Received Host’s Time-out complete?
ACK?
Yes Yes
Prepare to receive
ICSP data Start Code
Execution
No
Received Address
and Data info?
Yes
Do Table Write
operation
No
Interrupt?
Yes
Read Program
Location
Yes
END
Main1
Main1
Main2
Boot Boot
Vdd
Vss
RB7
RB6
To application circuit
Isolation circuits
PICmicro, PRO MATE, and PICSTART are registered trademarks of Microchip Technology Inc.
In-Circuit Serial Programming and ICSP are trademarks of Microchip Technology Inc.
Vcc 15V
1
R2 Q1 TO CIRCUIT
APPENDIX A:
DS91016B-page 2-24
2N3906
R9
33k 100
1 U1A
U1B 2 R9 Vcc
6 R10 1
7 3
5 100 Q2
100 4 TLE2144A 2N2222
VPP_IN TLE2144A D1
C1 12.7V
FROM 1NF
PROGRAMMER R12
100k R13
5k C3
0.1mF
R15
VDD_OUT
1 TO CIRCUIT
R4 Q3
2N3906
R17
10k 100
9 U1C
U1D R18 Vcc
13 R19 8
14 10
12 TLE2144A 100 Q4
100 2N2222
Vdd_IN TLE2144A D2
C4 6.2V
FROM 1NF
SAMPLE DRIVER BOARD SCHEMATIC
PROGRAMMER R21
100k R22
5k C6
0.1mF
IN-CIRCUIT SERIAL PROGRAMMING FOR PIC12C67X AND PIC12CE67X OTP MCUs ................. 3-15
PIC12CE5XXA
PIC12C5XXA
PIC12C5XX
• PIC12C509 • PIC12C509A • PIC12CE519 VDD 1 8
VSS
GP5/OSC1/CLKIN 2 7 GP0
GP4/OSC2/CLKOUT 3 6 GP1
1.0 PROGRAMMING THE GP3/MCLR/Vpp 4 5 GP2/T0CKI
PIC12C5XX
The PIC12C5XX can be programmed using a serial
method. Due to this serial programming, the
PIC12C5XX can be programmed while in the user’s
system increasing design flexibility. This programming
specification applies to PIC12C5XX devices in all pack-
ages.
Incrementing the PC once (using the increment Clearly, to implement this technique, the most stringent
address command) selects location 0x000 of the regu- requirements will be that of the power supplies:
lar program memory. Afterwards all other memory loca- VPP: VPP can be a fixed 13.0V to 13.25V supply. It
tions from 0x001-01FF (PIC12C508/CE518), 0x001- must not exceed 14.0V to avoid damage to the pin and
03FF (PIC12C509/CE519) can be addressed by incre- should be current limited to approximately 100mA.
menting the PC.
VDD: 2.0V to 6.5V with 0.25V granularity. Since this
If the program counter has reached the last user pro- method calls for verification at different VDD values, a
gram location and is incremented again, the on-chip programmable VDD power supply is needed.
special EPROM area will be addressed. (See
Figure 2-2 to determine where the special EPROM Current Requirement: 40mA maximum
area is located for the various PIC12C5XX devices). Microchip may release devices in the future with differ-
ent VDD ranges which make it necessary to have a pro-
2.1 Programming Method
grammable VDD.
The programming technique is described in the follow- It is important to verify an EPROM at the voltages
ing section. It is designed to guarantee good program- specified in this method to remain consistent with
ming margins. It does, however, require a variable M i c r o c h i p ' s t e s t s c r e e n i n g . Fo r ex a m p l e , a
power supply for VCC. PIC12C5XX specified for 4.5V to 5.5V should be
2.1.1 PROGRAMMING METHOD DETAILS tested for proper programming from 4.5V to 5.5V.
Essentially, this technique includes the following steps: Note: Any programmer not meeting the programma-
ble VDD requirement and the verify at VDDmax
1. Perform blank check at VDD = VDDmin. Report and VDDmin requirement may only be classi-
failure. The device may not be properly erased. fied as “prototype” or “development” program-
2. Program location with pulses and verify after mer but not a production programmer.
each pulse at VDD = VDDP:
where VDDP = VDD range required during pro- 2.1.3 SOFTWARE REQUIREMENTS
gramming (4.5V - 5.5V).
Certain parameters should be programmable (and
a) Programming condition:
therefore easily modified) for easy upgrade.
VPP = 13.0V to 13.25V
a) Pulse width
VDD = VDDP = 4.5V to 5.5V b) Maximum number of pulses, present limit 8.
VPP must be ≥ VDD + 7.25V to keep “programming c) Number of over-programming pulses: should be
mode” active. = (A • N) + B, where N = number of pulses
b) Verify condition: required in regular programming. In our current
algorithm A = 11, B = 0.
VDD = VDDP
VPP ≥ VDD + 7.5V but not to exceed 13.25V 2.2 Programming Pulse Width
If location fails to program after “N” pulses, (sug- Program Memory Cells: When programming one
gested maximum program pulses of 8) then report word of EPROM, a programming pulse width (TPW) of
error as a programming failure. 100µs is recommended.
Note: Device must be verified at minimum and The maximum number of programming attempts
maximum specified operating voltages as should be limited to 8 per word.
specified in the data sheet. After the first successful verify, the same location
3. Once location passes “Step 2", apply 11X over should be over-programmed with 11X over-program-
programming, i.e., apply 11 times the number of ming.
pulses that were required to program the loca- Configuration Word: The configuration word for oscil-
tion. This will guarantee a solid programming lator selection, WDT (watchdog timer) disable and
margin. The over programming should be made code protection, and MCLR enable, requires a pro-
“software programmable” for easy updates. gramming pulse width (TPWF) of 10ms. A series of
4. Program all locations. 100µs pulses is preferred over a single 10ms pulse.
Start
Blank Check
@ VDD = VDDmin
Program 1 Location No
@ VPP = 13.0V to 13.25V N > 8?
VDD = VDDP
No
N=N+1
Pass? (N = # of program pulses)
Yes
All
locations
No done?
Yes
No
Pass? Report verify failure
@ VDDmin
Yes
No
Report verify failure
Pass? @ VDDmax
Yes
Now program Verify Configuration Word
Configuration Word @ VDDmax & VDDmin
Done
TTT 0 0 ID0
TTT + 1 0 0 ID1 For Customer Use
(4 x 4 bit usable)
TTT + 2 0 0 ID2
TTT + 3 0 0 ID3
TTT + 3F
NNN Highest normal EPROM memory address. NNN = 0x1FF for PIC12C508/CE518.
NNN = 0x3FF for PIC12C509/CE519.
Note that some versions will have an oscillator calibration value programmed at NNN
TTT Start address of special EPROM area and ID locations.
To allow portability of code, the programmer is required to read the configuration word and ID locations from the hex
file when loading the hex file. If configuration word information was not present in the hex file then a simple warning
message may be issued. Similarly, while saving a hex file, configuration word and ID information must be included.
An option to not include this information may be provided.
Microchip Technology Inc. feels strongly that this feature is important for the benefit of the end customer.
PIC12C508A
To code protect:
• (CP enable pattern: XXXXXXXX0XXX)
PIC12CE518
To code protect:
• (CP enable pattern: XXXXXXXX0XXX)
Program Memory Segment R/W in Protected Mode R/W in Unprotected Mode
Configuration Word (0xFFF) Read enabled, Write Enabled Read enabled, Write Enabled
[0x00:0x3F] Read enabled, Write Enabled Read enabled, Write Enabled
[0x40:0x1FE] Read disabled (all 0’s), Write Disabled Read enabled, Write Enabled
0x1FF Oscillator Calibration Value Read enabled, Write Enabled Read enabled, Write Enabled
ID Locations (0x200 : 0x203) Read enabled, Write Enabled Read enabled, Write Enabled
PIC12CE519
To code protect:
• (CP enable pattern: XXXXXXXX0XXX))
Program Memory Segment R/W in Protected Mode R/W in Unprotected Mode
Configuration Word (0xFFF) Read enabled, Write Enabled Read enabled, Write Enabled
[0x00:0x3F] Read enabled, Write Enabled Read enabled, Write Enabled
[0x40:0x3FF] Read disabled (all 0’s), Write Disabled Read enabled, Write Enabled
ID Locations (0x400 : 0x403) Read enabled, Write Enabled Read enabled, Write Enabled
0x723 at
Code Blank
Device Checksum* 0 and max
Protect Value
address
PIC12C508 OFF SUM[0x000:0x1FE] + CFGW & 0x01F EE20 DC68
ON SUM[0x000:0x03F] + CFGW & 0x01F + SUM(IDS) EDF7 D363
PIC12C508A OFF SUM[0x000:0x1FE] + CFGW & 0x01F EE20 DC68
ON SUM[0x000:0x03F] + CFGW & 0x01F + SUM(IDS) EDF7 D363
PIC12C509 OFF SUM[0x000:0x3FE] + CFGW & 0x01F EC20 DA68
ON SUM[0x000:0x03F] + CFGW & 0x01F + SUM(IDS) EBF7 D163
PIC12C509A OFF SUM[0x000:0x3FE] + CFGW & 0x01F EC20 DA68
ON SUM[0x000:0x03F] + CFGW & 0x01F + SUM(IDS) EBF7 D163
PIC12CE518 OFF SUM[0x000:0x1FE] + CFGW & 0x01F EE20 DC68
ON SUM[0x000:0x03F] + CFGW & 0x01F + SUM(IDS) EDF7 D363
PIC12CE519 OFF SUM[0x000:0x3FE] + CFGW & 0x01F EC20 DA68
ON SUM[0x000:0x03F] + CFGW & 0x01F + SUM(IDS) EBF7 D163
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
Parameter
Sym. Characteristic Min. Typ. Max. Units Conditions
No.
General
PD1 VDDP Supply voltage during programming 4.75 5.0 5.25 V
PD2 IDDP Supply current (from VDD) 20 mA
during programming
PD3 VDDV Supply voltage during verify VDDmin VDDmax V Note 1
PD4 VIHH1 Voltage on MCLR/VPP during 12.75 13.25 V Note 2
programming
PD5 VIHH2 Voltage on MCLR/VPP during verify VDD + 4.0 13.5
PD6 IPP Programming supply current (from 50 mA
VPP)
PD9 VIH1 (GP1, GP0) input high level 0.8 VDD V Schmitt Trigger input
PD8 VIL1 (GP1, GP0) input low level 0.2 VDD V Schmitt Trigger input
}
}
}
}
100ns 100ns
min. min.
Program/Verify Mode
Reset
VIHH
MCLR/VPP 100ns P6
P8
1 2 3 4 5 6 1ms min. 1 2 3 4 5 15
GP1
(CLOCK)
100ns P7
GP0 0 0 1 0 0 0
(DATA) P5
P4
P3 1ms min.
}
}
100ns
min. GP0
GP0 = output input
Program/Verify Mode
Reset
GP0
0 1 1 0 0 0 0 0
(DATA)
P5
P3 P4 1ms min.
}
}
100ns
min
Program/Verify Mode
Reset
PIC12C67X
VDD 1 8 VSS
• PIC12CE673 GP5/OSC1/CLKIN 2 7 GP0/AN0
GP4/OSC2/AN3/
• PIC12CE674 CLKOUT 3 6 GP1/AN1/VREF
GP3/MCLR/VPP 4 5 GP2/T0CKI/
AN2/INT
1.0 PROGRAMMING THE
PIC12C67X AND PIC12CE67X
PDIP, JW
The PIC12C67X and PIC12CE67X can be pro-
grammed using a serial method. In serial mode the
PIC12CE67X
VDD 1 8 VSS
PIC12C67X and PIC12CE67X can be programmed GP5/OSC1/CLKIN 2 7 GP0/AN0
while in the users system. This allows for increased GP4/OSC2/AN3/
CLKOUT 3 6 GP1/AN1/VREF
design flexibility. GP3/MCLR/VPP 4 5 GP2/T0CKI/
AN2/INT
1.1 Hardware Requirements
The PIC12C67X and PIC12CE67X requires two pro-
grammable power supplies, one for VDD (2.0V to 6.0V
recommended) and one for VPP (12V to 14V). Both
supplies should have a minimum resolution of 0.25V.
2000 ID Location
0 1KW 2KW
1FF
3FF Implemented Implemented
2001 ID Location
400
7FF Implemented
2002 ID Location
800
Reserved
2007 Configuration Word
1FFF
2000
2008
Reserved Reserved
2100
Reserved Reserved
3FFF
The program/verify mode is entered by holding pins The GP1 pin is used as a clock input pin, and the GP0
GP1 and GP0 low while raising MCLR pin from VIL to pin is used for entering command bits and data input/
VIHH (high voltage). VDD is then raised from VIL to output during serial operation. To input a command, the
VIH.Once in this mode the user program memory and clock pin (GP1) is cycled six times. Each command bit
the configuration memory can be accessed and pro- is latched on the falling edge of the clock with the least
grammed in serial fashion. The mode of operation is significant bit (LSB) of the command being input first.
serial, and the memory that is accessed is the user pro- The data on pin GP0 is required to have a minimum
gram memory. GP1 is a Schmitt Trigger input in this setup and hold time (see AC/DC specs) with respect to
mode. the falling edge of the clock. Commands that have data
associated with them (read and load) are specified to
The sequence that enters the device into the program-
have a minimum delay of 1µs between the command
ming/verify mode places all other logic into the reset
and the data. After this delay the clock pin is cycled 16
state (the MCLR pin was initially at VIL). This means
times with the first cycle being a start bit and the last
that all I/O are in the reset state (High impedance
cycle being a stop bit. Data is also input and output LSB
inputs).
first. Therefore, during a read operation the LSB will be
Note 1:The MCLR pin must be raised from VIL transmitted onto pin GP0 on the rising edge of the sec-
to VIHH before VDD is applied. This is to ond cycle, and during a load operation the LSB will be
ensure that the device does not have the latched on the falling edge of the second cycle. A min-
PC incremented while in valid operation imum 1µs delay is also specified between consecutive
range. commands.
Note 2:Do not power GP2, GP4 or GP5 All commands are transmitted LSB first. Data words
before VDD is applied. are also transmitted LSB first. The data is transmitted
on the rising edge and latched on the falling edge of the
clock. To allow for decoding of commands and reversal
of data pin configuration, a time separation of at least
1µs is required between a command and a data word
(or another command).
The commands that are available are listed in Table .
Start
N=0
No
Yes Report Programming
Program Cycle N > 25 Failure
Read Data
Command N=N+1
N = # of Program Cycles
No
Increment Address
Command Data Correct?
Yes
Program Cycle
Apply 3N Additional
Program Cycles Load Data
Command
No
All Locations Done?
Begin Programming
Command
Yes
No Report Verify
Data Correct? @ VDD MIN. Error End Programming
Command
Yes
No
Report Verify
Data Correct? @ VDD MAX Error
Yes
Done
Start
Load Configuration
Command
N=0
Increment Address No
Command N=N+1
N = # of Program Data Correct?
Cycles
Yes
No
Address = 2004 No
N > 25
Yes
Yes
Increment Address
Command ID/Configuration Apply 3N
Error Program Cycles
Increment Address
Command
No
Data Correct?
Yes
To allow portability of code, the programmer is required to read the configuration word and ID locations from the hex
file when loading the hex file. If configuration word information was not present in the hex file then a simple warning
message may be issued. Similarly, while saving a hex file, configuration word and ID information must be included.
An option to not include this information may be provided.
Microchip Technology Inc. feels strongly that this feature is important for the benefit of the end customer.
PIC12C672, PIC12CE674
To code protect:
• Protect all memory 00 0000 X00X XXXX
• Protect 0200h-07FFh 01 0101 X01X XXXX
• Protect 0400h-07FFh 10 1010 X10X XXXX
• No code protection 11 1111 X11X XXXX
Program Memory Segment R/W in Protected Mode R/W in Unprotected Mode
Configuration Word (0x2007) Read Unscrambled, Write Enabled Read Unscrambled, Write Enabled
Unprotected memory segment Read Unscrambled, Write Enabled Read Unscrambled, Write Enabled
Protected memory segment Read All 0’s, Write Disabled Read Unscrambled, Write Enabled
ID Locations (0x2000 : 0x2003) Read Unscrambled, Write Enabled Read Unscrambled, Write Enabled
INTRC Calibration Word (0X7FF) Read Unscrambled, Write Enabled Read Unscrambled, Write Enabled
Parameter
Sym. Characteristic Min. Typ. Max. Units Conditions
No.
General
PD1 VDDP Supply voltage during programming 4.75 5.0 5.25 V
PD2 IDDP Supply current (from VDD) 20 mA
during programming
PD3 VDDV Supply voltage during verify VDDmin VDDmax V Note 1
PD4 VIHH1 Voltage on MCLR/VPP during 12.75 13.25 V Note 2
programming
PD5 VIHH2 Voltage on MCLR/VPP during verify VDD + 4.0 13.5
PD6 IPP Programming supply current (from 50 mA
VPP)
PD9 VIH1 (GP0, GP1) input high level 0.8 VDD V Schmitt Trigger input
PD8 VIL1 (GP0, GP1) input low level 0.2 VDD V Schmitt Trigger input
}
}
}
}
100ns 100ns
min. min.
Program/Verify Mode
Reset
100ns
min. RB7
RB7 = output input
Program/Verify Mode
Reset
VDD
P9
VIHH
MCLR/VPP
P6
Next Command
1µs min.
1 2 3 4 5 6 1 2
GP1
(CLOCK)
GP0
0 1 1 0 0 0 0 0
(DATA)
P5
P3 P4 1µs min.
}
}
100ns
min
Program/Verify Mode
Reset
RA1/AN1 •1 28 RA2/AN2
RA0/AN0 2 27 RA3/AN3
RD3/REFB 3 26 RD4/AN4
1.0 PROGRAMMING THE PIC14000 RD2/CMPB 4 25 RD5/AN5
PIC14000
RD1/SDAB 5 24 RD6/AN6
The PIC14000 can be programmed using a serial RD0/SCLB 6 23 RD7/AN7
OSC2/CLKOUT 7 22 CDAC
method. In serial mode the PIC14000 can be pro- 21
OSC1/PBTN 8 SUM
grammed while in the users system. This allows for VDD 9 20 VSS
increased design flexibility. This programming specifi- VREG 10 19 RC0/REFA
RC7/SDAA 11 18 RC1/CMPA
cation applies to PIC14000 devices in all packages. RC6/SCLA 12 17 RC2
RC5 13 16 RC3/T0CKI
1.1 Hardware Requirements MCLR/VPP 14 15 RC4
0
Program
0FBF
2000 ID Location 0FC0
Calibration
0FFF
2001 ID Location
2002 ID Location
2003 ID Location
Reserved
2004 Reserved
2005 Reserved
2006 Reserved
Test
20FF
Reserved
3FFF
2.2.1 PROGRAM/VERIFY OPERATION After receiving this command, the program counter
(PC) will be set to 0x2000. By then applying 16 cycles
The RB6 pin is used as a clock input pin, and the RB7 to the clock pin, the chip will load 14-bits a “data word”
pin is used for entering command bits and data input/ as described above, to be programmed into the config-
output during serial operation. To input a command, the uration memory. A description of the memory mapping
clock pin (RC6) is cycled six times. Each command bit schemes for normal operation and configuration mode
is latched on the falling edge of the clock with the least operation is shown in Figure 2-1. After the configura-
significant bit (LSB) of the command being input first. tion memory is entered, the only way to get back to the
The data on pin RC7 is required to have a minimum user program memory is to exit the program/verify test
setup and hold time (see AC/DC specs) with respect to mode by taking MCLR low (VIL).
the falling edge of the clock. Commands that have data
associated with them (read and load) are specified to
TABLE 2-1: COMMAND MAPPING
Command Mapping (MSB ... LSB) Data
Load Configuration 0 0 0 0 0 0 0, data(14), 0
Load Data 0 0 0 0 1 0 0, data(14), 0
Read Data 0 0 0 1 0 0 0, data(14), 0
Increment Address 0 0 0 1 1 0
Begin programming 0 0 1 0 0 0
End Programming 0 0 1 1 1 0
Note: The CPU clock must be disabled during in-circuit programming (to avoid incrementing the PC).
Start
N=0
No
Yes Report Programming
Program Cycle N > 25
Failure
Read Data
Command N=N+1 N=#
of Program Cycles
No
Increment Address Data Correct?
Command
Yes
Apply 3N Additional
Program Cycles
Program Cycle
Load Data
No
All Locations Done? Command
Yes
Verify all Locations Begin Programming
@ VDD min.* Command
VPP = VIHH2
Wait 100 µs
No Report Verify
Data Correct?
@ VDD min. Error
Yes End Programming
Verify all Locations Command
@ VDD max.
VPP = VIHH2
No Report Verify
Data Correct?
@ VDD max. Error
Yes
* VDDP = VDD range for programming (typically 4.75V - 5.25V).
VDDmin = Minimum VDD for deviceDone
operation.
VDDmax = Maximum VDD for device operation.
Start
Load Configuration
Command
N=0
Increment Address No
Command N=N+1N=# Data Correct?
of Program Cycles
Yes
No
Address = 2004 No
N > 25
Yes
Yes
Increment Address
Command Report ID Apply 3N
Configuration Error Program Cycles
Increment Address
Command
No
Data Correct?
Yes
CPP<1:0>
11: All Unprotected
10: N/A
01: N/A
00: All Protected
bit 1,6: F Internal trim, factory programmed. DO NOT CHANGE! Program as ‘1’. Note 1.
bit 3: PWRTE, Power Up Timer Enable Bit
0 = Power up timer enabled
1 = Power up timer disabled (unprogrammed)
bit 2: WDTE, WDT Enable Bit
0 = WDT disabled
1 = WDT enabled (unprogrammed)
bit 0: FOSC<1:0>, Oscillator Selection Bit
0: HS oscillator (crystal/resonator)
1: Internal RC oscillator (unprogrammed)
To allow portability of code, the programmer is required to read the configuration word and ID locations from the hex
file when loading the hex file. If configuration word information was not present in the hex file then a simple warning
message may be issued. Similarly, while saving a hex file, configuration word and ID information must be included.
An option to not include this information may be provided.
Microchip Technology Inc. feels strongly that this feature is important for the benefit of the end customer.
0x25E6 at
Code Blank
Checksum* 0 and max
Protect Value
address
Parameter
Sym. Characteristic Min. Typ. Max. Units Conditions
No.
General
PD1 VDDP Supply voltage during programming 4.75 5.0 5.25 V
PD2 IDDP Supply current (from VDD) – – 20 mA
during programming
PD3 VDDV Supply voltage during verify VDDmin VDDmax V Note 1
PD4 VIHH1 Voltage on MCLR/VPP during 12.75 – 13.25 V Note 2
programming
PD5 VIHH2 Voltage on MCLR/VPP during verify VDD + 4.0 13.5
PD6 IPP Programming supply current (from – – 50 mA
VPP)
PD9 VIH1 (RC6, RC7) input high level 0.8 VDD – – V Schmitt Trigger input
PD8 VIL1 (RC6, RC7) input low level 0.2 VDD – – V Schmitt Trigger input
}
}
}
}
100ns 100ns
min. min.
Program/Verify Test Mode
Reset
VIHH
MCLR/VPP 100ns P6
P8
1 2 3 4 5 6 1µs min. 1 2 3 4 5 15
RC6
(CLOCK)
100ns P7
RC7 0 0 1 0 0 0
(DATA) P5
P4
P3 1µs min.
}
}
100ns
min. RC7
RC7 = output input
RC7
0 1 1 0 0 0 0 0
(DATA)
P5
P3 P4 1µs min.
}
}
100ns
min
Program/Verify Test Mode
Reset
PIC16C55X
In-Circuit Serial Programming for PIC16C55X OTP MCUs
This document includes the programming PIN Diagrams
specifications for the following devices:
PDIP, SOIC, Windowed CERDIP
• PIC16C554
• PIC16C556
RA2 •1 18 RA1
• PIC16C558 RA3 2 17 RA0
PIC16C55X
RA4/T0CKI 3 16 OSC1/CLKIN
MCLR 4 15 OSC2/CLKOUT
VSS 5 14 VDD
1.0 PROGRAMMING THE RB0/INT
RB1
6
7
13
12
RB7
RB6
PIC16C55X RB2
RB3
8
9
11
10
RB5
RB4
The PIC16C55X can be programmed using a serial
method. In serial mode the PIC16C55X can be pro-
grammed while in the users system. This allows for
increased design flexibility. SSOP
PIC16C55X
The PIC16C55X requires two programmable power RA4/T0CKI 3 18 OSC1/CLKIN
MCLR 4 17 OSC2/CLKOUT
supplies, one for VDD (2.0V to 6.5V recommended) and VSS 5 16 VDD
VSS 6 15 VDD
one for VPP (12V to 14V). Both supplies should have a RB0/INT 7 14 RB7
minimum resolution of 0.25V. RB1 8 13 RB6
RB2 9 12 RB5
RB3 10 11 RB4
1.2 Programming Mode
The programming mode for the PIC16C55X allows pro-
gramming of user program memory, special locations
used for ID, and the configuration word for the
PIC16C55X.
PIC16C55X
2.0 PROGRAM MODE ENTRY
2.1 User Program Memory Map
The user memory space extends from 0x0000 to
0x1FFF (8K). Table 2-1 shows actual implementation
of program memory in the PIC16C55X family.
TABLE 2-1: IMPLEMENTATION OF
PROGRAM MEMORY IN THE
PIC16C55X
Access to
Device Program Memory Size Program
Memory
PIC16C554 0x000 - 0x1FF (0.5K) PC<8:0>
PIC16C556 0x000 - 0x3FF (1K) PC<9:0>
PIC16C558 0x000 - 0x7FF (2K) PC<10:0>
PIC16C55X
FIGURE 2-1: PROGRAM MEMORY MAPPING
Reserved
2005 Reserved
Reserved
2006 Reserved
2100
3FFF
PIC16C55X
2.2 Program/Verify Mode setup and hold time (see AC/DC specs) with respect to
the falling edge of the clock. Commands that have data
The program/verify mode is entered by holding pins associated with them (read and load) are specified to
RB6 and RB7 low while raising MCLR pin from VIL to have a minimum delay of 1µs between the command
VIHH (high voltage). Once in this mode the user pro- and the data. After this delay the clock pin is cycled 16
gram memory and the configuration memory can be times with the first cycle being a start bit and the last
accessed and programmed in serial fashion. The mode cycle being a stop bit. Data is also input and output LSB
of operation is serial, and the memory that is accessed first. Therefore, during a read operation the LSB will be
is the user program and configuration memory. RB6 is transmitted onto pin RB7 on the rising edge of the sec-
a Schmitt Trigger input in this mode. ond cycle, and during a load operation the LSB will be
The sequence that enters the device into the program- latched on the falling edge of the second cycle. A min-
ming/verify mode places all other logic into the reset imum 1µs delay is also specified between consecutive
state (the MCLR pin was initially at VIL). This means commands.
that all I/O are in the reset state (High impedance The commands that are available are listed
inputs). in Table 2-1.
Note: The MCLR pin should be raised as quickly 2.2.1.1 LOAD CONFIGURATION
as possible from VIL to VIHH. this is to
ensure that the device does not have the After receiving this command, the program counter
PC incremented while in valid operation (PC) will be set to 0x2000. By then applying 16 cycles
range. to the clock pin, the chip will load 14-bits a “data word”
as described above, to be programmed into the config-
2.2.1 PROGRAM/VERIFY OPERATION uration memory. A description of the memory mapping
The RB6 pin is used as a clock input pin, and the RB7 schemes for normal operation and configuration mode
pin is used for entering command bits and data input/ operation is shown in Figure 2-1. After the configura-
output during serial operation. To input a command, the tion memory is entered, the only way to get back to the
clock pin (RB6) is cycled six times. Each command bit user program memory is to exit the program/verify test
is latched on the falling edge of the clock with the least mode by taking MCLR low (VIL).
significant bit (LSB) of the command being input first.
The data on pin RB7 is required to have a minimum
TABLE 2-1: COMMAND MAPPING
Command Mapping (MSB ... LSB) Data
Load Configuration 0 0 0 0 0 0 0, data(14), 0
Load Data 0 0 0 0 1 0 0, data(14), 0
Read Data 0 0 0 1 0 0 0, data(14), 0
Increment Address 0 0 0 1 1 0
Begin programming 0 0 1 0 0 0
End Programming 0 0 1 1 1 0
Note: The CPU clock must be disabled during in-circuit programming.
PIC16C55X
FIGURE 2-2: PROGRAM FLOW CHART - PIC16C55X PROGRAM MEMORY
Start
N=0
No
Yes Report Programming
Program Cycle N > 25
Failure
Read Data
Command N=N+1 N=#
of Program Cycles
No
Increment Address Data Correct?
Command
Yes
Apply 3N Additional
Program Cycles
Program Cycle
Load Data
No
All Locations Done? Command
Yes
Verify all Locations Begin Programming
@ VDD min.* Command
VPP = VIHH2
Wait 100 µs
No Report Verify
Data Correct?
@ VDD min. Error
Yes End Programming
Verify all Locations Command
@ VDD max.
VPP = VIHH2
No Report Verify
Data Correct?
@ VDD max. Error
Yes
Done
PIC16C55X
FIGURE 2-3: PROGRAM FLOW CHART - PIC16C55X CONFIGURATION WORD & ID LOCATIONS
Start
Load Configuration
Command
N=0
Increment Address No
Command N=N+1N=# Data Correct?
of Program Cycles
Yes
No
Address = 2004 No
N > 25
Yes
Yes
Increment Address
Command ID/Configuration Apply 3N
Error Program Cycles
Increment Address
Command
No
Data Correct?
Yes
PIC16C55X
2.2.1.2 LOAD DATA 2.3 Programming Algorithm Requires
Variable VDD
After receiving this command, the chip will load in a
14-bit “data word” when 16 cycles are applied, as The PIC16C55X uses an intelligent algorithm. The
described previously. A timing diagram for the load data algorithm calls for program verification at VDDmin as
command is shown in Figure 5-1. well as VDDmax. Verification at VDDmin guarantees
good “erase margin”. Verification at VDDmax guaran-
2.2.1.3 READ DATA
tees good “program margin”.
After receiving this command, the chip will transmit The actual programming must be done with VDD in the
data bits out of the memory currently accessed starting VDDP range (4.75 - 5.25V).
with the second rising edge of the clock input. The RB7
VDDP = VCC range required during programming.
pin will go into output mode on the second rising clock
edge, and it will revert back to input mode (hi-imped- VDD min. = minimum operating VDD spec for the part.
ance) after the 16th rising edge. A timing diagram of VDD max.= maximum operating VDD spec for the part.
this command is shown in Figure 5-2.
Programmers must verify the PIC16C55X at its speci-
2.2.1.4 INCREMENT ADDRESS fied VDDmax and VDDmin levels. Since Microchip may
introduce future versions of the PIC16C55X with a
The PC is incremented when this command is broader VDD range, it is best that these levels are user
received. A timing diagram of this command is shown selectable (defaults are ok).
in Figure 5-3.
Note: Any programmer not meeting these
2.2.1.5 BEGIN PROGRAMMING requirements may only be classified as
“prototype” or “development” programmer
A load command (load configuration or load data) but not a “production” quality programmer.
must be given before every begin programming
command. Programming of the appropriate memory
(test program memory or user program memory) will
begin after this command is received and decoded.
Programming should be performed with a series of
100µs programming pulses. A programming pulse is
defined as the time between the begin programming
command and the end programming command.
PIC16C55X
3.0 CONFIGURATION WORD
The PIC16C55X family members have several configu-
ration bits. These bits can be programmed (reads ’0’) or
left unprogrammed (reads ’1’) to select various device
configurations. Figure 3-1 provides an overview of con-
figuration bits.
PIC16C55X
4.0 CODE PROTECTION 4.1 Programming Locations 0x0000 to
0x03F after Code Protection
The program code written into the EPROM can be pro-
tected by writing to the CP0 & CP1 bits of the configu- For PIC16C55X devices, once code protection is
ration word. enabled, all protected segments read '0's (or “garbage
values”) and are prevented from further programming.
All unprotected segments, including ID locations and
configuration word, read normally. These locations can
be programmed.
To allow portability of code, the programmer is required to read the configuration word and ID locations from the hex
file when loading the hex file. If configuration word information was not present in the hex file then a simple warning
message may be issued. Similarly, while saving a hex file, configuration word and ID information must be included.
An option to not include this information may be provided.
Microchip Technology Inc. feels strongly that this feature is important for the benefit of the end customer.
PIC16C556
To code protect:
• Protect all memory 0000001000XXXX
• Protect upper 1/2 memory 0101011001XXXX
• No code protection 1111111011XXXX
Program Memory Segment R/W in Protected Mode R/W in Unprotected Mode
Configuration Word (0x2007) Read Unscrambled, Write Enabled Read Unscrambled, Write Enabled
Protected memory segment Read All 0’s, Write Disabled Read Unscrambled, Write Enabled
ID Locations (0x2000 : 0x2003) Read Unscrambled, Write Enabled Read Unscrambled, Write Enabled
PIC16C558
To code protect:
• Protect all memory 0000001000XXXX
• Protect upper 3/4 memory 0101011001XXXX
• Protect upper 1/2 memory 1010101010XXXX
• No code protection 1111111011XXXX
Program Memory Segment R/W in Protected Mode R/W in Unprotected Mode
Configuration Word (0x2007) Read Unscrambled, Write Enabled Read Unscrambled, Write Enabled
Protected memory segment Read All 0’s, Write Disabled Read Unscrambled, Write Enabled
ID Locations (0x2000 : 0x2003) Read Unscrambled, Write Enabled Read Unscrambled, Write Enabled
PIC16C55X
4.3 Checksum The following table describes how to calculate the
checksum for each device. Note that the checksum cal-
4.3.1 CHECKSUM CALCULATIONS culation differs depending on the code protect setting.
Since the program memory locations read out differ-
Checksum is calculated by reading the contents of the
ently depending on the code protect setting, the table
PIC16C55X memory locations and adding up the
describes how to manipulate the actual program mem-
opcodes up to the maximum user addressable location,
ory values to simulate the values that would be read
e.g., 0x1FF for the PIC16C74. Any carry bits exceeding
from a protected device. When calculating a checksum
16-bits are neglected. Finally, the configuration word
by reading a device, the entire program memory can
(appropriately masked) is added to the checksum.
simply be read and summed. The configuration word
Checksum computation for each member of the
and ID locations can always be read.
PIC16C55X devices is shown in Table .
Note that some older devices have an additional value
The checksum is calculated by summing the following:
added in the checksum. This is to maintain compatibil-
• The contents of all program memory locations ity with older device programmer checksums.
• The configuration word, appropriately masked
• Masked ID locations (when applicable)
The least significant 16 bits of this sum is the check-
sum.
PIC16C55X
5.0 PROGRAM/VERIFY MODE ELECTRICAL CHARACTERISTICS
TABLE 5-1: AC/DC CHARACTERISTICS
TIMING REQUIREMENTS FOR PROGRAM/VERIFY TEST MODE
Standard Operating Conditions
Operating Temperature: +10°C ≤ TA ≤ +40°C, unless otherwise stated, (25°C is recommended)
Operating Voltage: 4.5V ≤ VDD ≤ 5.5V, unless otherwise stated.
Parameter
Sym. Characteristic Min. Typ. Max. Units Conditions
No.
General
PD1 VDDP Supply voltage during programming 4.75 5.0 5.25 V
PD2 IDDP Supply current (from VDD) - - 20 mA
during programming
PD3 VDDV Supply voltage during verify VDDmin - VDDmax V Note 1
PD4 VIHH1 Voltage on MCLR/VPP during 12.75 - 13.25 V Note 2
programming
PD5 VIHH2 Voltage on MCLR/VPP during verify VDD + 4.0 - 13.5 -
PD6 IPP Programming supply current (from - - 50 mA
VPP)
PD9 VIH1 (RB6, RB7) input high level 0.8 VDD - - V Schmitt Trigger input
PD8 VIL1 (RB6, RB7) input low level 0.2 VDD - - V Schmitt Trigger input
PIC16C55X
FIGURE 5-1: LOAD DATA COMMAND (PROGRAM/VERIFY)
VIHH
MCLR/VPP
100ns P6
P8
1 2 3 4 5 6 1µs min. 1 2 3 4 5 15
RB6
(CLOCK)
100ns
RB7 0 0 0 0
(DATA) 1 0 0 0
P5
P3
P4
P4 1µs min. P3
}
}
}
}
100ns 100ns
min. min.
Program/Verify Test Mode
Reset
VIHH
MCLR/VPP 100ns P6
P8
1 2 3 4 5 6 1µs min. 1 2 3 4 5 15
RB6
(CLOCK)
100ns P7
RB7 0 0 1 0 0 0
(DATA) P5
P4
P3 1µs min.
}
}
100ns
min. RB7
RB7 = output input
RB7
0 1 1 0 0 0 0 0
(DATA)
P5
P3 P4 1µs min.
}
}
100ns
min
Program/Verify Test Mode
Reset
PIC16C74/74A/74B/77/765
PIC16C64/64A/65/65A/67
RA1 3 38 RB5
• PIC16C62A • PIC16C73A • PIC16CE625 RA2 4 37 RB4
RA3 5 36 RB3
• PIC16C62B • PIC16C73B • PIC16C710 RA4/T0CKI 6 35 RB2
RA5 7 34 RB1
• PIC16C63 • PIC16C74 • PIC16C711 RE0 8 33 RB0/INT
RE1 9 32 VDD
• PIC16C63A • PIC16C74A • PIC16C712 RE2 10 31 VSS
• PIC16C64 • PIC16C74B • PIC16C716 VDD
VSS
11
12
30
29
RD7
RD6
• PIC16C64A • PIC16C76 • PIC16C745 OSC1/CLKIN 13 28 RD5
OSC2/CLKOUT 14 27 RD4
• PIC16C65 • PIC16C77 • PIC16C765 RC0 15 26 RC7
RC1 16 25 RC6
• PIC16C65A • PIC16C620 • PIC16C773 RC2 17 24 RC5
RC3 18 23 RC4
• PIC16C65B • PIC16C620A • PIC16C774 RD0 19 22 RD3
RD1 20 21 RD2
• PIC16C66 • PIC16C621 • PIC16C923
• PIC16C67 • PIC16C621A • PIC16C924
PDIP, SOIC, Windowed CERDIP (300 mil)
• PIC16C71 • PIC16C622
28 RB7
• PIC16C72 • PIC16C622A MCLR/VPP •1
PIC16C73/73A/73B/76/745
PIC16C62/62A/63/66/72/72A
RA0 2 27 RB6
RA1 3 26 RB5
RA2 4 25 RB4
1.0 PROGRAMMING THE RA3 5 24 RB3
PIC16C6XX/7XX/9XX RA4/T0CKI
RA5
6
7
23
22
RB2
RB1
VSS 8 21 RB0/INT
The PIC16C6XX/7XX/9XX can be programmed using a OSC1/CLKIN 9 20 VDD
serial method. In serial mode the PIC16C6XX/7XX/ OSC2/CLKOUT 10 19 VSS
RC0 11 18 RC7
9XX can be programmed while in the users system. 17 RC6
RC1 12
This allows for increased design flexibility. This pro- RC2 13 16 RC5
gramming specification applies to PIC16C6XX/7XX/ RC3 14 15 RC4
PDIP, SOIC, Windowed CERDIP 300 mil. SDIP, SOIC, Windowed CERDIP, SSOP
RA2 •1 18 RA1
MCLR/VPP •1 28 RB7
PIC16C710/711
2 17 RA0
PIC16C62X
PIC16C61/71
RA3 RA0/AN0 2 27 RB6
RA4/T0CKI 3 16 OSC1/CLKIN
RA1/AN1 3 26 RB5
MCLR/VPP 4 15 OSC2/CLKOUT RA2/AN2/VREF-/VRL 4 25 RB4
14 VDD
PIC16C773
VSS 5 RA3/AN3/VREF+/VRH 5 24 RB3/AN9/LVDIN
RA3/AN3/VREF 2 19 RA0/AN0
MCLR/VPP 4 15 OSC2/CLKOUT
RA4/T0CKI 3 18 OSC1/CLKIN
PIC16C716
PIC16C712
VSS 5 14 VDD
MCLR/VPP 4 17 OSC2/CLKOUT
RB0/INT 6 13 RB7
VSS 5 16 VDD
RB1/T1OSO/T1CKI 7 12 RB6
VSS 6 15 VDD
RB2/T1OSI 8 11 RB5
RB0/INT 7 14 RB7
RB3/CCP1 9 10 RB4
RB1/T1OSO/T1CKI 8 13 RB6
RB2/T1OSI 9 12 RB5
RB3/CCP1 10 11 RB4
RD7/SEG31/COM1
RD6/SEG30/COM2
RA3/AN3/VREF
MCLR/VPP
RA2/AN2
RA1/AN1
RA0/AN0
PLCC
COM0
RB2
RB3
RB4
RB5
RB7
RB6
VDD
VSS
N/C
9
8
7
6
5
4
3
2
1
68
67
66
65
64
63
62
61
RA4/T0CKI 10 60 RD5/SEG29/COM3
RA5/AN4/SS 11 59 RG6/SEG26
RB1 12 58 RG5/SEG25
RB0/INT 13 57 RG4/SEG24
RC3/SCK/SCL 14 56 RG3/SEG23
RC4/SDI/SDA 15 55 RG2/SEG22
RC5/SDO 16 54 RG1/SEG21
C1
C2
17
18
PIC16C923 53
52
RG0/SEG20
RG7/SEG28
VLCD2
VLCD3
19
20
PIC16C924 51
50
RF7/SEG19
RF6/SEG18
AVDD 21 49 RF5/SEG17
VDD 22 48 RF4/SEG16
VSS 23 47 RF3/SEG15
OSC1/CLKIN 24 46 RF2/SEG14
OSC2/CLKOUT 25 45 RF1/SEG13
RC0/T1OSO/T1CKI 26 44 RF0/SEG12
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
VLCDADJ
RC1/T1OSI
RC2/CCP1
VLCD1
RD0/SEG00
RD1/SEG01
RD2/SEG02
RD3/SEG03
RD4/SEG04
RE7/SEG27
RE0/SEG05
RE1/SEG06
RE2/SEG07
RE3/SEG08
RE4/SEG09
RE5/SEG10
RE6/SEG11
0.5K 1K 2K 4K 8K
words words words words words
2000h ID Location 0h
Implemented
1FFh Implemented Implemented Implemented Implemented
3FFh
2001h ID Location
400h
Implemented Implemented Implemented
7FFh
2002h ID Location
800h
Reserved Implemented Implemented
BFFh
2003h ID Location
C00h
Reserved Implemented Implemented
FFFh
2004h Reserved
1000h
Reserved Implemented
2005h Reserved
Reserved Implemented
2006h Reserved
Implemented
2007h Configuration Word
Implemented
1FFFh
2008h
Reserved Reserved Reserved Reserved Reserved
2100h
3FFFh
Start
N=1
No
Program Cycle Yes Report programming
N > 25?
failure
Read Data
Command N=N+1 N=#
of Program Cycles
Increment Address No
Data correct?
Command
Yes
Apply 3N Additional
Program Cycles
Program Cycle
Load Data
No Command
All locations done?
Yes
Wait 100 µs
No Report verify
Data correct?
@ VDD min. Error
Yes
End Programming
Verify all locations Command
@ VDD max.*
VPP = VIHH2
No Report verify
Data correct? @ VDD max. Error
Yes
Done
Start
Load Configuration
Command
N=1
Increment Address No
Command N=N+1N=# Data Correct?
of Program Cycles
Yes
No
Address = 2004 No
N > 25
Yes
Yes
Increment Address
Command Report ID Apply 3N
Configuration Error Program Cycles
Increment Address
Command
No
Data Correct?
Yes
CP1 CP0 BORV1 BORV0 CP1 CP0 - BODEN CP1 CP0 PWRTE WDTE FOSC1 FOSC0 Register: CONFIG
Address 2007h
bit13 12 11 10 9 8 7 6 5 4 3 2 1 bit0
Note 1: Enabling Brown-out Reset automatically enables the Power-up Timer (PWRT) regardless of the value of bit PWRTE.
Ensure the Power-up Timer is enabled anytime Brown-out Reset is enabled.
2: All of the CP <1:0> pairs have to be given the same value to enable the code protection scheme listed.
CP0 CP0 CP0 CP0 CP0 CP0 CP0 BODEN CP0 CP0 PWRTE WDTE FOSC1 FOSC0 Register: CONFIG
bit13 bit0 Address 2007h
Note 1: Enabling Brown-out Reset automatically enables Power-up Timer (PWRT) regardless of the value of bit PWRTE.
Ensure the Power-up Timer is enabled anytime Brown-out Reset is enabled.
2: All of the CP0 bits have to be given the same value to enable the code protection scheme listed.
To allow portability of code, the programmer is required to read the configuration word and ID locations from the hex
file when loading the hex file. If configuration word information was not present in the hex file then a simple warning
message may be issued. Similarly, while saving a hex file, configuration word and ID information must be included.
An option to not include this information may be provided.
Microchip Technology Inc. feels strongly that this feature is beneficial to the end customer.
Parameter
Sym. Characteristic Min. Typ. Max. Units Conditions
No.
General
PD1 VDDP Supply voltage during programming 4.75 5.0 5.25 V
PD2 IDDP Supply current (from VDD) – – 20 mA
during programming
PD3 VDDV Supply voltage during verify VDDmin – VDDmax V Note 1
PD4 VIHH1 Voltage on MCLR/VPP during 12.75 – 13.25 V Note 2
programming
PD5 VIHH2 Voltage on MCLR/VPP during verify VDD + 4.5 – 13.25 –
PD6 IPP Programming supply current (from – – 50 mA
VPP)
PD9 VIH (RB6, RB7) input high level 0.8 VDD – – V Schmitt Trigger input
PD8 VIL (RB6, RB7) input low level 0.2 VDD – – V Schmitt Trigger input
}
}
}
}
100ns 100ns
min. min.
Program/Verify Test Mode
Reset
VIHH
MCLR/VPP 100ns P6
P8
1 2 3 4 5 6 1µs min. 1 2 3 4 5 15
RB6
(CLOCK)
100ns P7
RB7 0 0 1 0 0 0
(DATA) P5
P4
P3 1µs min.
}
}
100ns
min. RB7
RB7 = output input
RB7
0 1 1 0 0 0 0 0
(DATA)
P5
P3 P4 1µs min.
}
}
100ns
min
Program/Verify Test Mode
Reset
RD2/AD10
RD3/AD11
RD4/AD12
RD5/AD13
RD6/AD14
RD7/AD15
RC2/AD2
RC5/AD5
RC6/AD6
RC7/AD7
RC1/AD1
RC3/AD3
RC4/AD4
RC0/AD0
RH1
RH0
VDD
VSS
RJ7
RJ6
NC
1110 9 8 7 6 5 4 3 2 1 84 83828180 7978777675
RH2 12 74 RJ5
RH3 13 73 RJ4
RD1/AD9 14 72 RA0/INT
RD0/AD8 15 71 RB0/CAP1
RE0/ALE 16 70 RB1/CAP2
RE1/OE 17 69 RB3/PWM2
RE2/WR 18 68 RB4/TCLK12
RE3/CAP4 19
PIC17C762/766 67 RB5/TCLK3
MCLR/VPP 20 66 RB2/PWM1
TEST 21 65 VSS
NC 22 Top View 64 NC
VSS 23 63 OSC2/CLKOUT
VDD 24 62 OSC1/CLKIN
RF7/AN11 25 61 VDD
RF6/AN10 26 60 RB7/SDO
RF5/AN9 27 59 RB6/SCK
RF4/AN8 28 58 RA3/SDI/SDA
RF3/AN7 29 57 RA2/SS/SCL
RF2/AN6 30 56 RA1/T0CKI
RH4/AN12 31 55 RJ3
RH5/AN13 32 54 RJ2
3334353637383940414243444546 474849 50 51 52 53
RD2/AD10
RD3/AD11
RD4/AD12
RD5/AD13
RD6/AD14
RD7/AD15
RC0/AD0
RC1/AD1
RC2/AD2
RC3/AD3
RC4/AD4
RC5/AD5
RC6/AD6
RC7/AD7
RJ1
AVDD
AVSS
VSS
VDD
RH6/AN14
RH7/AN15
RJ0
RG3/AN0/VREF+
NC
RF1/AN5
RF0/AN4
RG1/AN2
RG0/AN3
RG4/CAP3
RG5/PWM3
RG6/RX2/DT2
RA4/RX1/DT1
RG7/TX2/CK2
RA5/TX1/CK1
RG2/AN1/VREF-
VDD
VSS
NC
9 8 7 6 5 4 3 2 1 68 67 66 65 64 63 62 61
RD1/AD9 10 60 RA0/INT
RD0/AD8 11 59 RB0/CAP1
RE0/ALE 12 58 RB1/CAP2
RE1/OE 13 57 RB3/PWM2
RE2/WR 14 56 RB4/TCLK12
RE3/CAP4 15 55 RB5/TCLK3
MCLR/VPP 16 PIC17C752/756/756A 54 RB2/PWM1
TEST 17 53 VSS
NC 18 Top View 52 NC
VSS 19 51 OSC2/CLKOUT
VDD 20 50 OSC1/CLKIN
RF7/AN11 21 49 VDD
RF6/AN10 22 48 RB7/SDO
RF5/AN9 23 47 RB6/SCK
RF4/AN8 24 46 RA3/SDI/SDA
RF3/AN7 25 45 RA2/SS/SCL
RF2/AN6 26 44 RA1/T0CKI
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
AVSS
VSS
AVDD
VDD
RF1/AN5
RF0/AN4
RG1/AN2
RG0/AN3
RG4/CAP3
RG5/PWM3
RG7/TX2/CK2
RG6/RX2/DT2
RA5/TX1/CK1
RA4/RX1/DT1
NC
RG3/AN0/VREF+
RG2/AN1/VREF-
Pulse RA1
Pulse Pulse (Raise RA1
Jump to RA1 RA1 after RA0↓)
Program Load
Reset Reset
Routine Address
RA0↑
Pulse RA0
Raise RA1 Program (RA0 pulse
before RA0↓ width is
programming time)
The program allows new address to be loaded right out “Program cycle” is entered from “verify cycle” or pro-
of reset. A 16-bit address is presented on ports B (high gram cycle” itself. After a verify, pulsing RA0 will begin
byte) and C (low byte) and the RA1 is pulsed (0 → 1, a program cycle. 16-bit data must be presented on
then 1 → 0). The address is latched on the rising edge PORTB (high byte) and PORTC (low byte) before RA0
of RA1. See timing diagrams for details. After loading is raised.
an address, the program automatically goes into a “ver- The data is sampled 3 TCY cycles after the rising edge
ify cycle.” To load a new address at any time, the of RA0. Programming continues for the duration of RA0
PIC17C7XX must be reset and the programming mode pulse.
re-entered.
At the end of programming, the user can choose one of
2.1.2 VERIFY (OR READ) MODE three different routes. If RA1 is kept low and RA0 is
pulsed again, the same location will be programmed
“Verify mode” can be entered from “Load address” again. This is useful for applying over programming
mode, “program mode” or “verify mode.” In verify mode pulses. If RA1 is raised before RA0 falling edge, then a
pulsing RA1 will turn on PORTB and PORTC output verify cycle is started without address increment. Rais-
drivers and output the 16-bit value from the current ing RA1 after RA0 goes low will increment address and
location. Pulsing RA1 again will increment location begin verify cycle on the next address.
count and be ready for the next verify cycle. Pulsing
RA0 will begin a program cycle.
FE03h WDTPS1
FE05h Reserved
FE06h PM1
FE07h Reserved
FE08h Reserved
FE09h Reserved
FFFFh
RESET
NO
RA2 = 0 RA1 = 0
RA3 = 0
RA4 = 1
YES
NO
RA1 = 1
MCLR = 1
Bport = 0xE1
(hold for 10 TCY) YES
NO
Read MSB of data RA1 = 0
Present address
on ports RB, RC from portB.
hold TCY after Read LSB of data
from portC YES
RA1 changes
to 1 Enable RA0 to end
program cycle B and C
ports not
driven by part
NO
RA1 = 0 Program
16-bit
data If programming is desired
YES force portB = MSB of data
force portC = LSB of data
(hold 10 Tcy after RA0
NO
RA1 = 1 is raised)
NO
RA0 = 0
YES
YES YES
YES RA0 = 1
Stop driving
address on ports YES
RA1 = 0 RA0 = 1 NO
NO
NO NO RA1 = 1
NO
RA1 = 0 NO
RA1 = 1 YES
YES
Increment
Address
NO
RA1 = 1
Start
Verify blank
Pulse NO
Blank Issue “Blank check fail”
Check? error message
YES
YES
Location fails
programming issue error
message “Unable to
programming location”
Start
Verify blank
Pass NO
Blank Issue “blank check fail”
check? error message
YES
YES
Program using 100 µs NO
pulse increment Pass?
pulse-count
NO SetVVDD==VVDDminmin
Set DD DD
Verify location for Verify location
correct data
YES
Pass?
NO
Location fails
programming, issue error
message “Unable to
program location”
This feature is similar to that of the PIC16CXXX mid- This is used to clear the address pointer to the Program
range family, but the programming commands have Memory. This ensures that the pointer is at a known
been implemented in the device Boot ROM. The Boot state as well as pointing to the first location in program
ROM is located in the program memory from 0xFF60 to memory.
0xFFFF. The ISP mode is entered when the TEST pin
has a VIHH voltage applied. Once in ISP mode, the 4.3.2 INCREMENT ADDRESS
USART/SCI module is configured as a synchronous This is used to increment the address pointer to the
slave receiver, and the device waits for a command to Program Memory. This is used after the current location
be received. The ISP firmware recognizes eight com- has been programmed (or read).
mands. These are shown in Table 4-2.
TABLE 4-2: ISP COMMANDS
Command Value
RESET PROGRAM 0000 0000
MEMORY POINTER
LOAD DATA 0000 0010
READ DATA 0000 0100
INCREMENT ADDRSS 0000 0110
BEGIN PROGRAMMING 0000 1000
LOAD ADDRESS 0000 1010
READ ADDRESS 0000 1100
END PROGRAMMING 0000 1110
RA1/T0CKI
VIHH
Test PS2
VIHH
MCLR/VPP PS3 (NEXT COMMAND)
PS1 1 2 3 4 5 6 7 8 1 2
RA5 (Clock)
PS6
PS4PS5
RA4 (Data) 0 0 0 0 0 0 0 0
RA4 = Input
Reset
Program/Verify Test Mode
VIHH
MCLR/VPP PS3 (NEXT COMMAND)
PS1 1 2 3 4 5 6 7 8 1 2
RA5 (Clock)
PS6
PS4PS5
RA4 (Data) 0 1 1 0 0 0 0 0
RA4 = Input
Reset
Program/Verify Test Mode
This is used to load the address pointer to the Program This is used so that the current address in the Program
Memory with a specific 16-bit value. This is useful when Memory pointer can be determined. This can be used
a specific range of locations are to be accessed. to increase the robustness of the ISP programming
(ensure that the Program Memory pointers are still in
sync).
RA1/T0CKI
VIHH
Test PS2
VIHH
MCLR/VPP PS3 (NEXT COMMAND)
PS1 1 2 3 4 5 6 7 8 1 2 3 15 16 1
RA5 (Clock)
PS7 PS6
PS4PS5
RA4 (Data) 0 1 0 1 0 0 0 0
RA4 = Input
Reset
Program/Verify Test Mode
RA1/T0CKI
VIHH
Test PS2
VIHH
MCLR/VPP PS3 (NEXT COMMAND)
PS1 1 2 3 4 5 6 7 8 1 2 3 15 16 1
RA5 (Clock)
PS8 PS6
PS4PS5
PS9
RA4 (Data) 0 0 1 1 0 0 0 0
Reset
Program/Verify Test Mode
This is used to load the 16-bit data that is to be pro- This is used to read the data in Program Memory that
grammed into the Program Memory location. The Pro- is pointed to by the current address pointer. This is use-
gram Memory address may be modified after the data ful for doing a verify of the programming cycle and can
is loaded. This data will not be programmed until a be used to determine the number for programming
BEGIN PROGRAMMING command is executed. cycles that are required for the 3X overprogramming.
RA1/T0CKI
VIHH
Test PS2
VIHH
MCLR/VPP PS3 (NEXT COMMAND)
PS1 1 2 3 4 5 6 7 8 1 2 3 15 16 1
RA5 (Clock)
PS7 SP6
PS4PS5
RA4 (Data) 0 1 0 0 0 0 0 0
RA4 = Input
Reset
Program/Verify Test Mode
RA1/T0CKI
VIHH
Test PS2
VIHH
MCLR/VPP PS3 (NEXT COMMAND)
PS1 1 2 3 4 5 6 7 8 1 2 3 15 16 1
RA5 (Clock)
PS8 PS6
PS4PS5
PS9
RA4 (Data) 0 0 1 0 0 0 0 0
Reset
Program/Verify Test Mode
This is used to program the current 16-bit data (last Once a location has been both programmed and veri-
data sent with LOAD DATA Command) into the Pro- fied over a range of voltages, 3X overprogramming
gram Memory at the address specified by the current should be applied. In other words, apply three times the
address pointer. The programming cycle time is speci- number of programming pulses that were required to
fied by specification P10. After this time has elapsed, program a location in memory, to ensure a solid pro-
any command must be sent, which wakes the proces- gramming margin.
sor from the Long Write cycle. This command will be This means that every location will be programmed a
the next executed command. minimum of 4 times (1 + 3X overprogramming).
RA1/T0CKI
VIHH
Test PS2
VIHH
MCLR/VPP PS3 (NEXT COMMAND)
PS1 1 2 3 4 5 6 7 8 1 2 7 8
RA5 (Clock)
PS10
PS4PS5
RA4 (Data) 0 0 0 1 0 0 0 0
RA4 = Input
Reset
Program/Verify Test Mode
TEST = Vihh
MCLR = Vihh
ISP Command
RESET ADDRESS
ISP Command
INCREMENT ADDRESS
N=1
or
LOAD ADDRESS
ISP Command
LOAD DATA
ISP Command
READ DATA
No
Data Correct? N=N+1
Yes
N = 3N
ISP Command
BEGIN PROGRAMMING
DONE
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
1 1 1 1 1 1 1 1 PM2 BODEN PM2 PM2 PM2 PM2 PM2 PM2
—=Unused
PM<2:0>, Processor Mode Select bits
111 = Microprocessor mode
110 = Microcontroller mode
101 = Extended Microcontroller mode
000 = Code protected microcontroller mode
BODEN, Brown-out Detect Enable
1 = Brown-out Detect Circuitry enabled
0 = Brown-out Detect Circuitry disabled
WDTPS1:WDTPS0, WDT Prescaler Select bits.
11 = WDT enabled, postscaler = 1
10 = WDT enabled, postscaler = 256
01 = WDT enabled, postscaler = 64
00 = WDT disabled, 16-bit overflow timer
FOSC1:FOSC0, Oscillator Select bits
11 = EC oscillator
10 = XT oscillator
01 = RC oscillator
00 = LF oscillator
To allow portability of code, a PIC17C7XX programmer is required to read the configuration word locations from the
hex file when loading the hex file. If the configuration word information was not present in the hex file, then a simple
warning message may be issued. Similarly, while saving a hex file, all configuration word information must be included.
An option to not include the configuration word information may be provided. When embedding configuration word
information in the hex file, it should be to address FE00h.
Microchip Technology Inc. feels strongly that this feature is important for the benefit of the end customer.
Device ID Value
Device
DEV REV
PIC17C766 0000 0001 001 X XXXX
PIC17C762 0000 0001 101 X XXXX
PIC17C756 0000 0000 001 X XXXX
PIC17C756A 0000 0010 001 X XXXX
PIC17C752 0000 0010 101 X XXXX
Test
13V
MCLR 5V
P14 P15
P4 P9
P5
RB<7:0> E1H ADDR_HI DATA_HI OUT DATA_HI OUT DDATA_HI OUT DATA_HI OUT
Jump Address
Input
RC<7:0> ADDR_LO DATA_LO OUT DATA_LO OUT DATA_LO OUT DATA_LO OUT
P5
P6
Program location X + !
Verify location X
Programming Do not increment PC
Load Address X Increment Address to X + 1 Verify location X + 1 Verify location X + 1
Mode Entry by raising RA1 before
by pulsing RA1
RA0
PARALLEL MODE PROGRAMMING AND VERIFY TIMINGS I
Note: RA2 = 0
RA3 = 0
RA4 = 1
PIC17C7XX
DS30274B-page 3-89
Test
FIGURE 6-2:
13V
DS30274B-page 3-90
5V
P14
VPP/MCLR P15
PIC17C7XX
P9 P9 P9
RA1
RA0
RB<7:0> E1H ADDR_HI DATA_HI OUT DATA_HI_IN DATA_HI_IN DATA_HI_IN DATA_HI OUT
Jump Address
Input
Program location X
Move to verify cycle
Programming
Load address X Verify location X Program location X Prevent increment of Verify location X
mode entry
PC by raising RA1
before RA0
PARALLEL MODE PROGRAMMING AND VERIFY TIMINGS II
Note: RA2 = 0
RA3 = 0
RA4 = 1
P13 P13
P12
RA0
RC<7:0> DATA_LO OUT DATA_LO IN DATA_LO OUT DATA_LO IN DATA_LO OUT DATA_LO IN
Program location X
Program location X Verify location X + 1
Do not increment
Verify location X Verify location X Raise RA1 after RA0 Pulse RA1 to increment Verify location X + 2
PC Raise RA1 before
to increment location X + 1 address to X + 2
RA0 to do this
VPP/MCLR = VPP
RA2 = 0
RA3 = 0
RA4 = 1
PIC17C7XX
DS30274B-page 3-91
PIC17C7XX
FIGURE 6-4: POWER-UP/DOWN SEQUENCE FOR PROGRAMMING
VDD P19
P16
VPP/MCLR
Test
RA4
RA2
RA3
RA0
P3
RB<7:0> E1H
P17
P18
RA1/T0CKI
VIHH
Test PS2
VIHH
MCLR/VPP PS3 (NEXT COMMAND)
PS1 1 2 3 4 5 6 7 8 1 2
RA5 (Clock)
PS6
PS4PS5
RA4 (Data) 0 0 0 0 0 0 0 0
RA4 = Input
Reset
Program/Verify Test Mode
VIHH
MCLR/VPP PS3 (NEXT COMMAND)
PS1 1 2 3 4 5 6 7 8 1 2
RA5 (Clock)
PS6
PS4PS5
RA4 (Data) 0 1 1 0 0 0 0 0
RA4 = Input
Reset
Program/Verify Test Mode
RA1/T0CKI
VIHH
Test PS2
VIHH
MCLR/VPP PS3 (NEXT COMMAND)
PS1 1 2 3 4 5 6 7 8 1 2 3 15 16 1
RA5 (Clock)
PS7 PS6
PS4PS5
RA4 (Data) 0 1 0 1 0 0 0 0
RA4 = Input
Reset
Program/Verify Test Mode
RA1/T0CKI
VIHH
Test PS2
VIHH
MCLR/VPP PS3 (NEXT COMMAND)
PS1 1 2 3 4 5 6 7 8 1 2 3 15 16 1
RA5 (Clock)
PS8 PS6
PS4PS5
PS9
RA4 (Data) 0 0 1 1 0 0 0 0
Reset
Program/Verify Test Mode
RA1/T0CKI
VIHH
Test PS2
VIHH
MCLR/VPP PS3 (NEXT COMMAND)
PS1 1 2 3 4 5 6 7 8 1 2 3 15 16 1
RA5 (Clock)
PS7 PS6
PS4PS5
RA4 (Data) 0 1 0 0 0 0 0 0
RA4 = Input
Reset
Program/Verify Test Mode
RA1T0CKI
VIHH
Test PS2
VIHH
MCLR/VPP PS3 (NEXT COMMAND)
PS1 1 2 3 4 5 6 7 8 1 2 3 15 16 1
RA5 (Clock)
PS8 PS6
PS4PS5
PS9
RA4 (Data) 0 0 1 0 0 0 0 0
Reset
Program/Verify Test Mode
RA1/T0CKI
VIHH
Test PS2
VIHH
MCLR/VPP PS3 (NEXT COMMAND)
PS1 1 2 3 4 5 6 7 8 1 2 7 8
RA5 (Clock)
PS10
PS4PS
RA4 (Data) 0 0 0 1 0 0 0 0
RA4 = Input
Reset
Program/Verify Test Mode
PIC18C4XX
RE0 8 33 RB0/INT
RE1 9 32 VDD
RE2 10 31 VSS
The PIC18CXXX can be programmed using a serial VDD 11 30 RD7
VSS 12 29 RD6
method. while in the users system. This allows for OSC1/CLKIN 13 28 RD5
increased design flexibility. This programming specifi- OSC2/CLKOUT 14 27 RD4
RC0 15 26 RC7
cation applies to PIC18CXXX devices in all package RC1 16 25 RC6
RC2 17 24 RC5
types. RC3 18 23 RC4
RD0 19 22 RD3
RD1 20 21 RD2
1.1 Hardware Requirements
The PIC18CXXX requires two programmable power PDIP, SOIC, Windowed CERDIP (300 mil)
supplies, one for VDD (2.0V to 5.5V recommended) and MCLR/VPP •1 28 RB7
one for VPP (12V to 14V). Both supplies should have a RA0 2 27 RB6
RA1 3 26 RB5
minimum resolution of 0.25V. 25 RB4
RA2 4
RA3 5 24 RB3
PIC18C2XX
1.2 Programming Mode RA4/T0CKI 6 23 RB2
RA5 7 22 RB1
TABLE 2-1: SPECIAL INSTRUCTIONS FOR SERIAL INSTRUCTION EXECUTION AND ICSP
Mnemonic, Status
Description Cycles 4-Bit Opcode
Operands Affected
NOP No Operation (Shift in16-bit instruction) 1 0000 None
TBLRD * Table Read (no change to TBLPTR) 2 1000 None
TBLRD *+ Table Read (post-increment TBLPTR) 2 1001 None
TBLRD *- Table Read (post-decrement TBLPTR) 2 1010 None
TBLRD +* Table Read (pre-increment TBLPTR) 2 1011 None
TBLWT * Table Write (no change to TBLPTR) 2 1100 None
TBLWT *+ Table Write (post-increment TBLPTR) 2 1101 None
TBLWT *- Table Write (post-decrement TBLPTR) 2 1110 None
TBLWT +* Table Write (pre-increment TBLPTR) 2 1111 None
Legend: Refer to the PIC18CXXX Data Sheet (DS39026) for opcode field descriptions.
Note: All special instructions not included in this table are decoded as NOP’s
VIHH
P2
MCLR/VPP
1 2 3 4 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 2 3 4
RB6 (Clock) P9
P5 P5
P3P4
RB7 (Data) 1 1 0 1 1 1 0 1
Reset
RB7 = Input or Output depending upon instruction
ICSP Mode
The NOP serial instruction is used to allow execution of If the instruction fetched is a one cycle instruction,
all other instructions not included in Table 2-1. When then the instruction operation will be completed in the
the NOP instruction is fetched, the serial execution 4 clock cycles following the instruction fetched. During
state machine suspends the CPU for 16 clock cycles. instruction execution, the next 4-bit serial instruction is
During these 16 clock cycles, all 16-bits of an instruc- fetched (See Figure 2-2).
tion are fed into the CPU and the NOP instruction is
discarded. Once all 16 bits have been shifted in the
state machine will allow the instruction to be executed
for the next 4 clock cycles.
Note: 16-bit TBLWT and TBLRD instructions are
not permitted. They will cause timing prob-
lems with the serial state machine. If the
user wishes to perform a TBLWT or TBLRD
instruction, it must be performed as a 4-bit
instruction.
MCLR/VPP = VIHH
P2
1 2 3 4 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 2 3 4
RB6 (Clock)
P5 P5
P3P4
RB7 (Data) 0 0 0 0 1 1 0 1
ICSP Mode
Start
MCLR = VIHH
Clock No
Transition
Shift in 1st RB6?
4-bit instruction, Yes
Num_Clk = 1,
Shift(R) RB7
Num_Clk = Num_Clk + 1
Clock No
Transition
RB6? End
Yes
Shift(R) RB7
Num_Clk = Num_Clk + 1
Clock No
Transition
RB6?
Yes
Shift(R) RB7
Num_Clk = Num_Clk + 1
No
Num_Clk = 16?
Yes
Start
Clock No
Transition
RB6? Clock No
Yes Transition
RB6?
Yes
Shift(R) RB7
Num_Clk = Num_Clk + 1
Shift(R) RB7
Num_Clk = Num_Clk + 1
4-bit instruction = NOP,
Shift in 16-bit instruction,
Num_Clk = 1
End
Clock No
Transition
RB6?
Yes
Shift(R) RB7
into ROMLAT<15>,
Num_Clk = Num_Clk + 1
No
Num_Clk = 16?
Yes
Q Cycles Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4
MCLR/VPP P2
1 2 3 4 1 2 15 16 1 2 3 4 1 2 15 16 1 2 3 4
RB6 (Clock)
P5 P5 P5 P5
P3P4
RB7 (Data) 0 0 0 0 1 1 0 1
Execute PC-2 Fetch 16-bit Instruction Fetch 4-bit NOP, Fetch 2nd 16-bit Execute 2nd Cycle,
Fetch 4-bit NOP Execute 1st Cycle Operand Word (discarded) Fetch Next 4-bit Instruction
of 16-bit Instruction
RB7 = Input
ICSP Mode
MCLR/VPP = VIHH
P2
1 2 3 4 1 2 3 15 16 1 2 3 4 1 2 15 16 1 2 3 4
RB6 (Clock)
P5 P5 P5 P5
P3P4
RB7 (Data) 0 0 0 0 0 0 0 0 1 1 0 1
Execute PC-2, Fetch 1st word Execute 1st Cycle, Fetch 2nd word Execute 2nd Cycle,
Fetch 4-bit NOP Fetch 4-bit NOP Fetch next 4-bit
Instruction
RB7 = Input
ICSP Mode
Start
MCLR = VPP,
RB6, RB7 = 0 Clock No
Transition
RB6?
MCLR = VIHH
Yes
Shift(R) RB7,
execute FNOP and shift in
1st 4-bit instruction, Num_Clk = Num_Clk + 1
Num_Clk = 1,
Shift(R) RB7,
4-bit instruction = NOP, Num_Clk = Num_Clk + 1
Shift in 16-bit instruction,
Num_Clk = 1
No
Num_Clk = 16?
Clock No
Transition Yes
RB6?
Yes execute 2nd cycle of 16-bit
instruction, and shift in
Shift(R) RB7, next 4-bit instruction
Num_Clk = 1
Num_Clk = Num_Clk + 1
No Clock No
Num_Clk = 16? Transition
RB6?
Yes Yes
Shift(R) RB7,
Enable CPU,
Num_Clk = Num_Clk + 1
execute 1st cycle of 16-bit
instruction, and shift in next
4-bit instruction,
Num_Clk = 1, End
Clock No
Transition
RB6?
Start Yes
Shift(R) RB7,
4-bit instruction = NOP, Num_Clk = Num_Clk + 1
Shift in 16-bit instruction,
Num_Clk = 1
No
Num_Clk = 16?
Clock No
Transition Yes
RB6?
Yes execute 2nd cycle of 16-bit
instruction, and shift in
next 4-bit instruction
Shift(R) RB7, Num_Clk = 1
Num_Clk = Num_Clk + 1
No Clock No
Num_Clk = 16? Transition
RB6?
Yes Yes
Shift(R) RB7,
execute 1st cycle of 16-bit Num_Clk = Num_Clk + 1
instruction, and shift in next
4-bit instruction,
Num_Clk = 1, End
MCLR/VPP = VIHH P2
P10
1 2 3 4 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 2 3 4
RB6 (Clock) P9
P5 P5
P3P4
RB7 (Data) 1 1 0 0 0 0 0 0 1 1 0 1
Execute 1st
Execute PC-2 Cycle TBLWT Execute 2nd Cycle TBLWT
Fetch TBLWT and fetch next 4-bit
instruction
RB7 = Input
ICSP Mode
Start
Clock No
Transition
MCLR = VSS, RB6?
RB6, RB7 = 0
Yes
Execute FNOP,
and shift in 4-bit No
TBLWT instruction, Num_Clk = 12?
Num_Clk = 1,
Yes
Shift(R) RB7
Num_Clk = Num_Clk + 1 Clock No
Transition
RB6?
Yes
4-bit instruction = TBLWT,
Execute 1st cycle of TBLWT,
Begin Shifting in TBLWT data, Shift(R) RB7
Num_Clk = 1 Num_Clk = Num_Clk + 1
End
Clock No
Transition
RB6?
Yes
Shift(R) RB7
Num_Clk = Num_Clk + 1
No
Num_Clk = 4?
Yes
Clock No
Transition
RB6?
Yes
Shift(R) RB7
Start
Num_Clk = Num_Clk + 1
Execute (PC-2),
and shift in 4-bit No
TBLWT instruction, Num_Clk = 12?
Num_Clk = 1,
Yes
Shift(R) RB7
Num_Clk = Num_Clk + 1 Clock No
Transition
RB6?
4-bit instruction = TBLWT, Yes
Execute 1st cycle of TBLWT,
Begin Shifting in TBLWT data, Shift(R) RB7
Num_Clk = 1 Num_Clk = Num_Clk + 1
Clock End
No
Transition
RB6?
Yes
Shift(R) RB7
Num_Clk = Num_Clk + 1
No
Num_Clk = 4?
Yes
MCLR/VPP = VIHH
1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 5 6 7 8 1 2 3 4
RB6 (Clock)
P5 P6 P5
Execute PC-2 Execute Cycle 1 Execute Cycle 2 Shift Data Out From TABLAT No Execution takes place,
Fetch TBLRD TBLRD TBLRD Fetch Next 4-bit instruction
RB7 = Input RB7 = Output RB7 = Input
ICSP Mode
Start
Clock No
MCLR = VSS, Transition
RB6, RB7 = 0
RB6?
Yes
MCLR = VIHH
Shift(R) TABLAT<0>
out onto RB7
Num_Clk = Num_Clk + 1
Execute FNOP,
and shift in 4-bit
TBLRD instruction,
Num_Clk = 1, No
Num_Clk = 8?
Yes
Shift(R) RB7
Num_Clk = Num_Clk + 1
Clock No
Transition
RB6?
Enable CPU, Yes
execute 1st and 2nd
cycle TBLRD instruction
Shift(R) RB7
Num_Clk = Num_Clk + 1
Clock No
Transition No
RB6? Num_Clk = 4?
Yes
Yes
TBLRD instruction execution
takes place here
Num_Clk = Num_Clk + 1 End
No
Num_Clk = 8?
Yes
Start
Clock No
Execute (PC-2), Transition
and shift in 4-bit RB6?
TBLRD instruction, Yes
Num_Clk = 1,
Shift(R) TABLAT<0>
out onto RB7
Num_Clk = Num_Clk + 1
Clock No
Transition
RB6? No
Num_Clk = 8?
Yes
Yes
Shift(R) RB7
Num_Clk = Num_Clk + 1 Shift in next
4-bit instruction
Clock No
Transition
RB6?
Clock No
Transition Yes
RB6?
Yes Shift(R) RB7
Num_Clk = Num_Clk + 1
TBLRD instruction execution
takes place here
Num_Clk = Num_Clk + 1
No
Num_Clk = 4?
No Yes
Num_Clk = 8?
Yes End
Start
No No
Num_Clk = 4? Num_Clk = 16?
Yes Yes
Yes
Yes
End
Start
No No
Num_Clk = 4? Num_Clk = 16?
Yes Yes
End
TBLWT TBLWT
Odd or Even Odd or Even Data shifted into
address address TABLAT and
Buffer registers
Buffer Register TABLAT Register
TBLRD RB7
Hold RB6
4-bit instruction = NOP, Clock high
Shift in 16-bit MOVLW Low_Addr
instruction for 16 clock cycles
Wait 100 µsec to
ensure programming
Hold RB6
Clock high (P10)
4-bit instruction = NOP, Execute MOVWF
Shift in 16-bit MOVWF TBLPTRL for 4 clock cycles
instruction for 16 clock cycles and shift in 4-bit NOP Execute 1st and 2nd cycle
TBLRD *- for 8 clock cycles
Yes
Verify? A
4-bit instruction = NOP,
Execute current instruction
Shift in 16-bit MOVWF TBLPTRH for 4 clock cycles, and
instruction for 16 clock cycles shift in 4-bit TBLWT+* No
N=N+1
Yes
N > 25?
Report
No Programming
Failure
N=3*N
No
N = 1?
No Yes Report
No Verify
Data Correct?
To B Error
@ VDDMAX
End
The Configuration registers are located in ok memory, When programming occurs, 16 bits of data are pro-
and are only addressable when the high address bit of grammed into memory. The 16-bits of data are shifted
the TBLPTR (bit 21) is set. Test program memory con- in during the TBLWT sequence. After the programming
tains test memory, configuration registers, calibration command (TBLWT) has been executed, the user must
registers, and ID locations. The desired address must wait for 100 µs until programming is complete, before
be loaded into all three bytes of the table pointer to pro- another command can be executed by the CPU. There
gram specific ID locations or the configuration bits. To is no command to end programming.
program the configuration registers, the following RB6 must remain high for as long as programming is
sequence must be followed: desired. When RB6 is lowered programming will cease.
NOP ; 4-bit instruction
After the falling edge occurs on RB6, RB6 must be held
; shift in 16-bit
; MOVLW instruction
low for a period of time so that a high voltage discharge
MOVLW 03h can be performed to ensure that the program array isn’t
NOP ; 4-bit instruction stressed at high voltage during execution of the next
; shift in 16-bit instruction. The high voltage discharge will occur while
; MOVWF instruction RB6 is low following the programming time.
; Enable Test memory
MOVWF TBLPTRU, 0
NOP ; 4-bit instruction
; shift in 16-bit
; MOVLW instruction
MOVLW Low_Config_Address
NOP ; 4-bit instruction
; shift in 16-bit
; MOVWF instruction
MOVWF TBLPTRL, 0
NOP ; 4-bit instruction
; shift in 16-bit
; MOVLW instruction
MOVLW ; High_Config_Address
NOP ; 4-bit instruction
; shift in 16-bit
; MOVWF instruction
MOVWF TBLPTRH, 0
NOP ; 4-bit instruction
; shift in 16-bit
; MOVLW instruction
TBLWT *+
; 16-bits of data are
; shifted in for write
; of config1L and
; config1H TBLWT is a
; 4-bit special
; instruction Wait
; 100 µsec for programming
START
MCLR = VSS
4.75V < VDD < 5.25V
MCLR = VIHH
ICSP Command
LOAD CONFIGURATION
Address = 300000h
ICSP Command
LOAD ADDRESS
Wait approx 100 µs
Address = 300000h
No
N = 100 N > 25? Data Correct?
Yes Yes
Report N = 3N
ICSP Command Programming
BEGIN PROGRAMMING
Failure
ICSP Command
BEGIN PROGRAMMING
Wait approx 100 µs N=0
No
N = 0? ICSP Command N=N-1
INCREMENT ADDRESS
Yes
No
ICSP Command N = 0?
READ DATA Yes
START
Execute MOVLW
for 4 clock cycles
and shift in 4-bit NOP
MCLR = VSS
4.75V < VDD < 5.25V
No
4-bit instruction = NOP, Execute 2nd cycle
Shift in 16-bit MOVLW 00 TBLWT for 4 clock cycles
instruction for 16 clock cycles Shift in TBLWT *
for 4 clock cycles
All
Execute 2nd cycle locations No
TBLWT *- for 4 clock cycles programmed? B
Shift in TBLRD*+
for 4 clock cycles
Yes
Yes
Start
MCLR = VPP,
Execute 1st cycle
RB6, RB7 = 0
TBLWT +*, and shift in
first 4-bits of data B
N=0 for 4 clock cycles
N=3*N
No
N = 1?
Legend
R = Readable bit P = Programmable bit U = Unimplemented bit, read as ‘0’
- n = Value when device is unprogrammed u = Unchanged from programmed state
CP: Code Protection bits (apply when in Code Protected Microcontroller Mode)
1 = Program memory code protection off
0 = All of program memory code protected
Legend
R = Readable bit P = Programmable bit U = Unimplemented bit, read as ‘0’
- n = Value when device is unprogrammed u = Unchanged from programmed state
Legend
R = Readable bit P = Programmable bit U = Unimplemented bit, read as ‘0’
- n = Value when device is unprogrammed u = Unchanged from programmed state
Legend
R = Readable bit P = Programmable bit U = Unimplemented bit, read as ‘0’
- n = Value when device is unprogrammed u = Unchanged from programmed state
Legend
R = Readable bit P = Programmable bit U = Unimplemented bit, read as ‘0’
- n = Value when device is unprogrammed u = Unchanged from programmed state
Legend
R = Readable bit P = Programmable bit U = Unimplemented bit, read as ‘0’
- n = Value when device is unprogrammed u = Unchanged from programmed state
3.1 ID Locations
A user may store identification information (ID) in 8 ID
locations. The ID locations are mapped in
[0x200000:0x200007]. It is recommended that the user
use only the 4 least significant bits of each ID location.
The ID locations do not read out in a scrambled fashion
after code protection is enabled. For all devices it is rec-
ommended that all ID locations are written as ‘1111
bbbb’ where bbbb is the ID information. When the
upper four bits of an ID location is written as ‘1111’, the
resulting opcode when executed is read as a NOP. This
allows Reset testing of test program memory after ID
locations have been programmed.
To allow portability of code, a PIC18C4X programmer is required to read the configuration word locations from the hex
file when loading the hex file. If configuration word information was not present in the hex file then a simple warning
message may be issued. Similarly, while saving a hex file, all configuration word information must be included. An
option to not include the configuration word information may be provided. When embedding configuration word infor-
mation in the hex file, it should be to address FE00h.
Microchip Technology Inc. feels strongly that this feature is important for the benefit of the end customer.
3.3 CHECKSUM COMPUTATION ently depending on the code protect setting, the table
describes how to manipulate the actual program mem-
The checksum is calculated by summing the following: ory values to simulate the values that would be read
• The contents of all program memory locations from a protected device. When calculating a checksum
• The configuration word, appropriately masked by reading a device, the entire program memory can
simply be read and summed. The configuration word
• Masked ID locations (when applicable)
and ID locations can always be read.
The least significant 16 bits of this sum is the check-
Note that some older devices have an additional value
sum.
added in the checksum. This is to maintain compatibil-
The following table describes how to calculate the ity with older device programmer checksums.
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-
TABLE 3-2: CHECKSUM COMPUTATION
0xAA at 0
Code Blank
Device Checksum* and max
Protect Value
address
Disable SUM[0C000:0x7FFF] + CFGW0 & 0xFF + CFGW1 & 0x27 + CFGW2 0x8148 0x809E
& 0x0F + CFGW3 & 0x0F + CFGW4 & 0x00 + CFGW5 & 0x01 +
CFGW6 & 0x03 + CFGW7 & 0x00
PIC18C452
Enabled CFGW0 & 0xFF + CFGW1 & 0x27 + CFGW2 & 0xF + CFGW3 & 0x0F 0x005E 0x0068
+ CFGW4 & 0x00 + CFGW5 & 0x01 + CFGW6 & 0x03 + CFGW7 &
0x00 + SUM_ID
Disable SUM[0x000:0x3FFF] + CFGW0 & 0xFF + CFGW1 & 0x27 + CFGW2 0xC148 0xC09E
& 0x0F + CFGW3 & 0x0F + CFGW4 & 0x00 + CFGW5 & 0x01 +
CFGW6 & 0x03 + CFGW7 & 0x00
PIC18C442
Enabled CFGW0 & 0xFF + CFGW1 & 0x27 + CFGW2 & 0x0F + CFGW3 & 0x0062 0x006C
0x0F + CFGW4 & 0x00 + CFGW5 & 0x01 + CFGW6 & 0x03 +
CFGW7 & 0x00 + SUM_ID
Disable SUM[0x000:0x7FFF] + CFGW0 & 0xFF + CFGW1 & 0x27 + CFGW2 0x8148 0x809E
& 0x0F + CFGW3 & 0x0F + CFGW4 & 0x00 + CFGW5 & 0x01 +
CFGW6 & 0x03 + CFGW7 & 0x00
PIC18C252
Enabled CFGW0 & 0xFF + CFGW1 & 0x27 + CFGW2 & 0x0F + CFGW3 & 0x005E 0x0068
0x0F + CFGW4 & 0x00 + CFGW5 & 0x01 + CFGW6 & 0x03 +
CFGW7 & 0x00 + SUM_ID
Disable SUM[0x000:0x3FFF] + CFGW0 & 0xFF + CFGW1 & 0x27 + CFGW2 0xC148 0xC09E
& 0x0F + CFGW3 & 0x0F + CFGW4 & 0x00 + CFGW5 & 0x01 +
CFGW6 & 0x03 + CFGW7 & 0x00
PIC18C242
Enabled CFGW0 & 0xFF + CFGW1 & 0x27 + CFGW2 & 0x0F + CFGW3 & 0x0062 0x006C
0x0F + CFGW4 & 0x00 + CFGW5 & 0x01 + CFGW6 & 0x03 +
CFGW7 & 0x00 + SUM_ID
Legend: CFGW = Configuration Word
SUM[a:b] = [Sum of locations a to b inclusive]
SUM_ID = Byte-wise sum of lower four bits of all ID locations
+ = Addition
& = Bitwise AND
PIC16F62X
RA5/MCLR/THV 4 15 RA6/OSC2/CLKOUT
RB0/INT RB7/T1OSI
PIC16F62X 6 13
RB1/RX/DT 7 12 RB6/T1OSO/T1CKI
The PIC16F62X is programmed using a serial method. RB2/TX/CK 8 11 RB5
The serial mode will allow the PIC16F62X to be pro- RB3/CCP1 9 10 RB4/PGM
grammed while in the users system. This allows for
increased design flexibility. This programming specifi-
cation applies to PIC16F62X devices in all packages.
PIC16F62X devices may be programmed using a sin- RA2/AN2/VREF •1 20 RA1/AN1
RA4/T0CKI/CMP2 3 18 RA7/OSC1/CLKIN
PIC16F62X
1.1 Hardware Requirements RA5/MCLR/THV 4 17 RA6/OSC2/CLKOUT
VSS 5 16 VDD
The PIC16F62X requires one programmable power
VSS 6 VDD
supply for VDD (4.5V to 5.5V) and a VPP of 12V to 14V 15
RB0/INT 7 14
or VPP of (4.5V to 5.5V) when using low voltage. Both RB7/T1OSI
RB1/RX/DT 8
RB6/T1OSO/T1CKI
supplies should have a minimum resolution of 0.25V. 13
RB2/TX/CK 9 12
RB5
2.1 User Program Memory Map A user may store identification information (ID) in four
ID locations. The ID locations are mapped in [0x2000 :
The user memory space extends from 0x0000 to 0x2003]. It is recommended that the user use only the
0x7FFF. In programming mode the program memory four least significant bits of each ID location. In some
space extends from 0x0000 to 0x3FFF, with the first devices, the ID locations read-out in an unscrambled
half (0x0000-0x7FFF) being user program memory and fashion after code protection is enabled. For these
the second half (0x2000-0x3FFF) being configuration devices, it is recommended that ID location is written as
memory. The PC will increment from 0x0000 to 0x7FFF “11 1111 1000 bbbb” where ‘bbbb’ is ID information.
and wrap to 0x000, 0x2000 to 0x3FFF and wrap In other devices, the ID locations read out normally,
around to 0x2000 (not to 0x0000). Once in configura- even after code protection. To understand how the
tion memory, the highest bit of the PC stays a ‘1’, thus devices behave, refer to Table 4-1.
always pointing to the configuration memory. The only
way to point to user program memory is to reset the To understand the scrambling mechanism after code
part and reenter program/verify mode as described in protection, refer to Section 3-1.
Section 2.3.
In the configuration memory space, 0x2000-0x200F
are physically implemented. However, only locations
0x2000 through 0x2007 are available. Other locations
are reserved. Locations beyond 0x200F will physically
access user memory. (See Figure 2-1).
1 KW 2 KW
0x1FF
Implemented Implemented
1FFF
2000 ID Location
2000
Implemented Implemented
2001
ID Location 2008
2002
ID Location
2003
ID Location
2004
Reserved
Not Implemented
2005
Reserved
2006
Reserved
2007
Configuration Word 3FFF
The program/verify mode is entered by holding pins The RB6 pin is used as a clock input pin, and the RB7
RB6 and RB7 low while raising MCLR pin from VIL to pin is used for entering command bits and data input/
VIHH (high voltage) or by applying VDD to MCLR and output during serial operation. To input a command, the
raising RB3 from VIL to VDD. Once in this mode the user clock pin (RB6) is cycled six times. Each command bit
program memory and the configuration memory can be is latched on the falling edge of the clock with the least
accessed and programmed in serial fashion. The mode significant bit (LSB) of the command being input first.
of operation is serial, and the memory that is accessed The data on pin RB7 is required to have a minimum
is the user program memory. RB6 and RB7 are Schmitt setup and hold time (see AC/DC specifications) with
Trigger Inputs in this mode. respect to the falling edge of the clock. Commands that
have data associated with them (read and load) are
Note: The OSC must not have 72 osc clocks specified to have a minimum delay of 1 µs between the
while the device MCLR is between VIL and command and the data. After this delay, the clock pin is
VIHH. cycled 16 times with the first cycle being a start bit and
The sequence that enters the device into the program- the last cycle being a stop bit. Data is also input and
ming/verify mode places all other logic into the reset output LSB first.
state (the MCLR pin was initially at VIL). This means Therefore, during a read operation the LSB will be
that all I/O are in the reset state (High impedance transmitted onto pin RB7 on the rising edge of the sec-
inputs). ond cycle, and during a load operation the LSB will be
The normal sequence for programming is to use the latched on the falling edge of the second cycle. A min-
load data command to set a value to be written at the imum 1µs delay is also specified between consecutive
selected address. Issue the begin programming com- commands.
mand followed by read data command to verify, and All commands are transmitted LSB first. Data words
then increment the address. are also transmitted LSB first. The data is transmitted
A device reset will clear the PC and set the address to on the rising edge and latched on the falling edge of
0. The “increment address” command will increment the clock. To allow for decoding of commands and
the PC. The “load configuration” command will se the reversal of data pin configuration, a time separation of
PC to 0x2000. The available commands are shown in at least 1 µs is required between a command and a
Table 2-1. data word (or another command).
2.3.1 LOW-VOLTAGE PROGRAMMING MODE The commands that are available are:
When LVP bit is set to ‘1’, the low-voltage programming 2.3.2.1 LOAD CONFIGURATION
entry is enabled. Since the LVP configuration bit allows After receiving this command, the program counter
low voltage programming entry in its erased state, an (PC) will be set to 0x2000. By then applying 16 cycles
erased device will have the LVP bit enabled at the fac- to the clock pin, the chip will load 14-bits in a “data
tory. While LVP is ‘1’, RB4 is dedicated to low voltage word,” as described above, to be programmed into the
programming. Bring MCLR to VDD and then RB4 to configuration memory. A description of the memory
VDD to enter programming mode. All other specifica- mapping schemes of the program memory for normal
tions for high-voltage ICSP™ apply. operation and configuration mode operation is shown
To disable low voltage mode, the LVP bit must be pro- in Figure 2-1. After the configuration memory is
grammed to ‘0’. This must be done while entered with entered, the only way to get back to the user program
high voltage entry mode (LVP bit= 1). RB4 is now a memory is to exit the program/verify test mode by tak-
general purpose I/O pin. ing MCLR low (VIL).
Start
Program Cycle
PROGRAM CYCLE
Read Data
Command Load Data
Command
No Report
Data Correct? Programming Begin
Failure Programming
Command
Verify all
Locations @
VDDMIN
Report Verify No
Error @ Data Correct?
VDDMIN
Verify all
Locations @
VDDMAX
Report Verify No
Error @ Data Correct?
VDDMAX
Done
Start
Load
Configuration
Data
Increment Report No
Address Programming Data Correct?
Command Failure
Yes
No Address =
0x2004?
Yes
Increment
Address
Command
Increment
Address
Command
Increment Program
Set VDD =
Address Cycle
VDDMAX
Command (Config. Word)
Yes
Set VDD =
VDDMAX
No
After receiving this command, the chip will load in a 14- A load command must be given before every begin
bit “data word” when 16 cycles are applied. However, programming command. Programming of the appro-
the data memory is only 8-bits wide, and thus only the priate memory (test program memory, user program
first 8-bits of data after the start bit will be programmed memory or data memory) will begin after this command
into the data memory. It is still necessary to cycle the is received and decoded. An internal timing mechanism
clock the full 16 cycles in order to allow the internal cir- executes a write. The user must allow for program cycle
cuitry to reset properly. The data memory contains 64 time for programming to complete. No “end program-
words. Only the lower 8-bits of the PC are decoded by ming” command is required.
the data memory, and therefore if the PC is greater than This command is similar to the ERASE/PROGRAM
0x3F, it will wrap around and address a location within CYCLE command, except that a word erase is not
the physically implemented memory. If the device is done. It is recommended that a bulk erase be per-
code protected, the data is read as all zeros. formed before starting a series of programming only
2.3.2.4 READ DATA FROM PROGRAM cycles.
MEMORY 2.3.2.9 BULK ERASE PROGRAM MEMORY
After receiving this command, the chip will transmit After this command is performed, the next program
data bits out of the program memory (user or configu- command will erase the entire program memory.
ration) currently accessed starting with the second ris-
ing edge of the clock input. The RB7 pin will go into To perform a bulk erase of the program memory, the fol-
output mode on the second rising clock edge, and it will lowing sequence must be performed.
revert back to input mode (hi-impedance) after the 16th 1. Do a “Load Data All 1’s” command.
rising edge. A timing diagram of this command is 2. Do a “Bulk Erase User Memory” command.
shown in Figure 5-2.
3. Do a “Begin Programming” command.
2.3.2.5 READ DATA FROM DATA MEMORY 4. Wait 10 ms to complete bulk erase.
If the address is pointing to the test program memory
After receiving this command, the chip will transmit
(0x2000 - 0x200F), then both the user memory and the
data bits out of the data memory starting with the sec-
test memory will be erased. The configuration word will
ond rising edge of the clock input. The RB7 pin will go
not be erased, even if the address is pointing to location
into output mode on the second rising edge, and it will
0x2007.
revert back to input mode (hi-impedance) after the 16th
rising edge. As previously stated, the data memory is 8- Note: If the device is code-protected, the BULK
bits wide, and therefore, only the first 8-bits that are out- ERASE command will not work.
put are actual data.
2.3.2.10 BULK ERASE DATA MEMORY
2.3.2.6 INCREMENT ADDRESS
To perform a bulk erase of the data memory, the follow-
The PC is incremented when this command is ing sequence must be performed.
received. A timing diagram of this command is shown
1. Do a “Load Data All 1’s” command.
in Figure 5-3.
2. Do a “Bulk Erase Data Memory” command.
2.3.2.7 BEGIN ERASE/PROGRAM CYCLE 3. Do a “Begin Programming” command.
4. Wait 10 ms to complete bulk erase.
A load command must be given before every begin
programming command. Programming of the appro-
priate memory (test program memory, user program
Note: All BULK ERASE operations must take
memory or data memory) will begin after this command
place at 4.5 to 5.5 VDD range.
is received and decoded. An internal timing mechanism
executes an erase before write. The user must allow for
both erase and programming cycle times for program-
ming to complete. No “end programming” command is
required.
CP1 CP0 CP1 CP0 - CPD LVP BODEN MCLRE FOSC2 PWRTE WDTE F0SC1 F0SC0 Register: CONFIG
Address 2007h
bit13 bit0
Note 1: Enabling Brown-out Reset automatically enables Power-up Timer (PWRT) regardless of the value of bit PWRTE. Ensure
the Power-up Timer is enabled anytime Brown-out Reset is enabled.
2: All of the CP1:CP0 pairs have to be given the same value to enable the code protection scheme listed. The entire pro-
gram EEPROM will be erased if the code protection is reduced.
3: The entire data EEPROM will be erased when the code protection is turned off. The calibration space in the test memory
is not erased.
4: When MCLR is asserted in INTRC or ER mode, the internal clock oscillator is disabled.
To allow portability of code, the programmer is required to read the configuration word and ID locations from the hex
file when loading the hex file. If configuration word information was not present in the hex file then a simple warning
message may be issued. Similarly, while saving a hex file, configuration word and ID information must be included.
An option to not include this information may be provided.
Specifically for the PIC16F62X, the EEPROM data memory should also be embedded in the hex file (see
Section 5.1).
Microchip Technology Inc. feels strongly that this feature is important for the benefit of the end customer.
VIHH
MCLR 1µs min.
tset0 1 2 3 4 5 6 1 2 3 4 5 15 16
tdly2
RB6
(CLOCK)
thld0
}
}
100ns min. 100ns 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 X X stp_bit
(DATA) strt_bit
tset1 tdly1
thld1
1µs min.
}
}
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.
}
}
100ns min.
PIC16F8X
• PIC16CR84 RA4/T0CKI 3 16 OSC1/CLKIN
MCLR 4 15 OSC2/CLKOUT
• PIC16F84A VSS 5 14 VDD
RB0/INT 6 13 RB7
• PIC16F877 RB1 7 12 RB6
RB2 8 11 RB5
RB3 9 10 RB4
1.0 PROGRAMMING THE PIC16F8X
The PIC16F8X is programmed using a serial method.
The serial mode will allow the PIC16F8X to be pro- MCLR/VPP 1 40 RB7
grammed while in the users system. This allows for RA0/AN0 2 39 RB6
increased design flexibility. This programming specifi- RA1/AN1 3 38 RB5
RA2/AN2/VREF 4 37 RB4
cation applies to PIC16F8X devices in all packages.
RA3/AN3/VREF 5 36 RB3
RA4/T0CKI 6 35 RB2
1.1 Hardware Requirements RA5/AN4/SS 7 34 RB1
PIC16F877
RE0/RD/AN5 8 33 RB0/INT
The PIC16F8X requires one programmable power sup- RE1/WR/AN6 9 32 VDD
ply for VDD (4.5V to 5.5V) and a VPP of 12V to 14V. Both RE2/CS/AN7 10 31 VSS
supplies should have a minimum resolution of 0.25V. VDD 11 30 RD7/PSP7
VSS 12 29 RD6/PSP6
1.2 Programming Mode OSC1/CLKIN 13 28 RD5/PSP5
OSC2/CLKOUT 14 27 RD4/PSP4
The programming mode for the PIC16F8X allows pro- RC0/T1OSO/T1CKI 15 26 RC7/RX/DT
RC1/T1OSI/CCP2 16 25 RC6/TX/CK
gramming of user program memory, data memory, spe- RC2/CCP1 RC5/SDO
17 24
cial locations used for ID, and the configuration word. RC3/SCK/SCL 18 23 RC4/SDI/SDA
RD0/PSP0 19 22 RD3/PSP3
RD1/PSP1 20 21 RD2/PSP2
2.1 User Program Memory Map A user may store identification information (ID) in four
ID locations. The ID locations are mapped in [0x2000 :
The user memory space extends from 0x0000 to 0x2003]. It is recommended that the user use only the
0x1FFF (8K), of which 1K (0x0000 - 0x03FF) is physi- four least significant bits of each ID location. In some
cally implemented. In actual implementation the on- devices, the ID locations read-out in an unscrambled
chip user program memory is accessed by the lower fashion after code protection is enabled. For these
10-bits of the PC, with the upper 3-bits of the PC devices, it is recommended that ID location is written as
ignored. Therefore if the PC is greater than 0x3FF, it will “11 1111 1000 bbbb” where ‘bbbb’ is ID information.
wrap around and address a location within the physi- In other devices, the ID locations read out normally,
cally implemented memory. (See Figure 2-1). even after code protection. To understand how the
In programming mode the program memory space devices behave, refer to Table 4-2.
extends from 0x0000 to 0x3FFF, with the first half To understand the scrambling mechanism after code
(0x0000-0x1FFF) being user program memory and the protection, refer to Section 4.0.
second half (0x2000-0x3FFF) being configuration
memory. The PC will increment from 0x0000 to 0x1FFF
and wrap to 0x000 or 0x2000 to 0x3FFF and wrap
around to 0x2000 (not to 0x0000). Once in configura-
tion memory, the highest bit of the PC stays a ‘1’, thus
always pointing to the configuration memory. The only
way to point to user program memory is to reset the
part and reenter program/verify mode as described in
Section 2.3.
In the configuration memory space, 0x2000-0x200F
are physically implemented. However, only locations
0x2000 through 0x2007 are available. Other locations
are reserved. Locations beyond 0x200F will physically
access user memory. (See Figure 2-1).
1FFF
2000
Implemented Implemented Implemented
ID Location 2008
2000
ID Location
2001
ID Location
2002
ID Location
2003
Reserved
2005
Reserved
2006
Configuration Word
2007
3FFF
Start
Program Cycle
PROGRAM CYCLE
Read Data
Command Load Data
Command
No Report
Data Correct? Programming Begin
Failure Programming
Command
Verify all
Locations @
VDDMIN
Report Verify No
Error @ Data Correct?
VDDMIN
Verify all
Locations @
VDDMAX
Report Verify No
Error @ Data Correct?
VDDMAX
Done
Start
Load
Configuration
Data
Increment Report No
Address Programming Data Correct?
Command Failure
Yes
No Address =
0x2004?
Yes
Increment
Address
Command
Increment
Address
Command
Increment Program
Set VDD =
Address Cycle
VDDMAX
Command (Config. Word)
Yes
Set VDD =
VDDMAX
No
After receiving this command, the chip will load in a 14- A load command must be given before every begin
bit “data word” when 16 cycles are applied. However, programming command. Programming of the appro-
the data memory is only 8-bits wide, and thus only the priate memory (test program memory, user program
first 8-bits of data after the start bit will be programmed memory or data memory) will begin after this command
into the data memory. It is still necessary to cycle the is received and decoded. An internal timing mechanism
clock the full 16 cycles in order to allow the internal cir- executes a write. The user must allow for program cycle
cuitry to reset properly. The data memory contains 64 time for programming to complete. No “end program-
words. Only the lower 8-bits of the PC are decoded by ming” command is required.
the data memory, and therefore if the PC is greater than This command is similar to the ERASE/PROGRAM
0x3F, it will wrap around and address a location within CYCLE command, except that a word erase is not
the physically implemented memory. done. It is recommended that a bulk erase be per-
2.3.1.4 READ DATA FROM PROGRAM formed before starting a series of programming only
MEMORY cycles.
After receiving this command, the chip will transmit 2.3.1.9 BULK ERASE PROGRAM MEMORY
data bits out of the program memory (user or configu- After this command is performed, the next program
ration) currently accessed starting with the second ris- command will erase the entire program memory.
ing edge of the clock input. The RB7 pin will go into
output mode on the second rising clock edge, and it will To perform a bulk erase of the program memory, the fol-
revert back to input mode (hi-impedance) after the 16th lowing sequence must be performed.
rising edge. A timing diagram of this command is 1. Do a “Load Data All 1’s” command.
shown in Figure 5-2. 2. Do a “Bulk Erase User Memory” command.
2.3.1.5 READ DATA FROM DATA MEMORY 3. Do a “Begin Programming” command.
4. Wait 10 ms to complete bulk erase.
After receiving this command, the chip will transmit
If the address is pointing to the test program memory
data bits out of the data memory starting with the sec-
(0x2000 - 0x200F), then both the user memory and the
ond rising edge of the clock input. The RB7 pin will go
test memory will be erased. The configuration word will
into output mode on the second rising edge, and it will
not be erased, even if the address is pointing to location
revert back to input mode (hi-impedance) after the 16th
0x2007
rising edge. As previously stated, the data memory is 8-
bits wide, and therefore, only the first 8-bits that are out- For PIC16F84 perform the following commands:
put are actual data. 1. Issue Command 2 (write program memory).
2.3.1.6 INCREMENT ADDRESS 2. Send out 3FFFH data.
3. Issue Command 1 (toggle select even rows).
The PC is incremented when this command is 4. Issue Command 7 (toggle select even rows).
received. A timing diagram of this command is shown
5. Issue Command 8 (begin programming)
in Figure 5-3.
6. Delay 10 ms
2.3.1.7 BEGIN ERASE/PROGRAM CYCLE 7. Issue Command 1 (toggle select even rows).
A load command must be given before every begin 8. Issue Command 7 (toggle select even rows).
programming command. Programming of the appro- Note: If the device is code-protected
priate memory (test program memory, user program (PIC16F84A), the BULK ERASE com-
memory or data memory) will begin after this command mand will not work.
is received and decoded. An internal timing mechanism
executes an erase before write. The user must allow for
both erase and programming cycle times for program-
ming to complete. No “end programming” command is
required.
CP1 CP0 BKBUG - WRT CPD LVP BODEN CP1 CP0 PWRTE WDTE F0SC1 F0SC0 Register: CONFIG
bit13 bit0 Address 2007h
bit 13-12:
bit 11: BKBUG: Background Debugger Mode (This bit documented as reserved in data sheet)
1 = Background debugger functions not enabled
0 = Background debugger functional.
bit 5-4: CP1:CP0: Flash Program Memory Code Protection bits (2)
11 = Code protection off
10 = 1F00h to 1FFFh code protected
01 = 1000h to 1FFFh code protected
00 = 0000h to 1FFFh code protected
bit 11: Reserved: Set to ‘1’ for normal operation
bit 10: Unimplemented: Read as ‘1’
bit 9: WRT: Flash Program Memory Write Enable
1 = Unprotected program memory may be written to by EECON control
0 = Unprotected program memory may not be written to by EECON control
bit 8: CPD: Data EE Memory Code Protection
1 = Code protection off
0 = Data EE memory code protected
bit 7: LVP: Low voltage programming Enable bit
1 = RB3/PGM pin has PGM function, low voltage programming enabled
0 = RB3 is digital I/O, HV on MCLR must be used for programming
bit 6: BODEN: Brown-out Reset Enable bit (1)
1 = BOR enabled
0 = BOR disabled
bit 3: PWRTE: Power-up Timer Enable bit (1)
1 = PWRT disabled
0 = PWRT enabled
bit 2: WDTE: Watchdog Timer Enable bit
1 = WDT enabled
0 = WDT disabled
bit 1-0: FOSC1:FOSC0: Oscillator Selection bits
11 = RC oscillator
10 = HS oscillator
01 = XT oscillator
00 = LP oscillator
Note 1: Enabling Brown-out Reset automatically enables Power-up Timer (PWRT) regardless of the value of bit PWRTE.
Ensure the Power-up Timer is enabled anytime Brown-out Reset is enabled.
2: All of the CP1:CP0 pairs have to be given the same value to enable the code protection scheme listed.
To allow portability of code, the programmer is required to read the configuration word and ID locations from the hex
file when loading the hex file. If configuration word information was not present in the hex file then a simple warning
message may be issued. Similarly, while saving a hex file, configuration word and ID information must be included.
An option to not include this information may be provided.
Specifically for the PIC16F8X, the EEPROM data memory should also be embedded in the hex file (see Section 5.1).
Microchip Technology Inc. feels strongly that this feature is important for the benefit of the end customer.
PIC16CR83
To code protect: 0000000000XXXX
PIC16F84A
To code protect: 0000000000XXXX
PIC16F8XX
To code protect: 00X1XXXX00XXXX
Paramet
Conditions/
er Sym. Characteristic Min. Typ. Max. Units
Comments
No.
VDDP Supply voltage during programming 4.5 5.0 5.5 V
VDDV Supply voltage during verify VDDmin VDDmax V Note 1
VIHH High voltage on MCLR for test mode 12 14.0 V Note 2
entry
IDDP Supply current (from VDD) during 50 mA
program/verify
IHH Supply current from VIHH (on MCLR) 200 µA
VIH1 (RB6, RB7) input high level 0.8 VDD V Schmitt Trigger input
VIL1 (RB6, RB7) input low level MCLR 0.2 VDD V Schmitt Trigger input
(test mode selection)
P1 TvHHR MCLR rise time (VSS to VHH) for test 8.0 µs
mode entry
P2 Tset0 RB6, RB7 setup time (before pattern 100 ns
setup time)
P3 Tset1 Data in setup time before clock ↓ 100 ns
P4 Thld1 Data in hold time after clock ↓ 100 ns
P5 Tdly1 Data input not driven to next clock 1.0 µs
input (delay required between com-
mand/data or command/command)
P6 Tdly2 Delay between clock ↓ to clock ↑ of 1.0 µs
next command or data
P7 Tdly3 Clock to data out valid (during read 80 ns
data)
P8 Thld0 RB <7:6> hold time after MCLR ↑ 100 ns
- - Erase cycle time - - 10 ms
- - Program cycle time - - 10 ms
Note 1: Program must be verified at the minimum and maximum VDD limits for the part.
Note 2: VIHH must be greater than VDD + 4.5V to stay in programming/verify mode.
}
}
}
}
100ns 100ns
min. min.
Program/Verify Test Mode
Reset
VIHH
MCLR 100ns P6
P2
1 2 3 4 5 6 1µs min. 1 2 3 4 5 15
RB6 P8
(CLOCK)
100ns P7
RB7 0 0 1 0 0 0
(DATA) P5
P4
P3 1µs min.
}
}
100ns
min. RB7
RB7 = output input
RB7
0 1 1 0 0 0 0 0
(DATA)
P5
P3 P4 1µs min.
}
}
100ns
min
Program/Verify Test Mode
Reset
PIC16F876/873/872/870
RA1/AN1 3 26 RB5
• PIC16F872 • PIC16F877 RA2/AN2/VREF 4 25 RB4
RA3/AN3/VREF 5 24 RB3
• PIC16F873 RA4/T0CKI 6 23 RB2
RA5/AN4/SS 7 22 RB1
VSS 8 21 RB0/INT
PIC16F877/874/871
RE0/RD/AN5 8 33 RB0/INT
The PIC16F8XX requires one programmable power RE1/WR/AN6 9 32 VDD
RE2/CS/AN7 10 31 VSS
supply for VDD (4.5V to 5.5V) and a VPP of 12V to 14V VDD 11 30 RD7/PSP7
or VPP of (4.5V to 5.5V) when using low voltage In-Cir- VSS 12 29 RD6/PSP6
cuit Serial Programming™ (ICSP™). Both supplies OSC1/CLKIN 13 28 RD5/PSP5
should have a minimum resolution of 0.25V. OSC2/CLKOUT 14 27 RD4/PSP4
RC0/T1OSO/T1CKI 15 26 RC7/RX/DT
1.2 Programming Mode RC1/T1OSI/CCP2 16 25 RC6/TX/CK
RC2/CCP1 17 24 RC5/SDO
RC3/SCK/SCL 18 23 RC4/SDI/SDA
The programming mode for the PIC16F8XX allows pro-
RD0/PSP0 19 22 RD3/PSP3
gramming of user program memory, data memory, spe- RD1/PSP1 20 21 RD2/PSP2
cial locations used for ID, and the configuration word.
2.2 ID Locations
A user may store identification information (ID) in four
ID locations. The ID locations are mapped in [0x2000 :
0x2003]. It is recommended that the user use only the
four least significant bits of each ID location. In some
devices, the ID locations read-out in an unscrambled
fashion after code protection is enabled. For these
devices, it is recommended that ID location is written as
“11 1111 1000 bbbb” where ‘bbbb’ is ID information.
In other devices, the ID locations read out normally,
even after code protection. To understand how the
devices behave, refer to Table 4-1.
To understand the scrambling mechanism after code
protection, refer to Section 4.0.
2K 4K 8K
words words words
2000h ID Location 0h
1FFh Implemented Implemented Implemented
3FFh
2001h ID Location
400h
Implemented Implemented Implemented
7FFh
2002h ID Location
800h
Implemented Implemented
BFFh
2003h ID Location
C00h
Implemented Implemented
FFFh
2004h Reserved
1000h
Reserved Implemented
2005h Reserved
Reserved Implemented
2006h Device ID
Implemented
2007h Configuration Word
Implemented
1FFFh
2008h
Reserved Reserved Reserved
2100h
3FFFh
The program/verify mode is entered by holding pins The RB6 pin is used as a clock input pin, and the RB7
RB6 and RB7 low while raising MCLR pin from VIL to pin is used for entering command bits and data input/
VIHH (high voltage). In this mode, the state of the RB3 output during serial operation. To input a command, the
pin does not effect programming. Low-voltage ICSP clock pin (RB6) is cycled six times. Each command bit
programming mode is entered by applying VDD to is latched on the falling edge of the clock with the least
MCLR and raising RB3 from VIL to VDD. Once in this significant bit (LSB) of the command being input first.
mode the user program memory and the configuration The data on pin RB7 is required to have a minimum
memory can be accessed and programmed in serial setup and hold time (see AC/DC specifications) with
fashion. The mode of operation is serial, and the mem- respect to the falling edge of the clock. Commands that
ory that is accessed is the user program memory. RB6 have data associated with them (read and load) are
and RB7 are Schmitt Trigger Inputs in this mode. specified to have a minimum delay of 1 µs between the
command and the data. After this delay, the clock pin is
Note: The OSC must not have 72 osc clocks cycled 16 times with the first cycle being a start bit and
while the device MCLR is between VIL and the last cycle being a stop bit. Data is also input and
VIHH. output LSB first.
The sequence that enters the device into the program- Therefore, during a read operation the LSB will be
ming/verify mode places all other logic into the reset transmitted onto pin RB7 on the rising edge of the sec-
state (the MCLR pin was initially at VIL). This means ond cycle, and during a load operation the LSB will be
that all I/O are in the reset state (High impedance latched on the falling edge of the second cycle. A min-
inputs). imum 1µs delay is also specified between consecutive
The normal sequence for programming is to use the commands.
load data command to set a value to be written at the All commands are transmitted LSB first. Data words
selected address. Issue the begin programming com- are also transmitted LSB first. The data is transmitted
mand followed by read data command to verify, and on the rising edge and latched on the falling edge of
then increment the address. the clock. To allow for decoding of commands and
A device reset will clear the PC and set the address to reversal of data pin configuration, a time separation of
0. The “increment address” command will increment at least 1 µs is required between a command and a
the PC. The “load configuration” command will se the data word (or another command).
PC to 0x2000. The available commands are shown in The commands that are available are:
Table 2-1.
2.3.2.1 LOAD CONFIGURATION
2.3.1 LOW-VOLTAGE ICSP PROGRAMMING
MODE After receiving this command, the program counter
(PC) will be set to 0x2000. By then applying 16 cycles
When LVP bit is set to ‘1’, the low-voltage ICSP pro- to the clock pin, the chip will load 14-bits in a “data
gramming entry is enabled. Since the LVP configura- word,” as described above, to be programmed into the
tion bit allows low voltage ICSP programming entry in configuration memory. A description of the memory
its erased state, an erased device will have the LVP bit mapping schemes of the program memory for normal
enabled at the factory. While LVP is ‘1’, RB3 is dedi- operation and configuration mode operation is shown
cated to low voltage ICSP programming. Bring MCLR in Figure 2-1. After the configuration memory is
to VDD and then RB3 to VDD to enter programming entered, the only way to get back to the user program
mode. All other specifications for high-voltage ICSP™ memory is to exit the program/verify test mode by tak-
apply. ing MCLR low (VIL).
To disable low voltage ICSP mode, the LVP bit must be
programmed to ‘0’. This must be done while entered
with high voltage entry mode (LVP bit= 1). RB3 is now
a general purpose I/O pin.
Start
Program Cycle
PROGRAM CYCLE
Read Data
Command Load Data
Command
No Report
Data Correct? Programming Begin
Failure Programming
Command
Verify all
Locations @
VDDMIN
Report Verify No
Error @ Data Correct?
VDDMIN
Verify all
Locations @
VDDMAX
Report Verify No
Error @ Data Correct?
VDDMAX
Done
Start
Load
Configuration
Data
Increment Report No
Address Programming Data Correct?
Command Failure
Yes
No Address =
0x2004?
Yes
Increment
Address
Command
Increment
Address
Command
Increment Program
Set VDD =
Address Cycle
VDDMAX
Command (Config. Word)
Yes
Set VDD =
VDDMAX
No
After receiving this command, the chip will load in a 14- A load command must be given before every begin
bit “data word” when 16 cycles are applied. However, programming command. Programming of the appro-
the data memory is only 8-bits wide, and thus only the priate memory (test program memory, user program
first 8-bits of data after the start bit will be programmed memory or data memory) will begin after this command
into the data memory. It is still necessary to cycle the is received and decoded. An internal timing mechanism
clock the full 16 cycles in order to allow the internal cir- executes a write. The user must allow for program cycle
cuitry to reset properly. The data memory contains 64 time for programming to complete. No “end program-
words. Only the lower 8-bits of the PC are decoded by ming” command is required.
the data memory, and therefore if the PC is greater than This command is similar to the ERASE/PROGRAM
0x3F, it will wrap around and address a location within CYCLE command, except that a word erase is not
the physically implemented memory. If the device is done. It is recommended that a bulk erase be per-
code protected, the data is read as all zeros. formed before starting a series of programming only
2.3.2.4 READ DATA FROM PROGRAM cycles.
MEMORY 2.3.2.9 BULK ERASE PROGRAM MEMORY
After receiving this command, the chip will transmit After this command is performed, the next program
data bits out of the program memory (user or configu- command will erase the entire program memory.
ration) currently accessed starting with the second ris-
ing edge of the clock input. The RB7 pin will go into To perform a bulk erase of the program memory, the fol-
output mode on the second rising clock edge, and it will lowing sequence must be performed.
revert back to input mode (hi-impedance) after the 16th 1. Do a “Load Data All 1’s” command.
rising edge. A timing diagram of this command is 2. Do a “Bulk Erase Program Memory” command.
shown in Figure 5-2.
3. Do a “Begin Programming” command.
2.3.2.5 READ DATA FROM DATA MEMORY 4. Wait 10 ms to complete bulk erase.
If the address is pointing to the test program memory
After receiving this command, the chip will transmit
(0x2000 - 0x200F), then both the user memory and the
data bits out of the data memory starting with the sec-
test memory will be erased. The configuration word will
ond rising edge of the clock input. The RB7 pin will go
not be erased, even if the address is pointing to location
into output mode on the second rising edge, and it will
0x2007.
revert back to input mode (hi-impedance) after the 16th
rising edge. As previously stated, the data memory is 8- Note: If the device is code-protected, the BULK
bits wide, and therefore, only the first 8-bits that are out- ERASE command will not work.
put are actual data.
2.3.2.10 BULK ERASE DATA MEMORY
2.3.2.6 INCREMENT ADDRESS
To perform a bulk erase of the data memory, the follow-
The PC is incremented when this command is ing sequence must be performed.
received. A timing diagram of this command is shown
1. Do a “Load Data All 1’s” command.
in Figure 5-3.
2. Do a “Bulk Erase Data Memory” command.
2.3.2.7 BEGIN ERASE/PROGRAM CYCLE 3. Do a “Begin Programming” command.
4. Wait 10 ms to complete bulk erase.
A load command must be given before every begin
programming command. Programming of the appro-
priate memory (test program memory, user program
Note: All BULK ERASE operations must take
memory or data memory) will begin after this command
place at 4.5 to 5.5 VDD range.
is received and decoded. An internal timing mechanism
executes an erase before write. The user must allow for
both erase and programming cycle times for program-
ming to complete. No “end programming” command is
required.
CP1 CP0 RESV - WRT CPD LVP BODEN CP1 CP0 PWRTE WDTE F0SC1 F0SC0 Register: CONFIG
bit13 bit0 Address 2007h
bit 13-12:
bit 11: Reserved: Set to ‘1’ for normal operation
bit 5-4: CP1:CP0: Flash Program Memory Code Protection bits (2)
4K Devices:
11 = Code protection off
10 = not supported
01 = not supported
00 = 0000h to 0FFFh code protected
8K Devices:
11 = Code protection off
10 = 1F00h to 1FFFh code protected
01 = 1000h to 1FFFh code protected
00 = 0000h to 1FFFh code protected
bit 11: Reserved: Set to ‘1’ for normal operation
bit 10: Unimplemented: Read as ‘1’
bit 9: WRT: Flash Program Memory Write Enable
1 = Unprotected program memory may be written to by EECON control
0 = Unprotected program memory may not be written to by EECON control
bit 8: CPD: Data EE Memory Code Protection
1 = Code protection off
0 = Data EE memory code protected
bit 7: LVP: Low voltage programming Enable bit
1 = RB3/PGM pin has PGM function, low voltage programming enabled
0 = RB3 is digital I/O, HV on MCLR must be used for programming
bit 6: BODEN: Brown-out Reset Enable bit (1)
1 = BOR enabled
0 = BOR disabled
bit 3: PWRTE: Power-up Timer Enable bit (1)
1 = PWRT disabled
0 = PWRT enabled
bit 2: WDTE: Watchdog Timer Enable bit
1 = WDT enabled
0 = WDT disabled
bit 1-0: FOSC1:FOSC0: Oscillator Selection bits
11 = RC oscillator
10 = HS oscillator
01 = XT oscillator
00 = LP oscillator
Note 1: Enabling Brown-out Reset automatically enables Power-up Timer (PWRT) regardless of the value of bit PWRTE.
Ensure the Power-up Timer is enabled anytime Brown-out Reset is enabled.
2: All of the CP1:CP0 pairs have to be given the same value to enable the code protection scheme listed.
CP1 CP0 RESV - WRT CPD LVP BODEN CP1 CP0 PWRTE WDTE F0SC1 F0SC0 Register: CONFIG
bit13 bit0 Address 2007h
bit 13-12:
bit 5-4: CP1:CP0: Flash Program Memory Code Protection bits (2)
11 = Code protection off
10 = not supported
01 = not supported
00 = 0000h to 07FFh code protected
bit 11: Reserved: Set to ‘1’ for normal operation
bit 10: Unimplemented: Read as ‘1’
bit 9: WRT: Flash Program Memory Write Enable
1 = Unprotected program memory may be written to by EECON control
0 = Unprotected program memory may not be written to by EECON control
bit 8: CPD: Data EE Memory Code Protection
1 = Code protection off
0 = Data EE memory code protected
bit 7: LVP: Low voltage programming Enable bit
1 = RB3/PGM pin has PGM function, low voltage programming enabled
0 = RB3 is digital I/O, HV on MCLR must be used for programming
bit 6: BODEN: Brown-out Reset Enable bit (1)
1 = BOR enabled
0 = BOR disabled
bit 3: PWRTE: Power-up Timer Enable bit (1)
1 = PWRT disabled
0 = PWRT enabled
bit 2: WDTE: Watchdog Timer Enable bit
1 = WDT enabled
0 = WDT disabled
bit 1-0: FOSC1:FOSC0: Oscillator Selection bits
11 = RC oscillator
10 = HS oscillator
01 = XT oscillator
00 = LP oscillator
Note 1: Enabling Brown-out Reset automatically enables Power-up Timer (PWRT) regardless of the value of bit PWRTE.
Ensure the Power-up Timer is enabled anytime Brown-out Reset is enabled.
2: All of the CP1:CP0 pairs have to be given the same value to enable the code protection scheme listed.
To allow portability of code, the programmer is required to read the configuration word and ID locations from the hex
file when loading the hex file. If configuration word information was not present in the hex file then a simple warning
message may be issued. Similarly, while saving a hex file, configuration word and ID information must be included.
An option to not include this information may be provided.
Specifically for the PIC16F8XX, the EEPROM data memory should also be embedded in the hex file (see
Section 5.1).
Microchip Technology Inc. feels strongly that this feature is important for the benefit of the end customer.
VIHH
MCLR 1µs min.
tset0 1 2 3 4 5 6 1 2 3 4 5 15 16
tdly2
RB6
(CLOCK)
thld0
}
}
100ns min. 100ns 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 0 0 1 0 X X stp_bit
(DATA) strt_bit
tset1 tdly1
thld1
1µs min.
}
}
VIHH
MCLR
tdly2
Next Command
1µs min.
1 2 3 4 5 6 1 2
RB6
(CLOCK)
RB7 0
0 1 1 X X X 0
(DATA)
tset1 tdly1
thld1 1µs min.
}
}
100ns min.
VIH
MCLR 1µs min.
tset0 1 2 3 4 5 6 1 2 3 4 5 15 16
tdly2
RB6
(CLOCK)
thld0
}
}
100ns min. 100ns min.
RB3
VIH
MCLR
tdly2
tset0
thld0 1µs min.
1 2 3 4 5 6 1 2 3 4 5 15 16
RB6
(CLOCK)
tdly3
RB7 0 0 1 0 X X stp_bit
(DATA) strt_bit
tset1 tdly1
thld1
1µs min.
}
}
RB3
Reset Program/Verify Test Mode
VIH
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.
}
}
100ns min.
RB3
PROGRAMMING FIXTURE
Author: John Day
Microchip Technology Inc. A programming fixture is needed to assist with the self
programming operation. This is typically a small re-
usable module that plugs into the application PCB
INTRODUCTION being calibrated. Only five pin connections are needed
and this programming fixture can draw its power from
Many embedded control applications, where sensor the application PCB to simplify the connections.
offsets, slopes and configuration information are mea-
sured and stored, require a calibration step. Tradition-
ally, potentiometers or Serial EEPROM devices are
used to set up and store this calibration information.
This application note will show how to construct a pro-
gramming jig that will receive calibration parameters
from the application mid-range PICmicro® microcon-
trollers (MCU) and program this information into the
application baseline PICmicro MCU using the In-Circuit
Serial Programming (ICSP) protocol. This method uses
the PIC16CXXX In-Circuit Serial Programming algo-
rithm of the 14-bit core microcontrollers.
FIGURE 1:
PIC16C58
RC osc RB1 Wait
RB7
RB6
RB5 RB2 Done
RB4 RB3
To Application Input(s)
Optional PC Connection
FIGURE 2:
RB6
FIGURE 1:
VCC VCC
VCC
VCC
VCC
T0CKI
VSS VDD
VCC
VPP
VIN
VCC VCC
VREF
VPP
Errors : 0
Warnings : 0 reported, 0 suppressed
Messages : 2 reported, 0 suppressed
Errors : 0
Warnings : 1 reported, 0 suppressed
Messages : 1 reported, 0 suppressed
All rights reserved. © 2000 Microchip Technology Incorporated. Printed in the USA. 5/00 Printed on recycled paper.
Information contained in this publication regarding device applications and the like is intended through suggestion only and may be superseded by updates.
It is your responsibility to ensure that your application meets with your specifications. No representation or warranty is given and no liability is assumed by
Microchip Technology Incorporated with respect to the accuracy or use of such information, or infringement of patents or other intellectual property rights
arising from such use or otherwise. Use of Microchip’s products as critical components in life support systems is not authorized except with express written
approval by Microchip. No licenses are conveyed, implicitly or otherwise, except as maybe explicitly expressed herein, under any intellectual property
rights. The Microchip logo and name are registered trademarks of Microchip Technology Inc. in the U.S.A. and other countries. All rights reserved. All other
trademarks mentioned herein are the property of their respective companies.