2008-2015 Microchip Technology Inc. DS30009687F-page 7
PIC18F2XJXX/4XJXX FAMILY
2.3 Overview of the Programming
Process
Figure 2-5 shows the high-level overview of the
programming process in which a Bulk Erase is per-
formed first, then the code memory is programmed.
Since only nonvolatile Configuration Words are within
the code memory space, the Configuration Words are
also programmed as code. Code memory (including
the Configuration Words) is then verified to ensure that
programming was successful.
FIGURE 2-5: HIGH-LEVEL
PROGRAMMING FLOW
2.4 Entering and Exiting ICSP™
Program/Verify Mode
Entry into ICSP modes for PIC18F2XJXX/4XJXX Family
devices is somewhat different than previous PIC18
devices. As shown in Figure 2-6, entering ICSP
Program/Verify mode requires three steps:
1. Voltage is briefly applied to the MCLR
pin.
2. A 32-bit key sequence is presented on PGD.
3. Voltage is reapplied to MCLR and held.
The programming voltage applied to MCLR
is VIH, or
essentially, V
DD. There is no minimum time requirement
for holding at V
IH. After VIH is removed, an interval of at
least P19 must elapse before presenting the key
sequence on PGD.
The key sequence is a specific 32-bit pattern,
0100 1101 0100 0011 0100 1000 0101 0000’,
which is more easily remembered as 4D434850h in
hexadecimal. The device will enter Program/Verify
mode only if the sequence is valid. The Most Significant
bit of the Most Significant nibble must be shifted in first.
Once the key sequence is complete, V
IH must be
applied to MCLR
and held at that level for as long as
Program/Verify mode is to be maintained. An interval of
at least time, P20 and P12, must elapse before
presenting data on PGD. Signals appearing on PGD
before P12 has elapsed may not be interpreted as valid.
On successful entry, the program memory can be
accessed and programmed in serial fashion. While in
the Program/Verify mode, all unused I/Os are placed in
the high-impedance state.
Exiting Program/Verify mode is done by removing V
IH
from MCLR, as shown in Figure 2-7. The only
requirement for exit is that an interval, P16, should
elapse between the last clock and program signals on
PGC and PGD before removing V
IH.
When V
IH is reapplied to MCLR, the device will enter
the ordinary operational mode and begin executing the
application instructions.
FIGURE 2-6: ENTERING PROGRAM/VERIFY MODE
Start
Done
Perform Bulk
Erase
Program Memory
Verify Program
Done
Enter ICSP™
Exit ICSP™
MCLR
PGD
PGC
VDD
P13
b31 b30 b29 b28 b27 b2 b1 b0b3
...
Program/Verify Entry Code = 4D434850h
P2B
P2A
P19
P20
01001 0000
P12
VIH
VIH
P1
PIC18F2XJXX/4XJXX FAMILY
DS30009687F-page 8 2008-2015 Microchip Technology Inc.
FIGURE 2-7: EXITING PROGRAM/
VERIFY MODE
2.5 Serial Program/Verify Operation
The PGC pin is used as a clock input pin and the PGD
pin is used for entering command bits and data input/
output during serial operation. Commands and data are
transmitted on the rising edge of PGC, latched on the
falling edge of PGC, and are Least Significant bit (LSb)
first.
2.5.1 FOUR-BIT COMMANDS
All instructions are 20 bits, consisting of a leading 4-bit
command followed by a 16-bit operand, which depends
on the type of command being executed. To input a
command, PGC is cycled four times. The commands
needed for programming and verification are shown in
Table 2-3.
Depending on the 4-bit command, the 16-bit operand
represents 16 bits of input data or eight bits of input
data and eight bits of output data.
Throughout this specification, commands and data are
presented as illustrated in Table 2-4. The 4-bit command
is shown Most Significant bit (MSb) first. The command
operand or “Data Payload” is shown <MSB><LSB>.
Figure 2-8 demonstrates how to serially present a 20-bit
command/operand to the device.
2.5.2 CORE INSTRUCTION
The core instruction passes a 16-bit instruction to the
CPU core for execution. This is needed to set up
registers as appropriate for use with other commands.
TABLE 2-3: COMMANDS FOR
PROGRAMMING
TABLE 2-4: SAMPLE COMMAND
SEQUENCE
FIGURE 2-8: TABLE WRITE, POST-INCREMENT TIMING (1101)
MCLR
P16
PGD
PGD = Input
PGC
VDD
VIH
VIH
P17
Description
4-Bit
Command
Core Instruction
(Shift in 16-bit instruction)
0000
Shift out TABLAT register 0010
Table Read 1000
Table Read, Post-Increment 1001
Table Read, Post-Decrement 1010
Table Read, Pre-Increment 1011
Table Write 1100
Table Write, Post-Increment by 2 1101
Table Write, Start Programming,
Post-Increment by 2
1110
Table Write, Start Programming 1111
4-Bit
Command
Data
Payload
Core Instruction
1101 3C 40 Table Write,
post-increment by 2
1234
PGC
P5
PGD
PGD = Input
5678
1
234
P5A
9
10 11 13 15 161412
Fetch Next 4-Bit Command
1011
1234
nnnn
P3
P2
P2A
000000 010001111 0
04C3
P4
4-Bit Command 16-Bit Data Payload
P2B
2008-2015 Microchip Technology Inc. DS30009687F-page 9
PIC18F2XJXX/4XJXX FAMILY
3.0 DEVICE PROGRAMMING
Programming includes the ability to erase or write the
memory within the device.
The EECON1 register is used to control Write or Row
Erase operations. The WREN bit must be set to enable
writes; this must be done prior to initiating a write
sequence. It is strongly recommended that the WREN
bit only be set immediately prior to a program or erase
operation.
The FREE bit must be set in order to erase the program
space being pointed to by the Table Pointer. The erase
or write sequence is initiated by setting the WR bit.
3.1 ICSP™ Erase
3.1.1 ICSP BULK ERASE
The PIC18F2XJXX/4XJXX Family devices may be
Bulk Erased by writing 0180h to the table address,
3C0005h:3C0004h. The basic sequence is shown in
Table 3-1 and demonstrated in Figure 3-1.
Since the code-protect Configuration bit is stored in the
program code within code memory, a Bulk Erase
operation will also clear any code-protect settings for
the device.
The actual Bulk Erase function is a self-timed
operation. Once the erase has started (falling edge of
the 4th PGC after the NOP command), serial execution
will cease until the erase completes (parameter P11).
During this time, PGC may continue to toggle but PGD
must be held low.
TABLE 3-1: BULK ERASE COMMAND
SEQUENCE
FIGURE 3-1: BULK ERASE FLOW
FIGURE 3-2: BULK ERASE TIMING
4-Bit
Command
Data
Payload
Core Instruction
0000
0000
0000
0000
0000
0000
1100
0000
0000
0000
0000
0000
0000
1100
0000
0000
0E 3C
6E F8
0E 00
6E F7
0E 05
6E F6
01 01
0E 3C
6E F8
0E 00
6E F7
0E 04
6E F6
80 80
00 00
00 00
MOVLW 3Ch
MOVWF TBLPTRU
MOVLW 00h
MOVWF TBLPTRH
MOVLW 05h
MOVWF TBLPTRL
Write 01h to 3C0005h
MOVLW 3Ch
MOVWF TBLPTRU
MOVLW 00h
MOVWF TBLPTRH
MOVLW 04h
MOVWF TBLPTRL
Write 80h TO 3C0004h to
erase entire device.
NOP
Hold PGD low until erase
completes.
Start
Done
Write 8080h to
3C0004h to Erase
Entire Device
Write 0101h
Delay P11 + P10
Time
to 3C0005h
n
1234
1
21516
123
PGC
P5
P5A
PGD
PGD = Input
00011
P11
P10
Erase Time
000000
12
00
4
0
1 2 15 16
P5
123
P5A
4
0000
n
4-Bit Command
4-Bit Command 4-Bit Command
16-Bit
Data Payload
16-Bit
Data Payload
16-Bit
Data Payload
11

PIC18F25J50-I/SS

Mfr. #:
Manufacturer:
Microchip Technology
Description:
8-bit Microcontrollers - MCU Full Spd USB 32KB Flsh 4KBRAM nanoWatt
Lifecycle:
New from this manufacturer.
Delivery:
DHL FedEx Ups TNT EMS
Payment:
T/T Paypal Visa MoneyGram Western Union